Link to home
Start Free TrialLog in
Avatar of nicholso
nicholso

asked on

resizing an MDI parent window

I need to resize the parent window in an MDI app, after
the program has started, so I can't override
PreCreateWindow. I'm displaying an image in the child
window, so I need to wait until I have loaded it to
resize the parent to be exactly the size of the image; is
there a command to resize the main frame?
ASKER CERTIFIED SOLUTION
Avatar of tser
tser

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mueller
mueller

First obtain a pointer to the child's parent window before attempting to manipulate its size.  Then resize that window as necessary.  If you need to calculate the dimensions of the child window and set the dimensions of the parent window to that, use GetWindowRect() for the child window and set accordingly for the parent.  Here is an example:

// obtain a pointer to the child's parent window
CWnd *pWndParent = GetParent();

// now get size of the current child window (including borders)
CRect rcChildRect;
GetWindowRect( &rcChildRect );

// next set the size of the parent window to that of the child
// NOTE:  the TRUE parameter forces a redraw on the parent
// window
pWndParent->MoveWindow( &rcChildRect, TRUE );

// finally update the parent window
pWndParent->UpdateWindow();