Programatically resise a Dialog and reoganize its controls
-
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
-
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
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++
-
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
Hi, Is this what you are looking for: http://www.codeproject.com/dialog/dlgresizearticle.asp[^] With best regards, Eli
-
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++
-
Hi, Is this what you are looking for: http://www.codeproject.com/dialog/dlgresizearticle.asp[^] With best regards, Eli
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
-
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
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.