Since the Prop sheet does fine at sizing itself to the
sizes of the pages it contains, I have decided to let it
do that, size the CDialog dynamically around
that, and then position/size the other controls
dynamically as well.
( Pls tell me if you think that isn't smart. )
The CDialog is Modal.
After creating it (& adding pages), I get the size of the
PropertySheet by calling pSheet->GetClientRect().
Then I get the size of the CDialog by calling
GetClientRect.
I modify the height of the dialog by calling SetWindowPos.
If I next call GetClientRect on the CDialog, the CDialog
has size has changed, but not to the dimensions I
assigned.
Here is the code:
BOOL CStaCfgDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if (!m_pSheet)
{
m_pSheet = new CDevCfgSheet("testsheet", m_pDoc,
this);
}
if (!m_pSheet->Create(this, WS_CHILD | WS_VISIBLE))
{
return FALSE;
}
RECT cr, bcr, scr;
GetClientRect( &cr );
m_BtnApply.GetClientRect( &bcr );
m_pSheet->GetClientRect( &scr );
//here cr.right = 573 cr.bottom = 348
// size the dlg vertically
cr.bottom = scr.bottom + SCD_MID_MARGIN + bcr.bottom +
SCD_BOTTOM_MARGIN;
// now cr.bottom = 350 I know, I know, big diff!
SetWindowPos( NULL, 0, 0, cr.right, cr.bottom,
SWP_NOMOVE|SWP_NOZORDER );
GetClientRect( &cr );
// now cr.right = 565, cr.bottom = 316 !!!
// how did this happen??
return TRUE;
}
I have also tried using the MoveWindow() method, with the
same result:
CRect myCRect;
GetClientRect(&myCRect);
myCRect.bottom = scr.bottom + SCD_MID_MARGIN +
bcr.bottom + SCD_BOTTOM_MARGIN;
ClientToScreen(myCRect);
MoveWindow(myCRect.left, myCRect.top, myCRect.Width(),
myCRect.Height());
What in the world am I doing wrong?
Thanks.
Suz.
GetClientRect doesn't include the borders and caption bar space of the
dialog. Try reworking your code to use GetWindowRect instead.
Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
>.
>