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. Query abt dialog box

Query abt dialog box

Scheduled Pinned Locked Moved C / C++ / MFC
questiondatabase
20 Posts 5 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 3037427
    wrote on last edited by
    #1

    How can i resize the dialog box controls when i resize the dialog box??:confused:

    N B H T 4 Replies Last reply
    0
    • U User 3037427

      How can i resize the dialog box controls when i resize the dialog box??:confused:

      N Offline
      N Offline
      Nibu babu thomas
      wrote on last edited by
      #2

      sruti_p wrote:

      How can i resize the dialog box controls when i resize the dialog box??

      Well you've got to design a layout manager. Just like the ones you find in Java. ;) The best place to trigger a layout is WM_SIZE.


      Nibu thomas A Developer Programming tips[^]  My site[^]

      U 1 Reply Last reply
      0
      • U User 3037427

        How can i resize the dialog box controls when i resize the dialog box??:confused:

        B Offline
        B Offline
        Benoy Bose
        wrote on last edited by
        #3

        There is no need to design a layout manager. You just have to resize the dialog box controls as follows. 1. Get the Client rectangle of the Dialog Box. ( Use: GetClientRect(LPRECT)) 2. Calculate the new size of controls. 4. Validate whether the dialog controls are valid window ( Use; IsWindow( HWND )) 5. Move dialog controls to the new position i they are valid windows. Hope it is useful Thank You Regards, Benoy Bose

        N U 2 Replies Last reply
        0
        • B Benoy Bose

          There is no need to design a layout manager. You just have to resize the dialog box controls as follows. 1. Get the Client rectangle of the Dialog Box. ( Use: GetClientRect(LPRECT)) 2. Calculate the new size of controls. 4. Validate whether the dialog controls are valid window ( Use; IsWindow( HWND )) 5. Move dialog controls to the new position i they are valid windows. Hope it is useful Thank You Regards, Benoy Bose

          N Offline
          N Offline
          Nibu babu thomas
          wrote on last edited by
          #4

          Benoy Bose wrote:

          There is no need to design a layout manager.

          Benoy Bose wrote:

          1. Get the Client rectangle of the Dialog Box. ( Use: GetClientRect(LPRECT)) 2. Calculate the new size of controls. 4. Validate whether the dialog controls are valid window ( Use; IsWindow( HWND )) 5. Move dialog controls to the new position i they are valid windows.

          Which is what the layout manager will do for you. :|


          Nibu thomas A Developer Programming tips[^]  My site[^]

          B 1 Reply Last reply
          0
          • N Nibu babu thomas

            Benoy Bose wrote:

            There is no need to design a layout manager.

            Benoy Bose wrote:

            1. Get the Client rectangle of the Dialog Box. ( Use: GetClientRect(LPRECT)) 2. Calculate the new size of controls. 4. Validate whether the dialog controls are valid window ( Use; IsWindow( HWND )) 5. Move dialog controls to the new position i they are valid windows.

            Which is what the layout manager will do for you. :|


            Nibu thomas A Developer Programming tips[^]  My site[^]

            B Offline
            B Offline
            Benoy Bose
            wrote on last edited by
            #5

            Layout manager in Java ( Like you said ) will automatically resize the controls in the window. Since we have a very simple method to resize the controls in MFC, designing a layout manager is overhead to the developer. In Java it's depends upon the personel interest since there are both the features are readly available.

            N 1 Reply Last reply
            0
            • B Benoy Bose

              Layout manager in Java ( Like you said ) will automatically resize the controls in the window. Since we have a very simple method to resize the controls in MFC, designing a layout manager is overhead to the developer. In Java it's depends upon the personel interest since there are both the features are readly available.

              N Offline
              N Offline
              Nibu babu thomas
              wrote on last edited by
              #6

              Benoy Bose wrote:

              Layout manager in Java ( Like you said ) will automatically resize the controls in the window.

              Not always. It depends on the way you design it.

              Benoy Bose wrote:

              Since we have a very simple method to resize the controls in MFC, designing a layout manager is overhead to the developer.

              Now imagine she want's to change the layout! Imagine the overhead.

              Benoy Bose wrote:

              In Java it's depends upon the personel interest since there are both the features are readly available.

              That is why you must have a layout manager. When you design, generalize your design. That is what OOP is all about. If you don't want any layout don't call the layout manager. I love the Java layout manager classes. :)


              Nibu thomas A Developer Programming tips[^]  My site[^]

              B 1 Reply Last reply
              0
              • N Nibu babu thomas

                Benoy Bose wrote:

                Layout manager in Java ( Like you said ) will automatically resize the controls in the window.

                Not always. It depends on the way you design it.

                Benoy Bose wrote:

                Since we have a very simple method to resize the controls in MFC, designing a layout manager is overhead to the developer.

                Now imagine she want's to change the layout! Imagine the overhead.

                Benoy Bose wrote:

                In Java it's depends upon the personel interest since there are both the features are readly available.

                That is why you must have a layout manager. When you design, generalize your design. That is what OOP is all about. If you don't want any layout don't call the layout manager. I love the Java layout manager classes. :)


                Nibu thomas A Developer Programming tips[^]  My site[^]

                B Offline
                B Offline
                Benoy Bose
                wrote on last edited by
                #7

                its really depends upon the persnel interest. I respect you interest. I believe Layout can generalize the functionality, but my code do the same in simple and a few lines. While I was working with layout managers in Java, i feel i have only a less freedom to move the control over the window. And I satrted to put NULL in the Java Window layout and moved my controls independently.

                N 1 Reply Last reply
                0
                • U User 3037427

                  How can i resize the dialog box controls when i resize the dialog box??:confused:

                  H Offline
                  H Offline
                  Hamid Taebi
                  wrote on last edited by
                  #8

                  you can use WM_SIZE and use functions MoveWindow or SetWindowPos in this event_**


                  **_

                  whitesky


                  U 1 Reply Last reply
                  0
                  • N Nibu babu thomas

                    sruti_p wrote:

                    How can i resize the dialog box controls when i resize the dialog box??

                    Well you've got to design a layout manager. Just like the ones you find in Java. ;) The best place to trigger a layout is WM_SIZE.


                    Nibu thomas A Developer Programming tips[^]  My site[^]

                    U Offline
                    U Offline
                    User 3037427
                    wrote on last edited by
                    #9

                    But how can i do this? is there any function for this?? Thanks for reply.

                    N 1 Reply Last reply
                    0
                    • B Benoy Bose

                      its really depends upon the persnel interest. I respect you interest. I believe Layout can generalize the functionality, but my code do the same in simple and a few lines. While I was working with layout managers in Java, i feel i have only a less freedom to move the control over the window. And I satrted to put NULL in the Java Window layout and moved my controls independently.

                      N Offline
                      N Offline
                      Nibu babu thomas
                      wrote on last edited by
                      #10

                      Benoy Bose wrote:

                      my code do the same in simple and a few lines.

                      Then that is called a simple layout manager. Don't get overrawed by the term Layout Manager. :)

                      Benoy Bose wrote:

                      i feel i have only a less freedom to move the control over the window.

                      I worked in Java for sometime. The LayoutManagers were cool. Some of them were not that good but then they all had some purpose as indicated by their name. I worked in some MFC layout managers. All of them were real cool. Except for setting them up. Once that pain is over it looks real cool. But as you said it depends. :)


                      Nibu thomas A Developer Programming tips[^]  My site[^]

                      1 Reply Last reply
                      0
                      • U User 3037427

                        But how can i do this? is there any function for this?? Thanks for reply.

                        N Offline
                        N Offline
                        Nibu babu thomas
                        wrote on last edited by
                        #11

                        sruti_p wrote:

                        But how can i do this? is there any function for this??

                        It should be easy to find one. Hey CP has one for sure I think I saw one. :~ Of course WhiteSky has mentioned two. But they work on a single control. But the above mentioned technique can take a bunch of controls and resize them as your specify. I think I saw one or two or three... of those layout managers in Code Project. Please check.


                        Nibu thomas A Developer Programming tips[^]  My site[^]

                        U 1 Reply Last reply
                        0
                        • B Benoy Bose

                          There is no need to design a layout manager. You just have to resize the dialog box controls as follows. 1. Get the Client rectangle of the Dialog Box. ( Use: GetClientRect(LPRECT)) 2. Calculate the new size of controls. 4. Validate whether the dialog controls are valid window ( Use; IsWindow( HWND )) 5. Move dialog controls to the new position i they are valid windows. Hope it is useful Thank You Regards, Benoy Bose

                          U Offline
                          U Offline
                          User 3037427
                          wrote on last edited by
                          #12

                          I Even want to increase/decrease the size of the controls based on th ewindow size. How can i do this?? :((

                          B N 2 Replies Last reply
                          0
                          • N Nibu babu thomas

                            sruti_p wrote:

                            But how can i do this? is there any function for this??

                            It should be easy to find one. Hey CP has one for sure I think I saw one. :~ Of course WhiteSky has mentioned two. But they work on a single control. But the above mentioned technique can take a bunch of controls and resize them as your specify. I think I saw one or two or three... of those layout managers in Code Project. Please check.


                            Nibu thomas A Developer Programming tips[^]  My site[^]

                            U Offline
                            U Offline
                            User 3037427
                            wrote on last edited by
                            #13

                            Thanks for ur reply.:)

                            1 Reply Last reply
                            0
                            • U User 3037427

                              I Even want to increase/decrease the size of the controls based on th ewindow size. How can i do this?? :((

                              B Offline
                              B Offline
                              Benoy Bose
                              wrote on last edited by
                              #14

                              You can either use Layout Managers or simple use MoveWindow or SetWindowPos in OnSize( WM_SIZE )

                              1 Reply Last reply
                              0
                              • U User 3037427

                                I Even want to increase/decrease the size of the controls based on th ewindow size. How can i do this?? :((

                                N Offline
                                N Offline
                                Nibu babu thomas
                                wrote on last edited by
                                #15

                                sruti_p wrote:

                                I Even want to increase/decrease the size of the controls based on th ewindow size. How can i do this??

                                Layout Managers Found In CP[^]. You should try to search first. :|


                                Nibu thomas A Developer Programming tips[^]  My site[^]

                                U 1 Reply Last reply
                                0
                                • H Hamid Taebi

                                  you can use WM_SIZE and use functions MoveWindow or SetWindowPos in this event_**


                                  **_

                                  whitesky


                                  U Offline
                                  U Offline
                                  User 3037427
                                  wrote on last edited by
                                  #16

                                  I am not getting it. This is what my code is: void CEgAppDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); // TODO: Add your message handler code here CRect wRect,eRect; GetClientRect(wRect); m_edit.GetClientRect(eRect); POINT * pt; pt->x=eRect.left; pt->y=eRect.top; ::ClientToScreen(m_edit.m_hWnd,pt); eRect.bottom+=30; eRect.right+=30; ::MoveWindow(m_edit.m_hWnd,pt->x,pt->y,eRect.Width(), eRect.Height(),TRUE); } I am getting an Exception:((

                                  H B 2 Replies Last reply
                                  0
                                  • N Nibu babu thomas

                                    sruti_p wrote:

                                    I Even want to increase/decrease the size of the controls based on th ewindow size. How can i do this??

                                    Layout Managers Found In CP[^]. You should try to search first. :|


                                    Nibu thomas A Developer Programming tips[^]  My site[^]

                                    U Offline
                                    U Offline
                                    User 3037427
                                    wrote on last edited by
                                    #17

                                    Thanks a lot. I got it.:)

                                    1 Reply Last reply
                                    0
                                    • U User 3037427

                                      How can i resize the dialog box controls when i resize the dialog box??:confused:

                                      T Offline
                                      T Offline
                                      ThatsAlok
                                      wrote on last edited by
                                      #18

                                      sruti_p wrote:

                                      How can i resize the dialog box controls when i resize the dialog box?

                                      Either Subclass the control to handle the Dialog resize or use MoveWindow api!

                                      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                                      cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                                      1 Reply Last reply
                                      0
                                      • U User 3037427

                                        I am not getting it. This is what my code is: void CEgAppDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); // TODO: Add your message handler code here CRect wRect,eRect; GetClientRect(wRect); m_edit.GetClientRect(eRect); POINT * pt; pt->x=eRect.left; pt->y=eRect.top; ::ClientToScreen(m_edit.m_hWnd,pt); eRect.bottom+=30; eRect.right+=30; ::MoveWindow(m_edit.m_hWnd,pt->x,pt->y,eRect.Width(), eRect.Height(),TRUE); } I am getting an Exception:((

                                        H Offline
                                        H Offline
                                        Hamid Taebi
                                        wrote on last edited by
                                        #19

                                        i guess m_edit.m_hWnd=NULL insert this if(m_edit.m_hWnd!=NULL) { ... }_**


                                        **_

                                        whitesky


                                        1 Reply Last reply
                                        0
                                        • U User 3037427

                                          I am not getting it. This is what my code is: void CEgAppDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); // TODO: Add your message handler code here CRect wRect,eRect; GetClientRect(wRect); m_edit.GetClientRect(eRect); POINT * pt; pt->x=eRect.left; pt->y=eRect.top; ::ClientToScreen(m_edit.m_hWnd,pt); eRect.bottom+=30; eRect.right+=30; ::MoveWindow(m_edit.m_hWnd,pt->x,pt->y,eRect.Width(), eRect.Height(),TRUE); } I am getting an Exception:((

                                          B Offline
                                          B Offline
                                          Benoy Bose
                                          wrote on last edited by
                                          #20

                                          Hey, just reduce the code lines do as follows void CEgAppDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); CRect ClientRect( 0, 0, 0, 0 ); GetClientRect( ClientRect ); if( FALSE != IsWindow( m_edit.GetSafeHwnd())) { m_edit.MoveWindow( ClientRect ); } } This code is expected to work only when the Dialog is forcely resize by using Minimize, Maximize, Drag Size etc. To resize the control in Initial state you have to put some similiar code in the OnInitDialog of the dialog class like CRect ClientRect( 0, 0, 0, 0 ); GetClientRect( ClientRect ); m_edit.MoveWindow( ClientRect ); In OnInitDialog you do not have to check the Window handle because OnInitDialog is called after the creation of the Dialog Box and it's control. But you should check the Validity of m_edit window in OnSize because it is called by the framework when the DialogBox alone is created, before the edit is created. OK ? Regards, Benoy Bose

                                          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