SendMessage, PostMessage problems with MessageBox

C

Cole Shelton

Hi all,

I am using SendMessage to manipulate the window of another process. The
problem is that when I use SendMessage to click a certain button a
MessageBox is displayed and my program will not continue until the user
clicks the OK button, which is not what I want.

Therefore, I switched to using PostMessage to click the button, which allows
my program to continue, except I need to know when it has pressed the button
so I can close the MessageBox. If my program runs directly through, it does
not find the MessageBox because the button has not been pushed yet. So if I
use PostMessage to click the button, how do I determine when this message
has completed so I can close the MessageBox and resume my other tasks?

Thanks for any help!
Cole
 
1

100

Hi Cole,
There is no way to determine when a posted message has been processed.
I think it won't be of any help to you, but just a reminder that there exist
an API called SendMessageCallback
It sends a message but returns immediately and your programm won't get
blocked until the message is in process When the message is precessed your
callback will be called with the result of the message processing. But in
your case I'm afraid that the callback won't be called until the message
box is on the screen.

The other solution is to install a windows hook which will listen for
opening a message box and will notify you or even close the message box for
you.
There are articles in MSDN 2002 issues about how to install windows hooks
(with source code) and what might be useful for you example how to intercept
creation of message boxes.
You can find that article here
http://msdn.microsoft.com/msdnmag/issues/02/11/CuttingEdge/default.aspx

HTH
B\rgds
100
 
C

Cole Shelton

100,

Thanks for the info. I haven't managed to get the hook working yet (events
don't seem to be firing), but I think this is the right direction.

Cole
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top