CodeItBetter Programming Another VB Programming Blog

How to keep your Background Processes running when displaying Message Box

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'System & API - How to keep your Background Processes running when displaying Message Box

'In Visual Basic, if you make a call to the MsgBox function, all other background processes
'that you may have running (counters, timer events, etc) will be stopped until the user
'acknowledges the Msgbox dialog box.

'To overcome this problem, you must use the Windows API call for the MessageBox function.
'It looks and acts the same as the Visual Basic "msgbox" function, but does not stop the
'background processes from running.

Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, _
    ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
 
Private Sub Command1_Click()
    MessageBox Me.hwnd, "Notice the timer does not stop!", "API Call", vbOKOnly + vbExclamation
End Sub
 
Private Sub Timer1_Timer()
    Label1.Caption = Time
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.