We used the TabPages sample for testing where we added the following two message handlers to the CChildView
class:
void CChildView::OnSetFocus(CWnd* pOldWnd)
{
CWnd::OnSetFocus( pOldWnd );
TRACE1( "CChildView::OnSetFocus() for %p\r\n", this );
}
void CChildView::OnKillFocus(CWnd* pNewWnd)
{
CWnd::OnKillFocus( pNewWnd );
TRACE1( "CChildView::OnKillFocus() for %p\r\n", this );
}
The handling of both messages was correct. Please notice the MDI child frame window receives the focus first. This happens when MDI child frame window becomes activated. It handles focus gaining and sets focus to its child view window. The view window can be any type of window but it must have the
AFX_IDW_PANE_FIRST
dialog control identifier which allows the MDI child frame window to determine which of its child windows is the view window. The view window in your project can be un-focused only in the following cases:
1) Focus changing is handled in your MDI child frame window in some special way and, as result, focus is not forwarded to view.
2) Focus changing is handled in the view’s
WindowProc()
method without invocation of the parent class method.
3) Focus changing is filtered in some
PreTranslateMessage()
method.
4) Focus changing is filtered in some thread hook procedure.
We are sure all the cases are not related to Prof-UIS source code.