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 add a minimize button and maximize button on a dialog?

how to add a minimize button and maximize button on a dialog?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 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
    vividtang
    wrote on last edited by
    #1

    the following is my doing: in precreatewindow() cs.style|=MINIMIZEBOX; but doesnt work,somebody can give me some advice and explanination? thx

    D A 2 Replies Last reply
    0
    • V vividtang

      the following is my doing: in precreatewindow() cs.style|=MINIMIZEBOX; but doesnt work,somebody can give me some advice and explanination? thx

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

      Are you creating the dialog at runtime, or toggling the min/max on and off buttons while the dialog is running?


      "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

      1 Reply Last reply
      0
      • V vividtang

        the following is my doing: in precreatewindow() cs.style|=MINIMIZEBOX; but doesnt work,somebody can give me some advice and explanination? thx

        A Offline
        A Offline
        Alexander M
        wrote on last edited by
        #3

        there are 2 better ways. if you are using a dialog resource then change the dialog settings with the resource editor (there is an option for min/max button). the other way is to change the window style run-time.

        DWORD dwLong;

        dwLong = GetWindowLong( hWnd, GWL_STYLE );
        dwLong |= WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
        SetWindowLong( hWnd, GWL_STYLE, dwLong );

        Don't try it, just do it! ;-)

        J 1 Reply Last reply
        0
        • A Alexander M

          there are 2 better ways. if you are using a dialog resource then change the dialog settings with the resource editor (there is an option for min/max button). the other way is to change the window style run-time.

          DWORD dwLong;

          dwLong = GetWindowLong( hWnd, GWL_STYLE );
          dwLong |= WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
          SetWindowLong( hWnd, GWL_STYLE, dwLong );

          Don't try it, just do it! ;-)

          J Offline
          J Offline
          J B 0
          wrote on last edited by
          #4

          If in MFC, I think ModifyStytle() works the same way.

          ModifyStyle(0, WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
          

          I have a little problem when making this style changes in run time tho. I placed it at the end of OnInitDialog() and the changes is made sucessfully. But at the first time the dialog appears, the MAXIMIZE and MINIMIZE icons (just the icons) are still on the menu bar, until the window is refreshed (e.g. switch to other dialog and switch back). Is this normal?

          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