visual-c++mfcmdimdichildwindow-style

MFC: Context Help (? Button) to Title Bar of MDIframe


In MFC how can we add (?)context help button in title bar of childframe. I tried to add window style on precreatewindow but it does not display help button in title bar. I know how to add contexthelp on dialogs and propertysheet but I am unable to add for child frame window

BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    cs.style &= ~WS_MAXIMIZEBOX;
    cs.style &= ~WS_MINIMIZEBOX;
    cs.style |= WS_SYSMENU;
    cs.style |= WS_EX_CONTEXTHELP;
    if( !CMDIChildWnd::PreCreateWindow(cs) )
        return FALSE;

    return TRUE;
}

Solution

  • WS_EX_CONTEXTHELP is an extended style, so you should be adding it to cs.dwExStyle instead of cs.style. Also, I believe you get the WS_SYSMENU by default, so something like the following should fix you up:

    BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
        cs.style &= ~WS_MAXIMIZEBOX;
        cs.style &= ~WS_MINIMIZEBOX;
        cs.dwExStyle |= WS_EX_CONTEXTHELP;
    
        if( !CMDIChildWndEx::PreCreateWindow(cs) )
            return FALSE;
    
        return TRUE;
    }
    

    Sincerely,