Date: 03-28-2012
Return to Index
created by gbSnippets
'Sometimes an application may not find a DLL it needs on the user's
'system, so the programmer would like so loading of the DLL to be
'optional.
'Primary Code:
'Compilable Example:
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
#Include "Win32API.inc"
'Declare Function WinMsg LIB "WINMSG.DLL" ALIAS "WindowMessageA" (ByVal MsgNum As Long) AS String
Declare Function WinMsg (ByVal MsgNum As Long) As String 'take out LIB and ALIAS sections
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
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
Local hLib As DWord, pAddress As DWord, Result As String
If IsFile("winmsg.dll") Then
hLib = LoadLibrary("winmsg.dll")
pAddress = GetProcAddress(hLib, "WindowMessageA") 'use ALIAS
Call DWord pAddress Using WinMsg(%WM_InitDialog) To Result 'use Declared name
FreeLibrary hLib
MsgBox Result
End if
End If
End Function
'gbs_00412
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm