Click to See Complete Forum and Search --> : How do I calculate the screen size of a dialog resource


jhouse
September 14th, 1999, 12:33 AM
Hello:

I am using a CFormView with a dialog resource that I created.
Unfortunately, the CFormView does not automatically fit to the size of the
resource I designed. Instead I get scroll bars. If I knew how to
programmaticlly determine the screen (pixel) size of the resource, I could
simply get the resource size and then set the view size equal to that size.
I'm sure there are better ways to skin this cat, and I am open to any
suggestions.

Thanks in advance,

Jim Houskeeper

Sanjeev
September 14th, 1999, 12:51 AM
You can use GetWindowRect() to get the size of dialog after creating dialog.

jhouse
September 14th, 1999, 08:27 AM
No, that was too easy, I tried that. As I tried to explain in the original post, the dialog resource is larger than the default CFormView, so the CFormView is exposed with both horizonal and vertical scroll bars, the rect you get when you query for the window size is the rect of the view, not the dialog resouce it contains. I want the view window to be exposed at the same size of the dialog resource, and thus no sliders. Any other suggestions?

Jim

James Hughes
September 14th, 1999, 11:26 AM
Sanjeev is right, you need to use GetWindowRect, but on the dialog, not the view. Not sure how you can get a pointer to the CDialog in a view like that (dont use them), but have done the following recently.

One way...To get size of arbitrary dialog, do a create of it (make it invisible if necessary), then do a getwindowrect, then delete the dialog.

As far as I can tell this is the only way of doing it, I needed to compensate for large fonts and thats what I had to do.

Rgds

James

September 29th, 1999, 07:43 AM
In an SDI app, you can do the following to resize your CFormView:
void CYourFormView::OnInitialUpdate()
{
CFormViewMgr::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}

But somehow it did not work in an MDI app. I am still trying to figure it out.

-Patty

SandraS
February 21st, 2006, 09:16 AM
try this (it worked for me)

void CMyFormView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit(FALSE);
...
}