Option Explicit Public 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 Public Declare Function SetDlgItemText Lib "user32" Alias "SetDlgItemTextA" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal lpString As String) As Long Public 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 Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long Public Const WH_CBT = 5 Public Const HCBT_ACTIVATE = 5 Public hHook As Long Public LanguageId As Long Public Function HookProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Dim hwnd As Long If nCode = HCBT_ACTIVATE Then hwnd = wParam If LanguageId = 0 Then 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 "重试" Else SetDlgItemText hwnd, vbOK, ByVal "OK" SetDlgItemText hwnd, vbCancel, ByVal "Cancel" SetDlgItemText hwnd, vbYes, ByVal "Yes" SetDlgItemText hwnd, vbNo, ByVal "No" SetDlgItemText hwnd, vbAbort, ByVal "Abort" SetDlgItemText hwnd, vbIgnore, ByVal "Ignore" SetDlgItemText hwnd, vbRetry, ByVal "Retry" End If UnhookWindowsHookEx hHook End If HookProc = 0 End Function Public Function MsgBox(Prompt As String, Optional Button As VbMsgBoxStyle = vbOKOnly, Optional Title As String, Optional ByVal wLanguageId As Integer) As VbMsgBoxResult LanguageId = wLanguageId 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
Option Explicit Private Sub Command1_Click() Dim LanguageNumber As Integer Dim LanguageStr As String LanguageNumber = Val(Text1.Text) If LanguageNumber = 0 Then LanguageStr = "中文" Else LanguageStr = "英文" End If MsgBox LanguageStr, vbOKCancel + vbInformation, "提示信息", LanguageNumber End Sub