Results 1 to 2 of 2

Thread: Newbie : Processing Other Windows Messages

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2001
    Posts
    1

    Post Newbie : Processing Other Windows Messages

    Hi,
    If someone could guide me to a website, book, .. any resource
    to find info about how to check for standard windows messages
    WM_*, EM_* and so on. And how to declare the handlers (functions, subs)
    Any help is greatly appreciated.
    Thank You
    Dennis

  2. #2
    Megatron
    Guest
    You need to subclass you App.

    Add to a Module
    VB Code:
    1. Public Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
    2. Public 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 Long
    3. Public Const GWL_WNDPROC = (-4)
    4. Public WndProcOld As Long
    5. Private Const WM_CLOSE = &H10
    6.  
    7. Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    8.     If hwnd = WM_CLOSE Then MsgBox "App is closing"
    9.     WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&)
    10. End Function
    11.  
    12. Sub SubClassWnd(hwnd As Long)
    13.     WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc)
    14. End Sub
    15.  
    16. Sub UnSubclassWnd(hwnd As Long)
    17.     SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
    18.     WndProcOld& = 0
    19. End Sub

    Usage:
    VB Code:
    1. Private Sub Form_Load()
    2.     SubClassWnd hwnd
    3. End Sub
    4.  
    5. Private Sub Form_Unload(Cancel As Integer)
    6.     UnSubclassWnd hwnd
    7. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width