PRB: Can't Set Focus to an Edit Control When its Parent Is an Inactive Captioned Child WindowID: Q230587
|
When an edit control is in an inactive captioned child window, you cannot set focus to it with the mouse. For example, if you have a modeless dialog box with the WS_CAPTION and WS_CHILD styles, and it has an edit control, you cannot set focus to the edit control with the mouse.
NOTE: All captioned child windows display an inactive caption bar.
The default WM_LBUTTONDOWN handler for edit controls will not set focus to the edit control if its parent is an inactive captioned child window. This code is implemented as part of the Windows API function, DefWindowProc().
There are not many good ways to work around this limitation because it is Windows itself that is intentionally causing this behavior.
The best way to prevent the problem is to prevent the parent of the edit control from being an inactive captioned child. For the above example, specify the WS_POPUP style for the dialog box instead of WS_CHILD.
This behavior is by design.
delete this;
m_pDlg = new CModelessDlg;
m_pDlg->Create(IDD_MODELESS2, this);
m_pDlg->ShowWindow(SW_SHOWNORMAL);
Additional query words:
Keywords : kbActiveX kbCtrl kbCtrlCreate kbMFC kbVC400 kbVC410 kbVC420 kbVC500 kbVC600 kbDSupport kbGrpMFCATL
Version : winnt:4.0,4.1,4.2,5.0,6.0
Platform : winnt
Issue type : kbprb
Last Reviewed: August 5, 1999