香港新浪網 MySinaBlog
« 上一篇 | 下一篇 »
Emily | 31st Jul 2006, 00:12 AM | API / Add-in | (2438 Reads)

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Call MakeNormal(Application.hwnd)
End Sub

'---------------------------------------------------------------------------------------
' Module    : Module1
' DateTime  :
' Author    :
' Purpose   :
'---------------------------------------------------------------------------------------

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, y, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const TOPMOST_FLAGS = SWP_NOMOVE Or SWP_NOSIZE

Public Sub MakeNormal(hwnd As Long)
    SetWindowPos hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub

Public Sub MakeTopMost(hwnd As Long)
    SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub


Sub Test()
    Call MakeTopMost(Application.hwnd)
    ' Call MakeNormal(Application.hwnd)
End Sub


[2]

Only tested in WinXp + Office 2003


[引用] | 作者 Emily | 2nd Aug 2006 12:08 PM | [舉報垃圾留言]

[1]

2000下出错


[引用] | 作者 yigepure | 31st Jul 2006 21:26 PM | [舉報垃圾留言]