Windows messages : How to find the sender of of WM_USER message

DBTechnique
DBTechnique used Ask the Experts™
on
Hello everyone,
I am having trouble with one function of my view.
This function is called on a windows message WM_USER + 100.
My problem is that my view is receiving the message again and again.
I can't find what part of the software is sending that message.
I used Spy++, but I don't know if I can use it to find the sender of the message.
It tells me correctly that my view is receiving the message but not who sent it.
Is Spy++ able to do that ? How can I find the sender ? Do you know another tool to use for that purpose ?
Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Author of the Year 2009
Commented:
Wow... good question.  
Spy++ does not appear to record the source process or thread, nor is that available with a message hook.  
Any process can send any message to any window and remain anonymous while doing so.  Until recently, that's been a security issue with System Services that expose a U/I -- some outside program could pull the strings of the Service, and thus obtain elevated privileges.  
However, If I were you, I'd not suspect outside programs until I'd ruled out my own program and even controls (such as RichEdit) that are outside of your direct control.   WM_USER+100 is a common value -- its usually safe to assume that a standard window (such as a button control) will ignore it.  
However, I know that MFC uses, for instance, WM_USER+101 in its CMFCPropertyGridCtrl intenal handling, so I can't rule out +100 (though I can't find it in the MFC source files).
You might be able to get a clue by looking at the lParam and wParam.

Author

Commented:
Thanks for your reply !
Actually, I have found the cause of my problem (who was the sender).
My log was like that :

Log : Message sent
Log : Message sent
Log : ... // Lot of this again
Log : Message received
Log : Message received
And so on and so on.
At first I didn't look at the first part of the log and since I was logging every access to my "message reception" function, it didn't make sense. But I found out that my function was called so many times because just before I sent the message a lot of time and the message queue didn't have time to process them. So then, when the sender had finished its stuff, windows processed all the previous message one after another and made me think that there were some "ghost sender" behind that :)
Too bad though that it is not possible to let the receiver knows who was the sender, even if they want to communicate directly. I wonder if another IPC can achieve that. That might be my next question on Expert-exchange :)
Anyway, thanks !

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial