Date: 02-16-2022
Return to Index
created by gbSnippets
'This snippet shows how to use the simple DLL created in the snippet: http://gbl_00297
'To use exported Subs/Functions from a DLL, you must Declare each Sub/Function.
'See the snippet ".Declare Syntax" for more information on Declare syntax options. http://gbl_00080
'Primary Code:
'In this case, there are two functions to Declare. Each has a single Long argument.
Declare Function FlipCoin LIB "gbsnippets_temp.dll" ALIAS "FlipCoin" (uLimit As Long) As Long
Declare Function PleaseWait LIB "gbsnippets_temp.dll" ALIAS "PleaseWait" (hParent as Dword) As Long
'Once Declared, a function is used just like any other function in the application.
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Declare Function FlipCoin LIB "gbsnippets_temp.dll" ALIAS "FlipCoin" (uLimit As Long) As Long
Declare Function PleaseWait LIB "gbsnippets_temp.dll" ALIAS "PleaseWait" (hDlg as Dword) As Long
Global hDlg as Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 50,10,100,20
Control Add Label, hDlg, 110,"<result>", 50,40,100,20
Control Add Button, hDlg, 120,"Push", 50,70,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
Control Set Text hDlg, 110, Str$(FlipCoin(10)) 'here, the function FlipCoin() returns a value of 0-10
End If
If CB.Msg = %WM_Command AND CB.Ctl = 120 AND CB.Ctlmsg = %BN_Clicked Then
Local hWait as Dword
hWait = PleaseWait (hDlg)
Sleep 2000
Dialog End hWait
End If
End Function
'gbs_00298
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm