请注意红色的部分!!
模块代码:
[CODE]
Option Explicit
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 Declare Function SetDlgItemText Lib "user32" Alias "SetDlgItemTextA" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal lpString As String) As Long
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Const WH_CBT = 5
Private Const HCBT_ACTIVATE = 5
Private hHook As Long
Private Function HookProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If nCode = HCBT_ACTIVATE Then
Dim hwnd As Long
hwnd = wParam
SetDlgItemText hwnd, vbOK, ByVal "对拉~~" SetDlgItemText hwnd, vbCancel, ByVal "去死!!" SetDlgItemText hwnd, vbYes, ByVal "是" SetDlgItemText hwnd, vbNo, ByVal "否" SetDlgItemText hwnd, vbAbort, ByVal "放弃" SetDlgItemText hwnd, vbIgnore, ByVal "忽略" SetDlgItemText hwnd, vbRetry, ByVal "重试" UnhookWindowsHookEx hHook
End If
HookProc = 0
End Function
Public Function MsgBox(Prompt As String, Optional Button As VbMsgBoxStyle = vbOKOnly, Optional Title As String) As VbMsgBoxResult
If Len(Title) = 0 Then Title = App.Title
hHook = SetWindowsHookEx(WH_CBT, AddressOf HookProc, App.hInstance, App.ThreadID)
MsgBox = MessageBox(
Form1.hwnd, Prompt, Title, Button)
End Function
[/CODE]
窗体的:
[CODE]
Option Explicit
Private Sub
Command1_Click()
If MsgBox("你好", vbOKCancel + vbInformation) = vbOK Then
Call MsgBox("你按了OK", vbInformation)
Else
Call MsgBox("你按了NO", vbInformation)
End If
End Sub
[/CODE]