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. Preventing a window from becoming maximized

Preventing a window from becoming maximized

Scheduled Pinned Locked Moved C / C++ / MFC
question
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.
  • V Offline
    V Offline
    Vancouver
    wrote on last edited by
    #1

    1. I have a simple dialog window, which has the "minimize" box enabled; the "maximize" box is not enabled. 2. One of the buttons of my mouse is customized as "maximize". Pressing this button maximizes the above, "non-maximizable" window. Is there a direct, clean way to prevent this maximizing? I guess posting a WM_SIZE message with SIZE_RESTORED from OnSize would work, but I find it strange that a "no" won't be taken as "no".

    M B V 3 Replies Last reply
    0
    • V Vancouver

      1. I have a simple dialog window, which has the "minimize" box enabled; the "maximize" box is not enabled. 2. One of the buttons of my mouse is customized as "maximize". Pressing this button maximizes the above, "non-maximizable" window. Is there a direct, clean way to prevent this maximizing? I guess posting a WM_SIZE message with SIZE_RESTORED from OnSize would work, but I find it strange that a "no" won't be taken as "no".

      M Offline
      M Offline
      Mumiozol
      wrote on last edited by
      #2

      Catch the WM_SIZE: OnSize( UINT nType, int cx, int cy ); if nType==SIZE_MAXIMIZED don't let the message go further. Mickey :)

      V 1 Reply Last reply
      0
      • M Mumiozol

        Catch the WM_SIZE: OnSize( UINT nType, int cx, int cy ); if nType==SIZE_MAXIMIZED don't let the message go further. Mickey :)

        V Offline
        V Offline
        Vancouver
        wrote on last edited by
        #3

        Thanks; however this does not help. The OnSize description states: The framework calls this member function AFTER the window's size has changed. I fact, this filtering in OnSize does not change the result. A call of CDialog::OnSize will be generated by the wizzard in OnSize. I admit that I don't know, what CDialog::OnSize does (this will be generated by the wizzard in OnSize), but no matter if I call it or not, the result is the same. In the meantime I tested my own suggestion, posting a WM_SIZE message with SIZE_RESTORED. This does not work either; I'd like to know, why. The message goes through properly, it appears in OnSize as well, with the identical parameters, as a RESTORE from the minimized state generates - but restoring does not happen. SetWindowPlacement works, but that needs more preparation: not only the size, but the position of the last non-maximized window too has to be recorded. Not a big deal, but all this is nonsense.

        K 1 Reply Last reply
        0
        • V Vancouver

          Thanks; however this does not help. The OnSize description states: The framework calls this member function AFTER the window's size has changed. I fact, this filtering in OnSize does not change the result. A call of CDialog::OnSize will be generated by the wizzard in OnSize. I admit that I don't know, what CDialog::OnSize does (this will be generated by the wizzard in OnSize), but no matter if I call it or not, the result is the same. In the meantime I tested my own suggestion, posting a WM_SIZE message with SIZE_RESTORED. This does not work either; I'd like to know, why. The message goes through properly, it appears in OnSize as well, with the identical parameters, as a RESTORE from the minimized state generates - but restoring does not happen. SetWindowPlacement works, but that needs more preparation: not only the size, but the position of the last non-maximized window too has to be recorded. Not a big deal, but all this is nonsense.

          K Offline
          K Offline
          KaRl
          wrote on last edited by
          #4

          Have you tried to catch WM_WINDOWPOSCHANGING[^]?


          Silence Means Death Stand On Your Feet Inner Fear Your Worst Enemy

          1 Reply Last reply
          0
          • V Vancouver

            1. I have a simple dialog window, which has the "minimize" box enabled; the "maximize" box is not enabled. 2. One of the buttons of my mouse is customized as "maximize". Pressing this button maximizes the above, "non-maximizable" window. Is there a direct, clean way to prevent this maximizing? I guess posting a WM_SIZE message with SIZE_RESTORED from OnSize would work, but I find it strange that a "no" won't be taken as "no".

            B Offline
            B Offline
            Blake Miller
            wrote on last edited by
            #5

            You must also process the CWnd::OnGetMinMaxInfo or handle WM_GETMINMAXINFO. If that does not work, override CWnd::PreTranslateMessage and trap the sizing calls. The memories of a man in his old age are the deeds of a man in his prime.

            1 Reply Last reply
            0
            • V Vancouver

              1. I have a simple dialog window, which has the "minimize" box enabled; the "maximize" box is not enabled. 2. One of the buttons of my mouse is customized as "maximize". Pressing this button maximizes the above, "non-maximizable" window. Is there a direct, clean way to prevent this maximizing? I guess posting a WM_SIZE message with SIZE_RESTORED from OnSize would work, but I find it strange that a "no" won't be taken as "no".

              V Offline
              V Offline
              Vancouver
              wrote on last edited by
              #6

              Thanks for the suggestions. WM_WINDOWPOSCHANGING appears a good solution, but it does not say, when the window will be maximized, i.e. it would need a "calibration" to get the actual maximum size. In the meantime I solved the problem already, with a combination of OnSize and OnMove plus SetWindowPlacement as correction of MAXIMIZE. However it is not a nice solution. Sometimes OnSize, sometimes OnMove is the first, when both will be called. Lots of work-around only to prevent the system from doing something, what it should not do per definition. Anyway, now it's working, but I'm now trying Blake's suggestion, GetMinMaxInfo. This function gets called before each MAXIMIZE (I have expected a call at MINIMIZE at well, even though it does not matter in my case). Simply to prevent MAXIMIZE to a large size is very simple this way. However, there is still a small problem: it positions the window to the upper left corner; one has to work around it. Once more, thanx for the help.

              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