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. Programatically resise a Dialog and reoganize its controls

Programatically resise a Dialog and reoganize its controls

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.
  • U Offline
    U Offline
    User 1241285
    wrote on last edited by
    #1

    Hello guys, I would like to do something easy, or at least that seams to be easy ... I have an old application based on dialogs. I would like to modify it to resize its dialog window automatically depending on the screen size and resolution. Something like : - at the end of the my OnInitDialog() routine, I test the screen type - if I am 800*600, I am ok - if I am more, I resize the dialog window itself to fit the screen size and then I move and resize each of my controls depending on a ratio calculated on real resolution and 800*600. Seems to be simple, no ? But how do I do this : - access the dialog window, resize it - access each of its controls (lists, buttons, etc), change their position and size. Thanks in advance DD

    C E 2 Replies Last reply
    0
    • U User 1241285

      Hello guys, I would like to do something easy, or at least that seams to be easy ... I have an old application based on dialogs. I would like to modify it to resize its dialog window automatically depending on the screen size and resolution. Something like : - at the end of the my OnInitDialog() routine, I test the screen type - if I am 800*600, I am ok - if I am more, I resize the dialog window itself to fit the screen size and then I move and resize each of my controls depending on a ratio calculated on real resolution and 800*600. Seems to be simple, no ? But how do I do this : - access the dialog window, resize it - access each of its controls (lists, buttons, etc), change their position and size. Thanks in advance DD

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      qadddd_free wrote: access the dialog window, resize it Does this mean you're not changing the code in the app ? If you are, then setwindowpos is what you want qadddd_free wrote: access each of its controls (lists, buttons, etc), change their position and size. The best way to do this is to call setwindowpos for all your controls in a handler for the WM_SIZE event, in other words, when your screen resizes itself, the controls also get sized to fit in the window. Christian Graus - Microsoft MVP - C++

      Q 1 Reply Last reply
      0
      • U User 1241285

        Hello guys, I would like to do something easy, or at least that seams to be easy ... I have an old application based on dialogs. I would like to modify it to resize its dialog window automatically depending on the screen size and resolution. Something like : - at the end of the my OnInitDialog() routine, I test the screen type - if I am 800*600, I am ok - if I am more, I resize the dialog window itself to fit the screen size and then I move and resize each of my controls depending on a ratio calculated on real resolution and 800*600. Seems to be simple, no ? But how do I do this : - access the dialog window, resize it - access each of its controls (lists, buttons, etc), change their position and size. Thanks in advance DD

        E Offline
        E Offline
        eli15021979
        wrote on last edited by
        #3

        Hi, Is this what you are looking for: http://www.codeproject.com/dialog/dlgresizearticle.asp[^] With best regards, Eli

        Q 1 Reply Last reply
        0
        • C Christian Graus

          qadddd_free wrote: access the dialog window, resize it Does this mean you're not changing the code in the app ? If you are, then setwindowpos is what you want qadddd_free wrote: access each of its controls (lists, buttons, etc), change their position and size. The best way to do this is to call setwindowpos for all your controls in a handler for the WM_SIZE event, in other words, when your screen resizes itself, the controls also get sized to fit in the window. Christian Graus - Microsoft MVP - C++

          Q Offline
          Q Offline
          Qadddd
          wrote on last edited by
          #4

          Hello, Good idea to put all my business in the OnSize() function. My biggest problem now is to determine the position, length and height of each control depending on the screen resolution. Thanks for help Regards DD

          1 Reply Last reply
          0
          • E eli15021979

            Hi, Is this what you are looking for: http://www.codeproject.com/dialog/dlgresizearticle.asp[^] With best regards, Eli

            Q Offline
            Q Offline
            Qadddd
            wrote on last edited by
            #5

            Hello, It is not really what I was looking for because I would like to keep my code as is, just add the the routine that maximizes the dialog and re-organizes all the controls. If I would like to do it as described in this article, I would have to change a big part of my code to create all controls independantly, etc ... But never the less, I will have a look in the part that calculates the new position and size of the control ... ;-)) Thanks Regards DD

            E 1 Reply Last reply
            0
            • Q Qadddd

              Hello, It is not really what I was looking for because I would like to keep my code as is, just add the the routine that maximizes the dialog and re-organizes all the controls. If I would like to do it as described in this article, I would have to change a big part of my code to create all controls independantly, etc ... But never the less, I will have a look in the part that calculates the new position and size of the control ... ;-)) Thanks Regards DD

              E Offline
              E Offline
              eli15021979
              wrote on last edited by
              #6

              Hi DD, I don't think that you will have to change a big part of your code. I didn't check it but try this in your OnInitDialog:

              //first - include the anchor.h and declare the appropriate dialogs
              #include "anchor.h"

              CDlgAnchor dlgAnchor;
              CDlgMan dlgMan;

              dlgMan.Load(hwndDlg, "Yours project path");
              dlgAnchor.Init(hwndDlg);
              for(int nIndex = IDC\_FIRST\_CONTROL ; nIndex < IDC\_LAST\_CONTROL ; nIndex++)
                   dlgAnchor.Add(nIndex, ANCHOR\_ALL);
              

              then , add the WM_SIZE handler , and add to it :

              dlgAnchor.OnSize();

              Good luck, Eli.

              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