CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 1999
    Posts
    13

    How do I calculate the screen size of a dialog resource

    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



  2. #2
    Join Date
    Apr 1999
    Location
    Rajasthan ,India
    Posts
    25

    Re: How do I calculate the screen size of a dialog resource

    You can use GetWindowRect() to get the size of dialog after creating dialog.


  3. #3
    Join Date
    Sep 1999
    Posts
    13

    Re: How do I calculate the screen size of a dialog resource

    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


  4. #4
    Join Date
    May 1999
    Posts
    19

    Re: How do I calculate the screen size of a dialog resource

    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


  5. #5
    Guest

    Re: How do I calculate the screen size of a dialog resource

    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


  6. #6
    Join Date
    Nov 2003
    Location
    Germany
    Posts
    1

    Re: How do I calculate the screen size of a dialog resource

    try this (it worked for me)

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured