Date: 07-23-2010
Return to Index
'A message pump is used to keep a modeless dialog on the screen. It's essentially Do Loop
'that runs until the last application dialog has been ended.
'Primary code:
'Syntax: DIALOG DOEVENTS [sleep&] [TO count&]
'Used to create a message pump for a modeless dialog, allowing other threads or processes
'to continue. Count& is the number of active dialogs within the application.
Do
Dialog Doevents 0 To Count&
Loop While Count&
'You can also do it the SDK way:
While GetMessage(Msg, %NULL, 0, 0)
If IsFalse IsDialogMessage (hDlg, Msg)
TranslateMessage Msg
DispatchMessage Msg
End If
Wend
'Note: Although the middle line looks like a loop of some kind, it is not.
' 0 is the sleep time for the app each time Dialog DoEvents is called.
' Count& is returned by Dialog Events, telling how many dialogs are currently
' open in the application. When Count& is zero, all dialogs are closed and the app ends
'Compilable Example:
#Compile Exe
#Dim All
Global hDlg As DWord, Count&
Function PBMain() As Long
Dialog New Pixels, 0, "Modeless Dialog",300,300,200,200, %WS_OverlappedWindow, 0 To hDlg
Control Add Button, hDlg, 100,"Push", 50,50,100,20
Dialog Show Modeless hDlg Call DlgProc
Do
Dialog Doevents 0 To Count&
Loop While Count&
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
'test code
MsgBox "Button pushed"
End If
End Function
'gbs_00047
created by gbSnippets: http://www.garybeene.com