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. Non-resizable window.

Non-resizable window.

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 4 Posters 1 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.
  • J Offline
    J Offline
    John Uhlenbrock
    wrote on last edited by
    #1

    How do I go about keeping my form-view based app from being resized, I'd also like to hide the maximize/restore restore button....

    N U R 3 Replies Last reply
    0
    • J John Uhlenbrock

      How do I go about keeping my form-view based app from being resized, I'd also like to hide the maximize/restore restore button....

      N Offline
      N Offline
      Nathan Hoffman
      wrote on last edited by
      #2

      Try catching the WM_SIZE/WM_SIZING message but don't resize anything. I don't know how to hide the maximize/restore button. Here are a couple links you may find interesting: OnSizing http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/\_mfc\_cwnd.3a3a.onsizing.asp OnSize http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/\_mfc\_cwnd.3a3a.onsize.asp Hope that helps.

      1 Reply Last reply
      0
      • J John Uhlenbrock

        How do I go about keeping my form-view based app from being resized, I'd also like to hide the maximize/restore restore button....

        U Offline
        U Offline
        Ulf Ohlen
        wrote on last edited by
        #3

        You need to remove a couple of window style flags from the main frame: WS_THICKFRAME and WS_MAXIMIZEBOX. The easiest way to do this in MFC is to override CWnd::PreCreateWindow().

        BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
        {
        if( !CFrameWnd::PreCreateWindow(cs) )
        return FALSE;
        cs.style &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX);
        return TRUE;
        }

        -------------- "Aagh!! I'm a victim of a Random Act of Management!"

        1 Reply Last reply
        0
        • J John Uhlenbrock

          How do I go about keeping my form-view based app from being resized, I'd also like to hide the maximize/restore restore button....

          R Offline
          R Offline
          Rick York
          wrote on last edited by
          #4

          Ulf is on the right track. However, I like the thick frame style so I take a somewhat backdoor approach. Catch the WM_NCHITTEST message (I think it is), which is the non-client hit test and tell the OS that it never hits the corners or sides. If you don't want it to be unmoveable then don't "let" it hit the title bar. This way, you can have a standard appearance but the window will be non-resizable and unmovable.

          U 1 Reply Last reply
          0
          • R Rick York

            Ulf is on the right track. However, I like the thick frame style so I take a somewhat backdoor approach. Catch the WM_NCHITTEST message (I think it is), which is the non-client hit test and tell the OS that it never hits the corners or sides. If you don't want it to be unmoveable then don't "let" it hit the title bar. This way, you can have a standard appearance but the window will be non-resizable and unmovable.

            U Offline
            U Offline
            Ulf Ohlen
            wrote on last edited by
            #5

            I agree that apps look better with the thick border style. Catching WM_NCHITTEST is not 100% foolproof, though. It prevents the user from resizing the window, but Windows can still resize it (if the user, for example, clicks "Tile windows" from the task bar). Also, if the window has a status bar, it can be resized with the status bar's gripper. These problems can be solved by catching WM_GETMINMAXINFO and setting the window's min and max tracking sizes. -------------- "Aagh!! I'm a victim of a Random Act of Management!"

            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