Link to home
Start Free TrialLog in
Avatar of LordSkitch
LordSkitchFlag for United States of America

asked on

How do you trap messages that are sent to a registered window?

I've got a window thats registered with another that sends messages to my window, and I've spied the messages it receives using spyxx, and it says my program's receiving the right messages. Such as:

message: 0x0536 [User-defined:WM_USER+310] wParam:0000023 lParam:0000022

now, how do I get my program to realize its been sent a message? And how do I get the wParam and lParam from it? I've tried using GetMessage and such, and it just halts the program in an endless loop, I probably used it wrong, so ya know, a snippet of code showing how to trap a message wouldn't be a hinderance. =)

Skitchy
ASKER CERTIFIED SOLUTION
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LordSkitch

ASKER

People have told me that before, but I really don't understand subclassing lol, every time I see it, its to make bloody multi-line tooltips, or add an icon to the system tray, not exactly what im lookin to do... any help on how to trap messages?
People have told me that before, but I really don't understand subclassing lol, every time I see it, its to make bloody multi-line tooltips, or add an icon to the system tray, not exactly what im lookin to do... any help on how to trap messages?
AH! dont hit the back button after you post. lol it makes duplicates.
AHA! ok, im just really really stupid.

i just use this one to hook into the queue,
Public Sub HookForm(F As Form)
    PrevProc = SetWindowLong(F.hWnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub

use this one to unhook,
Public Sub UnHookForm(F As Form)
    SetWindowLong F.hWnd, GWL_WNDPROC, PrevProc
End Sub


then add the things to check for here, and do whatever it is i need to do!

Public Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    If uMsg = WM_USER + 303 Then
       
    End If
    WindowProc = CallWindowProc(PrevProc, hWnd, uMsg, wParam, lParam)
End Function