VB中msgbox弹出对话框的选项—(“确定”“取消”之类的)文字怎么改变?
VB中msgbox弹出对话框的选项中,可以有“确定”、“取消”之类的选项,有没有什么语句可以改变这些文字?(如:“确定”按钮文字改变为“下载”)'只是举例……...
VB中msgbox弹出对话框的选项中,可以有“确定”、“取消”之类的选项,有没有什么语句可以改变这些文字?
(如:“确定”按钮文字改变为“下载”) '只是举例…… 展开
(如:“确定”按钮文字改变为“下载”) '只是举例…… 展开
展开全部
'可以
'这是别人的代码
'以下在Form
Private Sub Command1_Click()
Call EnableHook
MsgBoxTitle = "MyTitle5"
MsgBox "haha", vbYesNo, MsgBoxTitle
Call FreeHook
End Sub
'以下程式在.Bas
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
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lparam As Any) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lparam As Long) As Long
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Const HCBT_ACTIVATE = 5
Public Const WH_CBT = 5
Public hHook As Long
Public MsgBoxTitle as String
Public Sub EnableHook()
If hHook = 0 Then
hHook = SetWindowsHookEx(WH_CBT, AddressOf HookProc, 0, App.ThreadID)
End If
End Sub
Public Sub FreeHook()
If hHook <> 0 Then
Call UnhookWindowsHookEx(hHook)
hHook = 0
End If
End Sub
Public Function HookProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lparam As Long) As Long
If nCode < 0 Then
HookProc = CallNextHookEx(hHook, nCode, wParam, lparam)
Exit Function
End If
'当MsgBox Activate之前去更改Button的标题
If nCode = HCBT_ACTIVATE Then
Dim str5 As String
Dim len5 As Long, i As Long
str5 = String(255, 0)
len5 = 256
i = GetWindowText(wParam, str5, len5)
str5 = Left(str5, InStr(1, str5, Chr(0)) - 1)
'如果Active Window上的标题是MsgBox上的标题
'
If str5 = MsgBoxTitle Then
'取得MsgBox上的所有子window
Call EnumChildWindows(wParam, AddressOf ChgButtonTitle, 0)
End If
End If
HookProc = 0 '令待完成的动作继续完成,若为1,则取消原本要完成的动作
End Function
Private Function ChgButtonTitle(ByVal hwnd As Long, ByVal lparam As Long) As Long
Dim clsName As String, len5 As Long, i As Long
Dim Title As String
If hwnd = 0 Then
ChgButtonTitle = 0
Exit Function
End If
clsName = String(255, 0)
len5 = 256
i = GetClassName(hwnd, clsName, 256)
clsName = Left(clsName, InStr(1, clsName, Chr(0)) - 1)
Title = String(255, 0)
i = GetWindowText(hwnd, Title, 256)
Title = Left(Title, InStr(1, Title, Chr(0)) - 1)
'找到Button型态的子Window,并更改其上的标题
If clsName = "Button" Then
If Title = "是(&Y)" Then
Call SetWindowText(hwnd, "下载")
Else
If Title = "否(&N)" Then
Call SetWindowText(hwnd, "关机")
End If
End If
End If
ChgButtonTitle = 1 '表示继续找下一个子Window
End Function
'这是别人的代码
'以下在Form
Private Sub Command1_Click()
Call EnableHook
MsgBoxTitle = "MyTitle5"
MsgBox "haha", vbYesNo, MsgBoxTitle
Call FreeHook
End Sub
'以下程式在.Bas
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
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lparam As Any) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lparam As Long) As Long
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Const HCBT_ACTIVATE = 5
Public Const WH_CBT = 5
Public hHook As Long
Public MsgBoxTitle as String
Public Sub EnableHook()
If hHook = 0 Then
hHook = SetWindowsHookEx(WH_CBT, AddressOf HookProc, 0, App.ThreadID)
End If
End Sub
Public Sub FreeHook()
If hHook <> 0 Then
Call UnhookWindowsHookEx(hHook)
hHook = 0
End If
End Sub
Public Function HookProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lparam As Long) As Long
If nCode < 0 Then
HookProc = CallNextHookEx(hHook, nCode, wParam, lparam)
Exit Function
End If
'当MsgBox Activate之前去更改Button的标题
If nCode = HCBT_ACTIVATE Then
Dim str5 As String
Dim len5 As Long, i As Long
str5 = String(255, 0)
len5 = 256
i = GetWindowText(wParam, str5, len5)
str5 = Left(str5, InStr(1, str5, Chr(0)) - 1)
'如果Active Window上的标题是MsgBox上的标题
'
If str5 = MsgBoxTitle Then
'取得MsgBox上的所有子window
Call EnumChildWindows(wParam, AddressOf ChgButtonTitle, 0)
End If
End If
HookProc = 0 '令待完成的动作继续完成,若为1,则取消原本要完成的动作
End Function
Private Function ChgButtonTitle(ByVal hwnd As Long, ByVal lparam As Long) As Long
Dim clsName As String, len5 As Long, i As Long
Dim Title As String
If hwnd = 0 Then
ChgButtonTitle = 0
Exit Function
End If
clsName = String(255, 0)
len5 = 256
i = GetClassName(hwnd, clsName, 256)
clsName = Left(clsName, InStr(1, clsName, Chr(0)) - 1)
Title = String(255, 0)
i = GetWindowText(hwnd, Title, 256)
Title = Left(Title, InStr(1, Title, Chr(0)) - 1)
'找到Button型态的子Window,并更改其上的标题
If clsName = "Button" Then
If Title = "是(&Y)" Then
Call SetWindowText(hwnd, "下载")
Else
If Title = "否(&N)" Then
Call SetWindowText(hwnd, "关机")
End If
End If
End If
ChgButtonTitle = 1 '表示继续找下一个子Window
End Function
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
应该没有,像“确定”“取消”等这些是定义在系统文件里面的,举个例子,有时候英文软件的对话框也会出现“确定”之类的。
所以这个应该是没有办法更改的,你可以自己编写一个窗体模仿。
所以这个应该是没有办法更改的,你可以自己编写一个窗体模仿。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
MSGBOX不能改变确定,取消,忽略等!这些包括每种按钮的值都是固定的,因为这样才可以很快判断用户的选择来确定下一步执行哪些代码!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
那是系统自定义的,建议你用多重窗体吧,这样就可以达到你想要的效果了。
呵呵!希望对你有帮助,祝你好运~
呵呵!希望对你有帮助,祝你好运~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询