就是Message Box 啊!?有问题吗??
解决方案 »
- DLL(C++)如何操作VB中WebBrowser对象?
- 做了一个文本框控件,可是拖到窗体上时,可以设置自定义属性,当时可以反映,可是保存不了.下次打开时又是这个控件设计时的大小了.
- 如何使用MSChart呀?
- [文章]如何插入Access库记录后马上得到自动编号值
- 在线等了不给解决也过来看看了!如何在页面上加一个下拉筐和listbox??请各位大大多指教了
- 求救于一条SQL语句,100分求救!!!---关于表的连接
- 我用DrawText函数编写打印程序,打印速度很慢,不知什么原因?请问有那些因素影响程序的打印速度?
- 帮助文档的问题
- 菜鸟问题:ado与sql sever如何建立连接?有什么比较好的书可以看么?
- ActiveReport怎样能打印出行号(即按记录行数打印(1,2,3,4...)
- 如何引用listbox复选框的值
- 如何根据数据库表中的记录数确定MSFlexGrid控件的行数.
给自己心情放一个假吧,如果心情不好,老是呆在网上的话,只会越来越痛苦,不如请假二三天,有朋友就邀几个朋友,没朋友就一个人坐火车去一个完全陌生的地方,休息一天,心情就轻松了,说不准还遇到几件趣事。我试过了效果很好。:)
另,我一直很敬佩你,包括你的为人和技术水平!不要一天到晚都泡在网上,我希望你能常来CSDN和大家一起讨论技术问题,但这是“常来”,否则你会发现自己好像渐渐的失去一些东西。
听歌以放松心情……(被Win2000吓怕了)
他是微软那帮混蛋写的,但又很好用的东东。嗨不用都不行!!!
不过,以下代码即是不用VB的MsgBoxAttribute VB_Name = "basMessageBox"
Declare Function MessageBoxEx Lib "user32" Alias "MessageBoxExA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal uType As Long, ByVal wLanguageId As Long) As Long
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function GetCurrentThreadId Lib "KERNEL32" () As Long
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 SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As LongConst GWL_HINSTANCE = (-6)
Const SWP_NOSIZE = &H1
Const SWP_NOZORDER = &H4
Const SWP_NOACTIVATE = &H10
Const HCBT_ACTIVATE = 5
Const WH_CBT = 5Type RECT
left As Long
top As Long
Right As Long
Bottom As Long
End TypeDim hHook As Long
Dim parenthWnd As LongPublic Function MessageBox(ByVal hwnd As Long, ByVal Prompt As String, Optional ByVal Buttons As VbMsgBoxStyle = vbOKOnly, Optional ByVal Title As String = "", Optional ByVal HelpFile As String, Optional ByVal Context, Optional ByVal centerForm As Boolean = True) As VbMsgBoxResult
Dim ret As Long
Dim hInst As Long
Dim Thread As Long
'Set up the CBT hook
parenthWnd = hwnd
hInst = GetWindowLong(hwnd, GWL_HINSTANCE)
Thread = GetCurrentThreadId()
If centerForm = True Then
hHook = SetWindowsHookEx(WH_CBT, AddressOf WinProcCenterForm, hInst, Thread)
Else
hHook = SetWindowsHookEx(WH_CBT, AddressOf WinProcCenterScreen, hInst, Thread)
End If
ret = MessageBoxEx(hwnd, Prompt, Title, Buttons, 0)
MessageBox = ret
End FunctionPrivate Function WinProcCenterScreen(ByVal lMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim rectForm As RECT, rectMsg As RECT
Dim x As Long, y As Long
If lMsg = HCBT_ACTIVATE Then
'Show the MsgBox at a fixed location (0,0)
GetWindowRect wParam, rectMsg
x = Screen.Width / Screen.TwipsPerPixelX / 2 - (rectMsg.Right - rectMsg.left) / 2
y = Screen.Height / Screen.TwipsPerPixelY / 2 - (rectMsg.Bottom - rectMsg.top) / 2
SetWindowPos wParam, 0, x, y, 0, 0, SWP_NOSIZE Or SWP_NOZORDER Or SWP_NOACTIVATE
'Release the CBT hook
UnhookWindowsHookEx hHook
End If
WinProcCenterScreen = False
End FunctionPrivate Function WinProcCenterForm(ByVal lMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim rectForm As RECT, rectMsg As RECT
Dim x As Long, y As Long
'On HCBT_ACTIVATE, show the MsgBox centered over Form1
If lMsg = HCBT_ACTIVATE Then
'Get the coordinates of the form and the message box so that
'you can determine where the center of the form is located
GetWindowRect parenthWnd, rectForm
GetWindowRect wParam, rectMsg
x = (rectForm.left + (rectForm.Right - rectForm.left) / 2) - ((rectMsg.Right - rectMsg.left) / 2)
y = (rectForm.top + (rectForm.Bottom - rectForm.top) / 2) - ((rectMsg.Bottom - rectMsg.top) / 2)
'Position the msgbox
SetWindowPos wParam, 0, x, y, 0, 0, SWP_NOSIZE Or SWP_NOZORDER Or SWP_NOACTIVATE
'Release the CBT hook
UnhookWindowsHookEx hHook
End If
WinProcCenterForm = False
End Function可见这是一个封装在User32中的一个Win32窗口类
都是我佩服的人。。有空的话多回答我的问题
http://www.csdn.net/expert/topic/536/536539.xml
http://www.csdn.net/expert/topic/531/531156.xml
不过我用API重写Msgbox不是没道理,效率上要高得多,至于安不安全,
我也不好说,看下面的贴子,明天我就会把文章贴出来。