CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2002
    Location
    Chicago, IL
    Posts
    255

    Stretch a docked CDialogBar.

    I'm feeling pretty dumb right now, but I can't seem to get my docked CDialogBar to stretch the length of a window. I want my dialog bar to be docked to the top (the user can't change this). In the dialog bar, I want certain controls to be anchored to the right side of the dialog. So when the window stretches, I want the dialog bar to stretch as well. However my CDialogBar derivative isn't receiving the WM_SIZE message when the frame window is resized.

    In my frame's OnCreate method (it's a frame not using doc/view architecture), I have the following code:

    Code:
        m_bar.Create( this, IDD_DIALOG1, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_SIZE_FIXED, IDD_DIALOG1 );
        m_bar.EnableDocking( CBRS_ALIGN_TOP );
        EnableDocking( CBRS_ALIGN_TOP );
        DockControlBar( &m_bar );
    Then in my frame's OnSize message handler, I call:

    Code:
        RepositionBars( IDD_DIALOG1, IDD_DIALOG1, 0 );
    I have a CDialogBar derivative that just handles the WM_SIZE message to move child controls, but it's never hit.

    What am I doing wrong?

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Stretch a docked CDialogBar.

    Well then, send WM_SIZE to dialog bar from the frame's WM_SIZE hander.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #3
    Join Date
    Mar 2002
    Location
    Chicago, IL
    Posts
    255

    Re: Stretch a docked CDialogBar.

    That's what I'm doing now, but that seems like a hack to me.

  4. #4
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Stretch a docked CDialogBar.

    Quote Originally Posted by sjc View Post
    That's what I'm doing now, but that seems like a hack to me.
    Every attempt to change of default behavior is a "hack".

    To avoid sending WM_SIZE which indeed is not elegant, override CDialogBar::CalcFixedLayout and force bStretch to TRUE.
    Code:
    CSize CMyDialogBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
    {
       if(!IsFloating())
       {
          bStretch = TRUE;
       }
       return CDialogBar::CalcFixedLayout(bStretch, bHorz);
    }
    Last edited by ovidiucucu; March 16th, 2011 at 08:38 AM.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured