This is a tip aswell as it is a question; we're talking about WinAPI programming. I hope someone will have the patience to read this and help me out.
Did you know that windows, when a dialog box is on, and when recieving an <Enter>, sends a WM_COMMAND message to the handler of the dialog box, having as window id (the window who should process the message) the OK button???
I know this could be sounding strange but you may check this by creating a dialog with some resouce editor.
You will be surprised to find out that the <OK> button id value cannot be changed . This is because it is used internally by windows for the reason i mentioned before. Then try assigning the button another identificator, with your specific ID (another value than 1).
In the dialog box procedure, trace the WM_COMMAND message params and you'll find out that [red] (when pressing <ENTER> ) the command should be processed by a window whose id is 1 !!!! ... meaning the OK button....[/red]
So far, soo good. But what if in you dialog box you may want to edit some data (suppose it is a table - imagine an excel style table in a dialog box), and usually, the <enter> button should close the editting of the cell you're in.
So, if you have a button with ID 1 and press enter to close the edit mode of that cell, your dialog will wanna go to sleep...
The standard way to avoid this is by installing a message hook. Once you have installed it, you may still intercept the WM_KEYDOWN message from your dialog and if this is <enter>, do whatever you think is appropriate.
My question is:
[red] How do i remove some message from the queue. [/red]
I want to do this because, after exitting my message hook function, the WM_KEYDOWN message is evelly morphed into a horrible WM_COMMAND message by Windows...
I searched for some Unix-like queue management functions that allow you to fully manage your message queue. But... nottathing...
Maybe i wasn't lucky enough to find the functions.
I temporarely solved the problem by setting the message queue extra information (with a call to SetMessageExtraInfo) and check that extra info when the destructing WM_Command comes in. But this is not good enough, nor preety...
So, if someone can help me, PLEASE DO!!!!
Thanks in advance,
Nosferatu.
Did you know that windows, when a dialog box is on, and when recieving an <Enter>, sends a WM_COMMAND message to the handler of the dialog box, having as window id (the window who should process the message) the OK button???
I know this could be sounding strange but you may check this by creating a dialog with some resouce editor.
You will be surprised to find out that the <OK> button id value cannot be changed . This is because it is used internally by windows for the reason i mentioned before. Then try assigning the button another identificator, with your specific ID (another value than 1).
In the dialog box procedure, trace the WM_COMMAND message params and you'll find out that [red] (when pressing <ENTER> ) the command should be processed by a window whose id is 1 !!!! ... meaning the OK button....[/red]
So far, soo good. But what if in you dialog box you may want to edit some data (suppose it is a table - imagine an excel style table in a dialog box), and usually, the <enter> button should close the editting of the cell you're in.
So, if you have a button with ID 1 and press enter to close the edit mode of that cell, your dialog will wanna go to sleep...
The standard way to avoid this is by installing a message hook. Once you have installed it, you may still intercept the WM_KEYDOWN message from your dialog and if this is <enter>, do whatever you think is appropriate.
My question is:
[red] How do i remove some message from the queue. [/red]
I want to do this because, after exitting my message hook function, the WM_KEYDOWN message is evelly morphed into a horrible WM_COMMAND message by Windows...
I searched for some Unix-like queue management functions that allow you to fully manage your message queue. But... nottathing...
Maybe i wasn't lucky enough to find the functions.
I temporarely solved the problem by setting the message queue extra information (with a call to SetMessageExtraInfo) and check that extra info when the destructing WM_Command comes in. But this is not good enough, nor preety...
So, if someone can help me, PLEASE DO!!!!
Thanks in advance,
Nosferatu.