CodeItBetter Programming Another VB Programming Blog

How to call message box using MessageBox API

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'System & API - How to call message box using MessageBox API
Private Const MB_OK = &H0&
Private Const MB_OKCANCEL = &H1&
Private Const MB_ABORTRETRYIGNORE = &H2&
Private Const MB_YESNOCANCEL = &H3&
Private Const MB_YESNO = &H4&
Private Const MB_RETRYCANCEL = &H5&
 
Private 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 Form_Load()
    Dim rval As Long
    rval = MessageBox(Me.hwnd, "Message Box Text for testing purpose", "Test Message", MB_YESNO)
    Select Case rval
    Case 1
        MsgBox "OK button Pressed"
    Case 2
        MsgBox "Cancel button Pressed"
    Case 3
        MsgBox "Abort button Pressed"
    Case 4
        MsgBox "Retry button Pressed"
    Case 5
        MsgBox "Ignore button Pressed"
    Case 6
        MsgBox "Yes button Pressed"
    Case 7
        MsgBox "No button Pressed"
    End Select
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.