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?
Re: Stretch a docked CDialogBar.
Well then, send WM_SIZE to dialog bar from the frame's WM_SIZE hander.
Re: Stretch a docked CDialogBar.
That's what I'm doing now, but that seems like a hack to me.
Re: Stretch a docked CDialogBar.
Quote:
Originally Posted by
sjc
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);
}