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. maximizing window in MFC application

maximizing window in MFC application

Scheduled Pinned Locked Moved C / C++ / MFC
c++
6 Posts 4 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.
  • M Offline
    M Offline
    minkowski
    wrote on last edited by
    #1

    Hi, I have a MFC application and wish to change the way the application behaves when a user maximises the main window frame. I understand that I need to add a virtual function to the document class that inherits from the CDocument class. However, I am not sure what the name of the function is that is used when maximising the window. If you can tell me, that would be great. Thanks !

    S B 2 Replies Last reply
    0
    • M minkowski

      Hi, I have a MFC application and wish to change the way the application behaves when a user maximises the main window frame. I understand that I need to add a virtual function to the document class that inherits from the CDocument class. However, I am not sure what the name of the function is that is used when maximising the window. If you can tell me, that would be great. Thanks !

      S Offline
      S Offline
      Sam_c
      wrote on last edited by
      #2

      the OnSize function takes UINT which identifies the minimise or maximise request. that how ever is in MainFrm and View not Doc example of an action based on minimised action. void CMainFrame::OnSize(UINT nType, int cx, int cy) { if(nType == SIZE_MINIMIZED) { ShowWindow(SW_HIDE); } else { CFrameWnd::OnSize(nType, cx, cy); } } hope that helps. if im wrong about the document OnSize let me know please :)

      M 1 Reply Last reply
      0
      • S Sam_c

        the OnSize function takes UINT which identifies the minimise or maximise request. that how ever is in MainFrm and View not Doc example of an action based on minimised action. void CMainFrame::OnSize(UINT nType, int cx, int cy) { if(nType == SIZE_MINIMIZED) { ShowWindow(SW_HIDE); } else { CFrameWnd::OnSize(nType, cx, cy); } } hope that helps. if im wrong about the document OnSize let me know please :)

        M Offline
        M Offline
        minkowski
        wrote on last edited by
        #3

        Hi ya, Thanks for your post. I actually found this void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { // kiran. static const CPoint point0 = CPoint(0, 0); if(m_PageSize != point0) { const long my = lpMMI -> ptMaxSize.y; const long ty = lpMMI -> ptMaxTrackSize.y; lpMMI -> ptMaxSize = m_PageSize; lpMMI -> ptMaxTrackSize = m_PageSize; lpMMI -> ptMaxSize.y = my; lpMMI -> ptMaxTrackSize.y = ty; } CFrameWnd::OnGetMinMaxInfo(lpMMI); } in my code and put a break point on it when I clicked the maximise button. The code then stopped at the break point proving that this function is invoked when using max / min. I guess the structure should contain info whether the user is doing a max / min ? Thanks

        D 1 Reply Last reply
        0
        • M minkowski

          Hi, I have a MFC application and wish to change the way the application behaves when a user maximises the main window frame. I understand that I need to add a virtual function to the document class that inherits from the CDocument class. However, I am not sure what the name of the function is that is used when maximising the window. If you can tell me, that would be great. Thanks !

          B Offline
          B Offline
          baerten
          wrote on last edited by
          #4

          I NEVER TRIED, but you can test to handle the WM_ONSIZE Message There you get the UINT nType, which you can test on if(nType == SIZE_MEXIMIZED) I hope it's true what i say :laugh: Good luck

          M 1 Reply Last reply
          0
          • B baerten

            I NEVER TRIED, but you can test to handle the WM_ONSIZE Message There you get the UINT nType, which you can test on if(nType == SIZE_MEXIMIZED) I hope it's true what i say :laugh: Good luck

            M Offline
            M Offline
            minkowski
            wrote on last edited by
            #5

            Hi Yes, I am sure what you suggested will work (am implementing it now) as I found this example void CMainFrame::OnSize(UINT nType, int cx, int cy) { CFrameWnd::OnSize(nType, cx, cy); CMenu* pmenu = GetMenu(); if (nType == SIZE_MAXIMIZED) pmenu->EnableMenuItem(ID_FREEZE, MF_DISABLED|MF_GRAYED); else pmenu->EnableMenuItem(ID_FREEZE, MF_ENABLED); Draw } Thanks for your suggestion.

            1 Reply Last reply
            0
            • M minkowski

              Hi ya, Thanks for your post. I actually found this void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { // kiran. static const CPoint point0 = CPoint(0, 0); if(m_PageSize != point0) { const long my = lpMMI -> ptMaxSize.y; const long ty = lpMMI -> ptMaxTrackSize.y; lpMMI -> ptMaxSize = m_PageSize; lpMMI -> ptMaxTrackSize = m_PageSize; lpMMI -> ptMaxSize.y = my; lpMMI -> ptMaxTrackSize.y = ty; } CFrameWnd::OnGetMinMaxInfo(lpMMI); } in my code and put a break point on it when I clicked the maximise button. The code then stopped at the break point proving that this function is invoked when using max / min. I guess the structure should contain info whether the user is doing a max / min ? Thanks

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              minkowski wrote:

              ...proving that this function is invoked when using max / min.

              True, but that does not mean it is the only function involved in such a request. The WM_GETMINMAXINFO message is sent to a window when the size or position of the window is about to change. You can handle this message to override the window's default maximized size and position, or its default minimum or maximum tracking size. The WM_SIZE message is sent to a window after its size has changed. Given your request of, "...change the way the application behaves when a user maximises the main window frame.", I'd opt for handling this message.


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              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