Date: 02-16-2022
Return to Index
created by gbSnippets
'This snippet is 3 of 4 covering DLL creation, in this case a simple DLL.
'It exports a couple of procedures but does not use a LibMain procedure.
'Check out the background information on DLLs at http://gbl_00320
'Primary Code:
'This simple example has two Functions, both of which are EXPORTed.
'The #Compile DLL compiler directive is the key statement. This tells
'the compiler to create a DLL (rather than an EXE). Otherwise, the
'functions are standard PowerBASIC functions.
#Compile DLL
%ID_Label = 500
Function FlipCoin ALIAS "FlipCoin" (uLimit&) EXPORT As Long 'exported function
'... see details in compilable example below
End Function
Function PleaseWait ALIAS "PleaseWait" (hParent as Dword) EXPORT as Long 'exported function
'... see details in compilable example below
End Function
'Compilable Example: (Jose Includes)
'This DLL provides two functions, a "Please Wait ..." popup dialog
'and a simple coin toss.
#Compiler PBWin 9, PBWin 10
#Compile DLL
%ID_Label = 500
Function FlipCoin ALIAS "FlipCoin" (uLimit&) EXPORT As Long
Function = Rnd(0,uLimit&)
End Function
Function PleaseWait ALIAS "PleaseWait" (hParent as Dword) EXPORT as Long
Local x As Long, y As Long, w As Long, h As Long, wX As Long, wY As Long, hWait as Long
Dialog Get Client hParent To w,h
wX = 150 : wY = 60 'size of popup dialog
x = (w-wX)/2 'gets left position of WaitDialog to center over app
y = (h-wY)/2 'gets top position of WaitDialog to center over app
Dialog New Pixels, hParent, "", x, y, wX, wY, %WS_Popup To hWait
Control Add Label, hWait, %ID_Label, "Please wait ... ", 0, 0, wX, wY, %SS_Center Or %SS_CenterImage Or %WS_Border
Control Set Color hWait, %ID_Label, %Black, %White
Dialog Show Modeless hWait
Function = hWait
End Function
'gbs_00297
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm