How can I kill a focus, of a control?
Thanks
Printable View
How can I kill a focus, of a control?
Thanks
One solution is send a WM_KILLFOCUS message to the control.
SendMessage(hControl, WM_KILLFOCUS, 0);
Kuphryn
Another would be to use SetFocus() to set the focus somewhere else.
What I have is: editbox that I sent text to, and a button. the thing is that when the dialog is called, the text in the editbox is marked, so I did try to set the focus on the button, but no luck.
The WM_KILLFOCUS doesn't work either
WM_KILLFOCUS is a notification message sent to a window immediately before it loses focus... it doesn't CAUSE it to lose focus. To make something lose focus, tell something else to gain focus via SetFocus(), so the OS knows what to give the focus to. It will then automatically make the control currently in focus lose it, and send it a notification (WM_KILLFOCUS), just in case you need to do something when it no longer has focus.