Date: 02-16-2022
Return to Index
created by gbSnippets
'Sometimes you have an operation going in the background and you want
'the user to wait unti it is done. This code places a simple "Please Wait ..."
'message on the main dialog.
'The approach uses a caption-less dialog with a single label control to
'hold the message.
'Primary Code:
Sub DisplayWaitDialog(hParent as Dword)
Local x As Long, y As Long, w As Long, h As Long, wX As Long, wY As Long
Dialog Get Client hParent To w,h
wX = 150 : wY = 60
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
End Sub
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
%ID_Label = 1000
Global hDlg as Dword, hWait 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
DisplayWaitDialog hDlg
Sleep 2000
Dialog End hWait
End If
End Function
Sub DisplayWaitDialog(hParent as Dword)
Local x As Long, y As Long, w As Long, h As Long, wX As Long, wY As Long
Dialog Get Client hParent To w,h
wX = 150 : wY = 60
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, hDlg, "", 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
End Sub
'gbs_00016
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm