Click to See Complete Forum and Search --> : CFormView -- Dialog resize?


jonjonjon
October 7th, 1999, 03:38 PM
I created an MFC application which is derived from CFormView -- so there is a main dialog insize of a frame.

My Question: How do I resize the dialog in response to the MainFrame being sized? I know I have to override the ON_SIZE handler from the MainFrame class.. BUT -- how do I get a handle to the dialog inside of that frame so that I can MoveWindow on it?

Sam Hobbs
October 7th, 1999, 06:18 PM
Instead of overriding OnSize in your MainFrame, override it in your view.

If it were me, I would use CView instead of CFormView if I want to dynamically resize the form. The problem with CFormView is that you probably need to write logic to determine where the controls are at, then write logic to dynamically resize. With CView, you can write logic to initially size everything and the same logic can be used to resize it. The disadvantage of CView is that you must write the logic to initially create the controls. The details of what you do and how you do it depends very much on what you want to do and how you want to do it.

In my program that dynamically resizes the form, my override of CView::OnSize includes the following:

RECT ClientRect;
CView::OnSize(nType, cx, cy);
if (nType != SIZE_RESTORED && nType != SIZE_MAXIMIZED)
return;
GetClientRect(&ClientRect);