Menu

How to dock a CDialog?

Help
2010-11-06
2013-05-28
  • Euven Vries

    Euven Vries - 2010-11-06

    Hi all,

    I docked a CDialog, currently with a groupbox and a checkbox.
    I took the class FormDemo\FormView.cpp from the examples and removed all but the groupbox and a checkbox.
    The groupbox does not repaint correctly, when sizing or if the app comes back to front from behind another window.
    What went wrong?

    Thanks
    euvi

    snip…
    CDockParam::CDockParam()
    {
    m_pView = new CParamView(IDD_DIALOG1);
    SetView(*m_pView);
    //SetView(m_View);
    }

    CDockParam::~CDockParam()
    {
    delete m_pView;
    }

     
  • David

    David - 2010-11-07

    Hi euvi,

    I haven't had a chance to look at this in detail as yet, but here's something you could try:
    1) Give the group box a unique resource ID.
    2) Handle the dialog's OnPaint and get the window handle of the group box (using GetDlgItem).
    3) Use InvalidateRect or perhaps RedrawWindow to force a redraw of the groupbox.

    Best regards,
    David

     
  • Euven Vries

    Euven Vries - 2010-11-07

    Hi David,

    The groupbox does paint only its frame and the title caption.
    However, the checkbox inside the groupbox paints well.

    I followed  your proposal, but:
    The overwritten dialog's OnPaint does not get called!?

    -snip-
    class CParamView : public CDialog
    {

    protected:

    virtual void OnPaint(HDC hDC);

    private:

    CResizer m_Resizer;
    class CGroup : public CWnd {};
    class CCheckA : public CButton {};

    CGroup m_Group;
    CCheckA m_CheckA;

    };

    -snip-
    void CParamView::OnPaint(HDC hDC)  // <= does not get called
    {
    m_Group.Invalidate(1);
    m_Group.RedrawWindow();
    }
    BOOL CParamView::OnInitDialog()
    {

        // Attach CWnd objects to the dialog's children
        m_CheckA.AttachDlgItem( IDC_CHECKBOX_1, this );
        m_Group.AttachDlgItem( IDC_GROUPBOX_1, this );

        // Initialize dialog resizing
       m_Resizer.Initialize( this, CRect(0, 0, 125, 283) );
       m_Resizer.AddChild(&m_CheckA,   leftright, FALSE, TRUE);  // "leftright" from my previous topic
       m_Resizer.AddChild(&m_Group,    leftright, FALSE, TRUE);

    }
    void CParamView::OnCheckA()
    {
         TRACE(_T("Check Box A\n"));  // This works

    }

    Thanks again, David
    (I am somehow sorry to ask such questions, but for my "excuse" I can tell that I use most of the time C++Builder (since CB1 to CB XE) for GUI related stuff (VCL, which makes it very easy to do complex GUI) and switch to VS etc. only for things like SIMD and other stuff or libraries the Borland compiler cannot do. So the only thing to give back to your great plain Win32 GUI lib is to ask "stupid" questions as a BCB expert in the hope to point out some useful hints.)

    Best regards
    euvi

     
  • David

    David - 2010-11-08

    Hi euvi,

    Yes, sorry about leading you down the wrong path. I assumed that DialogProc handled messages the same way that WndProc does, but unfortunately that's not the case. DialogProc only allows us to handle a subset of the dialog's window messages, and WM_PAINT is not one of these.

    I got around to adding the full dialog from the FormDemo to a docking container, and added a push button and radio button added to the group box. This all worked perfectly for me. I expect the problem you're experiencing comes down to the way the dialog is defined in your resource file.

    If a dialog has the WS_CLIPCHILDREN style set, it will generally cause the problem you describe. If you must have the WS_CLIPCHILDREN style for your dialog (setting it might reduce flicker for some controls), you will need to set the WS_EX_TRANSPARENT extended style set for the group box to get the dialog to display it properly.

    You can check the styles and extended styles of the dialog and its controls by opening the Resource.rc file with a text editor.

    I expect this will solve your problem. If not, you might need to send me your project (via a direct e-mail if you like) for me to have a look at.

    Best regards,
    David

     
  • Euven Vries

    Euven Vries - 2010-11-08

    Hi David,

    THANKS!

    Best regards
    euvi

     

Log in to post a comment.

MongoDB Logo MongoDB