?
Solved

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

Posted on 2003-02-22
6
Medium Priority
?
133 Views
Last Modified: 2010-05-03
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
0
Comment
Question by:LordSkitch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 600 total points
ID: 7998499
Hello LordSkitch,

just for my own learning i think you need subclasing your form to get a hold of the messages before windows does
http://www.mvps.org/the_nerd/VBSmartMirror/library/smartsubclass/smartsubclass.htm

but as said this is just to be linked in the thread and maybe it helps

HAGD:O)Bruintje
0
 
LVL 1

Author Comment

by:LordSkitch
ID: 8000057
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?
0
 
LVL 1

Author Comment

by:LordSkitch
ID: 8000075
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?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:LordSkitch
ID: 8000076
AH! dont hit the back button after you post. lol it makes duplicates.
0
 
LVL 1

Author Comment

by:LordSkitch
ID: 8001487
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
0
 
LVL 44

Expert Comment

by:bruintje
ID: 8002531
:)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question