SendMessage with WM_SETFOCUS and SetFocus() function
-
Hello, Case-1
SendMessage((*m_pIPedt).GetHWnd(), WM_SETFOCUS, NULL, NULL);
Result-1 Edit control is getting focus. But it is not accepting any text. Hanging sometimes. Case-2
SetFocus((*m_pIPedt).GetHWnd());
Result-2 Edit box is getting focus and I am able to type text in edit control I want to know difference between these 2 cases. Please help me. Regards msr
-
Hello, Case-1
SendMessage((*m_pIPedt).GetHWnd(), WM_SETFOCUS, NULL, NULL);
Result-1 Edit control is getting focus. But it is not accepting any text. Hanging sometimes. Case-2
SetFocus((*m_pIPedt).GetHWnd());
Result-2 Edit box is getting focus and I am able to type text in edit control I want to know difference between these 2 cases. Please help me. Regards msr
The
WM_SETFOCUS
message is sent to a window by the Windows system, as the result of a call toSetFocus()
or the user setting the focus to the window by mouse or keyboard. Thus option 2 is the correct way to do it.Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
Hello, Case-1
SendMessage((*m_pIPedt).GetHWnd(), WM_SETFOCUS, NULL, NULL);
Result-1 Edit control is getting focus. But it is not accepting any text. Hanging sometimes. Case-2
SetFocus((*m_pIPedt).GetHWnd());
Result-2 Edit box is getting focus and I am able to type text in edit control I want to know difference between these 2 cases. Please help me. Regards msr
Just look at the description of SetFocus(): http://msdn.microsoft.com/en-us/library/windows/desktop/ms646312%28v=vs.85%29.aspx[^] By reading that, you'll see that SetFocus() does a number of calls to make sure the focus is set correctly (kills the previous focus, activates the parent window of the control).