原来写的一个显示等待窗口的过程,现在用不成了,因为我几乎所有的窗口 都改成了有模式的,即用 .show 1来调用,结果以前的过程用不成了,因为调用等待窗口不能用模式的,否则就真一直等下去了。
在google查了好久,也发贴问了,都没有很好的答案,结果我想了又想终于让我想出一个好办法来:
那就是,即然显示了 模式 窗口后就不能再显示无模式窗口,那么,我先显示那个无模式窗口不就结了!!
于是开始动手
Public
Sub
MsgWinShow(ByVal msg
As
String
, Optional WaitSec
As
Integer
)
Dim w, h, l, t
Load frmMsgWin
frmMsgWin.lblMsg.Caption = msg
With frmMsgWin
SetWindowPos .hwnd, HWND_TOPMOST, 0 , 0 , 0 , 0 , Flag
h = .lblMsg.Height + 15 * 40
w = .lblMsg.Width + 15 * 60
l = (Screen.Width - w) / 2
t = (Screen.Height - h) / 2
.Move l, t, w, h
.lblMsg.Left = Int (.ScaleWidth - .lblMsg.Width) / 2
.lblMsg.Top = Int (.ScaleHeight - .lblMsg.Height) / 2
End With
frmMsgWin.MouseP = Screen.MousePointer
Screen.MousePointer = vbHourglass
DoEvents
If WaitSec > 0 Then
Delay WaitSec * 1000
Call MsgWinHide
End If
Exit Sub
End Sub
Public Sub MsgWinHide()
frmMsgWin.lblMsg.Caption = ""
frmMsgWin.Left = - 2000 * 15
Screen.MousePointer = frmMsgWin.MouseP
End Sub
Dim w, h, l, t
Load frmMsgWin
frmMsgWin.lblMsg.Caption = msg
With frmMsgWin
SetWindowPos .hwnd, HWND_TOPMOST, 0 , 0 , 0 , 0 , Flag
h = .lblMsg.Height + 15 * 40
w = .lblMsg.Width + 15 * 60
l = (Screen.Width - w) / 2
t = (Screen.Height - h) / 2
.Move l, t, w, h
.lblMsg.Left = Int (.ScaleWidth - .lblMsg.Width) / 2
.lblMsg.Top = Int (.ScaleHeight - .lblMsg.Height) / 2
End With
frmMsgWin.MouseP = Screen.MousePointer
Screen.MousePointer = vbHourglass
DoEvents
If WaitSec > 0 Then
Delay WaitSec * 1000
Call MsgWinHide
End If
Exit Sub
End Sub
Public Sub MsgWinHide()
frmMsgWin.lblMsg.Caption = ""
frmMsgWin.Left = - 2000 * 15
Screen.MousePointer = frmMsgWin.MouseP
End Sub
很简单,就是不用时将其移出屏幕外,用的时间显示到屏幕中央,然后设置其 zorder 以使用其置顶。其实用
'SetWindowPos .hwnd, HWND_TOPMOST, 0, 0, 0, 0, Flag
就应该可以了,应该不用再用zorder,但好象效果是一样的!!