Get all Windows message values

xiaoxiao2021-03-06  25

Programming under Windows, you can't deal with various messages. So, how to get a variety of messages is a good way to use the API browser, but the API browser is not included in all message values. The following measures will be available Message Value The following code Option Explicit in the module

Private Declare Function CallWindowProc Lib "user32" Alias ​​"CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias ​​"SetWindowLongA "(Byval HWNDEX As Long, Byval Dwnewlong As long) As longprivate const gwl_wndproc = (-4) DIM PrevPROC AS LONG

Public Function WindowProc (ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Debug.Print "msg =" & uMsg WindowProc = CallWindowProc (PrevProc, hWnd, uMsg, wParam, lParam) End Function

Public Sub Hookform (Byval Hwnd As Long) PrevProc = SetWindowlong (HWND, GWL_WNDPROC, Addressof WINDOPROC) End Sub

Public Sub UnHookform (Byval Hwnd As Long) SetWindowlong Hwnd, GWL_WndProc, Prevprocend Sub

The following code Option Explicit in the form

PRIVATE SUB FORM_LOAD () hookform me.hwndend Sub

Private Sub Form_Unload (Cancel AS Integer) UnHookform Me.hwndend Sub

转载请注明原文地址:https://www.9cbs.com/read-59293.html

New Post(0)