Is anyone out there an expert in Windows focus handling?
I have problems with our application and the focus handling in places.
Basically it seems to me that there is some sort of logic in windows whereby the code calls PostMessage (WM_SETFOCUS) but the result is that the parent of the target window receives WM_COMMAND EN_SETFOCUS instead.
Does anyone know anything about such translations?
Is anyone out there an expert in Windows focus handling?
I have problems with our application and the focus handling in places.
Basically it seems to me that there is some sort of logic in windows whereby the code calls PostMessage (WM_SETFOCUS) but the result is that the parent of the target window receives WM_COMMAND EN_SETFOCUS instead.
Does anyone know anything about such translations?
From MSDN:
The EN_SETFOCUS notification message is sent when an edit control receives the keyboard focus. The parent window of the edit control receives this notification message through a WM_COMMAND message.
LRESULT CALLBACK WindowProc( HWND hwnd, // handle to window UINT uMsg, // WM_COMMAND WPARAM wParam, // edit control identifier, EN_SETFOCUS LPARAM lParam // handle to edit control (HWND) ); Parameters wParam The low-order word specifies the edit control identifier. The high-order word specifies the notification message.
lParam Handle to the edit control. Remarks The parent window will always get a WM_COMMAND message for this event, it does not require a notification mask sent with WM_SETEVENTMASK.
Rich Edit: For information about the compatibility of rich edit versions with the various system versions, see About Rich Edit Controls.
On October 1, 2003 12:51 am, Gerhard Gruber wrote:
Is anyone out there an expert in Windows focus handling?
I have problems with our application and the focus handling in places.
Basically it seems to me that there is some sort of logic in windows whereby the code calls PostMessage (WM_SETFOCUS) but the result is that the parent of the target window receives WM_COMMAND EN_SETFOCUS instead.
Does anyone know anything about such translations?
From MSDN:
The EN_SETFOCUS notification message is sent when an edit control receives the keyboard focus. The parent window of the edit control receives this notification message through a WM_COMMAND message.
LRESULT CALLBACK WindowProc( HWND hwnd, // handle to window UINT uMsg, // WM_COMMAND WPARAM wParam, // edit control identifier, EN_SETFOCUS LPARAM lParam // handle to edit control (HWND) ); Parameters wParam The low-order word specifies the edit control identifier. The high-order word specifies the notification message.
lParam Handle to the edit control. Remarks The parent window will always get a WM_COMMAND message for this event, it does not require a notification mask sent with WM_SETEVENTMASK.
Rich Edit: For information about the compatibility of rich edit versions with the various system versions, see About Rich Edit Controls.
Thanks for taking the time to reply.
Yes, I know about that.
Also see the SetFocus documentation that says it sends WM_SETFOCUS.
So maybe they mean that it sends a WM_SETFOCUS unless its an edit control in which case it sends EN_SETFOCUS.
So what exactly is an edit control. i.e. what is the queriable property that allows us to decide which to send.
There is a suggestion that actually this translation is done down in the DefWindowProc somewhere. (See http://groups.google.ca/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&s... )
I see that currently we don't do anything with WM_SETFOCUS in DefWindowProc.
Bill Medland billmedland@mercuryspeed.com writes:
Also see the SetFocus documentation that says it sends WM_SETFOCUS.
So maybe they mean that it sends a WM_SETFOCUS unless its an edit control in which case it sends EN_SETFOCUS.
No, it sends a WM_SETFOCUS to the edit control, which in turns sends an EN_SETFOCUS to its parent. Why doesn't this do the right thing for you?
On October 1, 2003 10:25 am, Alexandre Julliard wrote:
Bill Medland billmedland@mercuryspeed.com writes:
Also see the SetFocus documentation that says it sends WM_SETFOCUS.
So maybe they mean that it sends a WM_SETFOCUS unless its an edit control in which case it sends EN_SETFOCUS.
No, it sends a WM_SETFOCUS to the edit control, which in turns sends an EN_SETFOCUS to its parent. Why doesn't this do the right thing for you?
Are you saying that you believe that the edit control itself sends the EN_SETFOCUS?
Our software includes some tracing and what I see in it suggests that under Windows there are EN_SETFOCUS messages whereas under Wine they are WM_SETFOCUS, and I am trying to understand why.
Bill Medland billmedland@mercuryspeed.com writes:
Are you saying that you believe that the edit control itself sends the EN_SETFOCUS?
Yes, the edit control sends it when it gets a WM_SETFOCUS. That's how all the notification messages work.
Our software includes some tracing and what I see in it suggests that under Windows there are EN_SETFOCUS messages whereas under Wine they are WM_SETFOCUS, and I am trying to understand why.
Probably the focus is set to the parent window directly instead of being set to the edit control.