Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handle windows messages one at a time?

Status
Not open for further replies.

donvittorio

Programmer
Jul 17, 2003
122
GB
Hello all,

I'm looking into a problem with message handling within an application. When the app is started a thread is created, and within this thread is a message handler which is assigned to Application.OnMessage. The message handler will only handle custom messages (between WM_USER+6 and WM_USER+11), for all other messages Handled remains False so that they are handled normally.
The handling for one of these messages (MM_SENDKEYS) uses the keybd_event method to simulate key presses, and a loop then uses PeekMessage to check that each of the expected WM_KEYDOWN / WM_SYSKEYDOWN messages are on the queue (without removing them from the queue).
The problem I have is that the KeyDown messages are being processed and removed from the queue before the loop has finished looking for them, so the loop ends up looking for messages that are no longer there!
Is there any way to ensure that the handling of the MM_SENDKEYS messsage is completed before any other messages are processed?
If anybody has any ideas how to solve this them I'm all ears!

Thanks in advance

Steve
 
It seems I misunderstood what was happening. It looks as though the key combinations ALT+TAB or ALT+ESC will only produce a single WM_SYSKEYDOWN message on the message queue. I was expecting a WM_SYSKEYDOWN for the ALT key and a WM_KEYDOWN message for the ESC key, but the WM_KEYDOWN message never occurs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top