|
Public IHook As Long
Public IThreadId As Long
Public ClassName As String
Public Sub EnableHook()
If IHook = 0 Then
IThreadId = GetCurrentThreadId
IHook = SetWindowsHookEx(WH_CBT, AddressOf HookProc, Application.Hinstance, IThreadId)
End If
End Sub
Public Sub FreeHook()
If IHook <> 0 Then
Call UnhookWindowsHookEx(IHook)
IHook = 0
End If
End Sub
Public Function HookProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lparam As Long) As Long
If nCode < 0 Then
HookProc = CallNextHookEx(IHook, nCode, wParam, lparam)
Exit Function
End If
If nCode = HCBT_SETFOCUS Then
ClassName = String(255, Chr(0))
GetClassName wParam, ClassName, 255
ClassName = Left(ClassName, InStr(ClassName, vbNullChar) - 1)
If ClassName = "EXCEL<" Or ClassName = "EXCEL6" Then
Application.StatusBar = "Õý´¦Óڱ༭״̬¡­¡­"
Else
Application.StatusBar = False
End If
End If
HookProc = CallNextHookEx(IHook, nCode, wParam, lparam)
End Function |
|