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_00173
'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_00173
'Primary Code:
'In this case, there is only 1 function to Declare. It has single Long argument.
Declare Function FlipCoin LIB "gbsnippets_temp.dll" ALIAS "FlipCoin" (uLimit As Long) 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
Declare Function FlipCoin LIB "gbsnippets_temp.dll" ALIAS "FlipCoin" (uLimit As Long) 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
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
End Function
'gbs_00323
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm