'以下申明放在标准模块中 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 Global Const HWND_TOPMOST = -1 Global Const HWND_NOTOPMOST = -2 Global Const SWP_NOMOVE = 2 Global Const SWP_NOSIZE = 1 Global Const flags = SWP_NOMOVE Or SWP_NOSIZE Public Sub NOOntop(frmpg As Object) '取消最前 SetWindowPos frmpg.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, flags End Sub Public Sub AlwaysONtop(frmpg As Object) '设置最前 SetWindowPos frmpg.hwnd, HWND_TOPMOST, 0, 0, 0, 0, flags End Sub '窗体部分. AlwaysONtop Me '设置最前显示 NOOntop Me '取消最前显示
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
Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2
Global Const SWP_NOMOVE = 2
Global Const SWP_NOSIZE = 1
Global Const flags = SWP_NOMOVE Or SWP_NOSIZE
Public Sub NOOntop(frmpg As Object) '取消最前
SetWindowPos frmpg.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, flags
End Sub
Public Sub AlwaysONtop(frmpg As Object) '设置最前
SetWindowPos frmpg.hwnd, HWND_TOPMOST, 0, 0, 0, 0, flags
End Sub
'窗体部分.
AlwaysONtop Me '设置最前显示
NOOntop Me '取消最前显示