CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Aug 2005
    Posts
    104

    How to set default size of MDI child frame?

    I would like to make my MDI child frames come up at a larger size. Is there an easy way to do this? How does MFC determine the default size?

    Actually, even better might be to have them come up already maximized.

    thanks!

  2. #2
    Join Date
    Jun 2005
    Location
    Chennai , India
    Posts
    1,375

    Thumbs up Re: How to set default size of MDI child frame?

    Check this one:
    CWnd::SetWindowPos
    useful one..

    if helped dont forget to "Rate this post"
    It takes seconds for rating…that actually compensates the minutes taken for giving answers
    The biggest guru-mantra is: Never share your secrets with anybody. It will destroy you.
    Regards, Be generous->Rate people
    Jayender!!

  3. #3
    Join Date
    Jun 2005
    Location
    Chennai , India
    Posts
    1,375

    Thumbs up Re: How to set default size of MDI child frame?

    This should work :
    Code:
    void CChildFrame::ActivateFrame(int nCmdShow) 
    {
     // Update window size 
    nCmdShow = SW_SHOWMAXIMISED;
     CMDIChildWnd::ActivateFrame(nCmdShow);
    }
    this should work !!


    if helped dont forget to "Rate this post"
    It takes seconds for rating…that actually compensates the minutes taken for giving answers
    The biggest guru-mantra is: Never share your secrets with anybody. It will destroy you.
    Regards, Be generous->Rate people
    Jayender!!

  4. #4
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: How to set default size of MDI child frame?

    Quote Originally Posted by jayender.vs
    This should work :

    this should work !!
    Well... Almost. Your code will prevent the MDI children from ever getting minimized or restored. Your ActivateFrame implementation should actually look like this:
    Code:
    void CChildFrame::ActivateFrame(int nCmdShow)
    {
      if (nCmdShow == -1)
      {
        nCmdShow = SW_SHOWMAXIMIZED;
      }
      CMDIChildWnd::ActivateFrame(nCmdShow);
    }

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: How to set default size of MDI child frame?

    I believe PreCreateWindow() would be the correct place to do it. You'll be handed a CREATESTRUCT. Set its members appropriately. ActivateFrame will be called any time that window is activated or deactivated, and I don't think you want to resize it every time.

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: How to set default size of MDI child frame?

    Quote Originally Posted by jayender.vs
    This should work :
    Code:
    void CChildFrame::ActivateFrame(int nCmdShow) 
    {
     // Update window size 
    nCmdShow = SW_SHOWMAXIMISED;
     CMDIChildWnd::ActivateFrame(nCmdShow);
    }
    this should work !!


    if helped dont forget to "Rate this post"
    Actually it won't. What happens if the user changes the size, switches to another view, then comes back to this one?

  7. #7
    Join Date
    Jun 2005
    Location
    Chennai , India
    Posts
    1,375

    Thumbs up Re: How to set default size of MDI child frame?

    Quote Originally Posted by GCDEF
    Actually it won't. ?
    Actually ,it will !!
    What happens if the user changes the size, switches to another view, then comes back to this one?
    its working perfectly dude....
    dont get
    It takes seconds for rating…that actually compensates the minutes taken for giving answers
    The biggest guru-mantra is: Never share your secrets with anybody. It will destroy you.
    Regards, Be generous->Rate people
    Jayender!!

  8. #8
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: How to set default size of MDI child frame?

    Quote Originally Posted by jayender.vs
    Actually ,it will !!

    its working perfectly dude....
    dont get
    It's an MDI app. Open two windows. Resize 1. Switch to the second, switch back to the first. Doesn't the activate code get triggered again and resize the window when you switch back to it?

    Regardless, PreCreateWindow is the normal place to do your initial sizing. It's provided for just that purpose.

  9. #9
    Join Date
    Aug 2005
    Posts
    104

    Re: How to set default size of MDI child frame?

    Thanks guys... I'll try out these methods and see which one works out (and rate accordingly :-) )

  10. #10
    Join Date
    Aug 2005
    Posts
    104

    Re: How to set default size of MDI child frame?

    Well, both things work.

    ActivateFrame appears to be called only once, even if I switch between mdi children, maximize, restore, etc...

    But I've decided to take the PreCreateWindow route...

  11. #11
    Join Date
    Aug 2005
    Posts
    104

    Re: How to set default size of MDI child frame?

    Actually, PreCreateWindow doesn't work so well, because if I increase the size, MFC starts putting these things off the MDI area, and the user has to move them completely back on (e.g. the bottom is clipped).

    It looks like MFC uses some percentage of the actually app size to determine the size of child windows. So maybe I'll just adjust my default app size.

  12. #12
    Join Date
    Jun 2005
    Location
    Chennai , India
    Posts
    1,375

    Thumbs up Re: How to set default size of MDI child frame?

    Good .. to know it works well..

    well .. the best place is PreCreateWindow , but it does make much difference as i said before .
    It takes seconds for rating…that actually compensates the minutes taken for giving answers
    The biggest guru-mantra is: Never share your secrets with anybody. It will destroy you.
    Regards, Be generous->Rate people
    Jayender!!

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