Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to maximize child windows

How to maximize child windows

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
8 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ancient Dragon
    wrote on last edited by
    #1

    I have an MFC MDI program using VC6. When the application starts I want the initial child window to be maximized within the frame. I've tried ModifyStyle(0,WS_MAXIMIZE); in the OnActivateView() and added cs.style |= WS_MAXIMIZE; to the beginning of PreCreateWindow(); Any other ideas?

    R J 2 Replies Last reply
    0
    • A Ancient Dragon

      I have an MFC MDI program using VC6. When the application starts I want the initial child window to be maximized within the frame. I've tried ModifyStyle(0,WS_MAXIMIZE); in the OnActivateView() and added cs.style |= WS_MAXIMIZE; to the beginning of PreCreateWindow(); Any other ideas?

      R Offline
      R Offline
      RickGavin
      wrote on last edited by
      #2

      I don't know if this is the correct way, but in the ActivateFrame Method I set the SW_SHOMAXIMIZED flag, this does the job just for the intial activation of the window. void CChildFrame::ActivateFrame(int nCmdShow) { // TODO: Modify this function to change how the frame is activated. nCmdShow = SW_SHOWMAXIMIZED; CMDIChildWnd::ActivateFrame(nCmdShow); } If you have more than one window in your MDI, i have noticed it will unmaximize when you switch to a new window.. I tried to get around this by using a ModifyStyle(NULL,WS_MAXIMIZE) void CChildFrame::OnSetFocus(CWnd* pOldWnd) { CMDIChildWnd::OnSetFocus(pOldWnd); // TODO: Add your message handler code here ModifyStyle(NULL,WS_MAXIMIZE); } As I said, I don't know if this is the correct way to do it.. Its just what I figured out while I was playing.. Please let me know if you find a better way. -Rick

      A N 2 Replies Last reply
      0
      • R RickGavin

        I don't know if this is the correct way, but in the ActivateFrame Method I set the SW_SHOMAXIMIZED flag, this does the job just for the intial activation of the window. void CChildFrame::ActivateFrame(int nCmdShow) { // TODO: Modify this function to change how the frame is activated. nCmdShow = SW_SHOWMAXIMIZED; CMDIChildWnd::ActivateFrame(nCmdShow); } If you have more than one window in your MDI, i have noticed it will unmaximize when you switch to a new window.. I tried to get around this by using a ModifyStyle(NULL,WS_MAXIMIZE) void CChildFrame::OnSetFocus(CWnd* pOldWnd) { CMDIChildWnd::OnSetFocus(pOldWnd); // TODO: Add your message handler code here ModifyStyle(NULL,WS_MAXIMIZE); } As I said, I don't know if this is the correct way to do it.. Its just what I figured out while I was playing.. Please let me know if you find a better way. -Rick

        A Offline
        A Offline
        Ancient Dragon
        wrote on last edited by
        #3

        Thank you for your help. ActivateFrame() alone works in my program without the problem you described. My view is derived from CHtmlView, which is derived from CFormView. I created two instances of the same view during runtime (that is, I selected File | New), switched between them (Window | ) and both windows stayed maximized.

        1 Reply Last reply
        0
        • R RickGavin

          I don't know if this is the correct way, but in the ActivateFrame Method I set the SW_SHOMAXIMIZED flag, this does the job just for the intial activation of the window. void CChildFrame::ActivateFrame(int nCmdShow) { // TODO: Modify this function to change how the frame is activated. nCmdShow = SW_SHOWMAXIMIZED; CMDIChildWnd::ActivateFrame(nCmdShow); } If you have more than one window in your MDI, i have noticed it will unmaximize when you switch to a new window.. I tried to get around this by using a ModifyStyle(NULL,WS_MAXIMIZE) void CChildFrame::OnSetFocus(CWnd* pOldWnd) { CMDIChildWnd::OnSetFocus(pOldWnd); // TODO: Add your message handler code here ModifyStyle(NULL,WS_MAXIMIZE); } As I said, I don't know if this is the correct way to do it.. Its just what I figured out while I was playing.. Please let me know if you find a better way. -Rick

          N Offline
          N Offline
          Neville Franks
          wrote on last edited by
          #4

          CChildFrame::ActivateFrame() is a recomended way to do this. I don't know if your code in CChildFrame::OnSetFocus() will do anything usefull however. With MDI only one window is ever maximized at a time. When you switch to another window, the current window is restored to its normal size and then the new window is maximized. This is all a pain in the backside as far as I'm concerned and I assume it has something to do with the early Win 3.x MDI implementation. One of the problems with this is that you can see the windows flash to restored and then maximized size as you change MDI windows and open and close windows. This flashing varies across different windows versions. In my CChildFrame::ActivateFrame() in ED for Windows (see sig) I wrap the call to CMDIChildWnd::ActivateFrame() in pMDIClient->SetRedraw( FALSE/TRUE ) calls. Neville Franks, Author of ED for Windows. www.getsoft.com

          K 1 Reply Last reply
          0
          • N Neville Franks

            CChildFrame::ActivateFrame() is a recomended way to do this. I don't know if your code in CChildFrame::OnSetFocus() will do anything usefull however. With MDI only one window is ever maximized at a time. When you switch to another window, the current window is restored to its normal size and then the new window is maximized. This is all a pain in the backside as far as I'm concerned and I assume it has something to do with the early Win 3.x MDI implementation. One of the problems with this is that you can see the windows flash to restored and then maximized size as you change MDI windows and open and close windows. This flashing varies across different windows versions. In my CChildFrame::ActivateFrame() in ED for Windows (see sig) I wrap the call to CMDIChildWnd::ActivateFrame() in pMDIClient->SetRedraw( FALSE/TRUE ) calls. Neville Franks, Author of ED for Windows. www.getsoft.com

            K Offline
            K Offline
            Kash
            wrote on last edited by
            #5

            Hi, I'm a newbie to MFC. I have an MDI with CFormView as my base class. I can't find the ActivateFrame() function. Someone suggested I try this in CMyFormView::OnInitialUpdate() CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(FALSE); but this still doesn't work. Any suggestions? Cheers

            N 1 Reply Last reply
            0
            • K Kash

              Hi, I'm a newbie to MFC. I have an MDI with CFormView as my base class. I can't find the ActivateFrame() function. Someone suggested I try this in CMyFormView::OnInitialUpdate() CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(FALSE); but this still doesn't work. Any suggestions? Cheers

              N Offline
              N Offline
              Neville Franks
              wrote on last edited by
              #6

              Kash wrote: ActivateFrame() is a member of CMDIChildWnd. The Help will tell you this. ;-) To access it you need to derive a class from CMDIChildWnd. This is usually named CChildFrame. Then you can use CChildFrame::ActivateFrame() If you want to get at the MDI Client Window inside this then use: CWnd* pMDIClient = GetParent(); Make sure you call CMDIChildWnd::ActivateFrame() from within your CChildFrame::ActivateFrame(). Neville Franks, Author of ED for Windows. www.getsoft.com

              1 Reply Last reply
              0
              • A Ancient Dragon

                I have an MFC MDI program using VC6. When the application starts I want the initial child window to be maximized within the frame. I've tried ModifyStyle(0,WS_MAXIMIZE); in the OnActivateView() and added cs.style |= WS_MAXIMIZE; to the beginning of PreCreateWindow(); Any other ideas?

                J Offline
                J Offline
                Joel Lucsy
                wrote on last edited by
                #7

                I've used it in PreCreateWindow in the ChildFrm and it works great. cs.style |= WS_MAXIMIZE. I placed it after the CMDIChildWnd::PreCreateWindow( cs ); Perhaps something else is confusing it. Joel Lucsy (jjlucsy@ameritech.net)

                M 1 Reply Last reply
                0
                • J Joel Lucsy

                  I've used it in PreCreateWindow in the ChildFrm and it works great. cs.style |= WS_MAXIMIZE. I placed it after the CMDIChildWnd::PreCreateWindow( cs ); Perhaps something else is confusing it. Joel Lucsy (jjlucsy@ameritech.net)

                  M Offline
                  M Offline
                  Mel Stober
                  wrote on last edited by
                  #8

                  I didn't put it in that class, and that's why it probably did not work. Thanks for your suggestion.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups