|
本帖最后由 smileyoufu 于 2014-2-14 13:14 编辑
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElaspe As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Dim TID As Long
' 主 题:庆祝元宵/情人双节,源码大放送
' 函数名称:MsgboxEx
' 函数作用:在指定时间后,会自动关闭的Msgbox对话框。使用户感受更人性化,
' 参数说明:与原Msgbox一致,只是多最后一个参数Sec,长整型(Long),用来表示延迟关闭对话框的秒数,默认为3秒
' 发 布 者:席主习 QQ:86053924
' 发布日期:2014年情人节
' 声 明:此非原创,代码是到处抄来,根据需要东拼西凑的(情人节也不一定要约会原配嘛,不过要做好事前/善后工作哟,谨防……),感谢原作者们
' 调用示例
Sub test5秒后关闭()
MsgboxEx "你好,这是测试代码,5秒后将自动关闭", 64, "5秒后将自动关闭", , , 5
End Sub
Sub test默认3秒后关闭()
MsgboxEx "你好,这是测试代码,3秒后将自动关闭", 64, "5秒后将自动关闭"
End Sub
'---------------------------------------------------------------------------------
Public Sub MsgboxEx(Pormpt As String, Optional Buttons As Long, Optional Title As String, Optional HelpFile As String, Optional Contest As Long, Optional Sec As Long = 3)
Dim A As Long
TID = SetTimer(0, 0, Sec * 1000, AddressOf CloseMsgbox)
Call MsgBox(Pormpt, Buttons, Title, HelpFile, Contest)
End Sub
Public Sub CloseMsgbox(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal Systime As Long)
Application.SendKeys "~", True
KillTimer 0, TID
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
|