Click to See Complete Forum and Search --> : How resize CChildFrm initialy


Alex
September 7th, 1999, 01:39 PM
Hi everyone,
I'm trying to resize my CChildWnd in PrecreateWindow function, let say I wona it take half of Main Frame client area, I've used code below:



BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
CMainFrame* pMain=(CMainFrame*)AfxGetMainWnd();
CRect rect;
pMain->GetClientRect(&rect);
cs.cx=rect.Width()/2;
cs.cy=rect.Height();
cs.x=0; cs.y=0;
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
return TRUE;
}




But I have two problem
1. It works only for weight of window, I got height bigger than client area of Main Frame. (Is tool bar including in client area? if yes how to calculate it's height, I've tried RecalculateLayout(), it doesn't help)

2. If changed in InitInstance pMainFrame->ShowWindow(m_nCmdShow);
to pMainFrame->ShowWindow(SW_SHOWMAXIMIZED); function GetClientRect() still return old coordinate of not maximized frame.

What's wrong and how I may fix it?
Any suggestin realy appreciate.