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. Dialog size should change to the system screen size

Dialog size should change to the system screen size

Scheduled Pinned Locked Moved C / C++ / MFC
question
17 Posts 6 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.
  • X Xeqtr 0

    Small example:

    UINT width = GetSystemMetrics(SM_CXSCREEN);
    UINT height = GetSystemMetrics(SM_CYSCREEN);
    SetWindowPos(hWnd, HWND_TOP, 0, 0, width, height, SWP_NOZORDER | SWP_SHOWWINDOW);

    L Offline
    L Offline
    loyal ginger
    wrote on last edited by
    #5

    Just a comment: If you don't use SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN in the GetSystemMetrics() calls, on a multiple-monitor system only the primary monitor's dimension is obtained. It's hard to tell whether the original poster wanted to use the primary monitor, or the whole desktop, though.

    X 1 Reply Last reply
    0
    • G Gary R Wheeler

      Call ShowWindow(SW_SHOWMAXIMIZED)[^].

      Software Zen: delete this;
      Fold With Us![^]

      L Offline
      L Offline
      loyal ginger
      wrote on last edited by
      #6

      On some multiple-monitor systems this only maximizes the window to one of the monitors, which may or may not be what the original poster wanted.

      1 Reply Last reply
      0
      • L loyal ginger

        Just a comment: If you don't use SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN in the GetSystemMetrics() calls, on a multiple-monitor system only the primary monitor's dimension is obtained. It's hard to tell whether the original poster wanted to use the primary monitor, or the whole desktop, though.

        X Offline
        X Offline
        Xeqtr 0
        wrote on last edited by
        #7

        ohh yeah, if author will use a multiple-monitor system, you're right of course :)

        1 Reply Last reply
        0
        • T tho_mee

          I have a dialog in my application. When the application starts the dialog size should be the the system size. It should occupy the full screen size automatically. How can i do this?

          Z Offline
          Z Offline
          zp2000
          wrote on last edited by
          #8

          As the answers aboves, I want to ask a question for more. That is: How can you let the buttons or text controls to suit the screen when the dialog fit the different screen size? In another word, the buttons in dialog will stay unmove if you just let the dialog fit the screen, that will make the whole dialog look grotty. Thanks, I wonder if I describe the question clearly.

          X 1 Reply Last reply
          0
          • X Xeqtr 0

            Small example:

            UINT width = GetSystemMetrics(SM_CXSCREEN);
            UINT height = GetSystemMetrics(SM_CYSCREEN);
            SetWindowPos(hWnd, HWND_TOP, 0, 0, width, height, SWP_NOZORDER | SWP_SHOWWINDOW);

            T Offline
            T Offline
            tho_mee
            wrote on last edited by
            #9

            hai all . I am using a dialog based MFC application. How will I get the value of hwnd?

            X 1 Reply Last reply
            0
            • T tho_mee

              hai all . I am using a dialog based MFC application. How will I get the value of hwnd?

              X Offline
              X Offline
              Xeqtr 0
              wrote on last edited by
              #10

              By default CWnd defined in afxwin.h. You should find same definition CWnd* m_pMainWnd;

              C 1 Reply Last reply
              0
              • Z zp2000

                As the answers aboves, I want to ask a question for more. That is: How can you let the buttons or text controls to suit the screen when the dialog fit the different screen size? In another word, the buttons in dialog will stay unmove if you just let the dialog fit the screen, that will make the whole dialog look grotty. Thanks, I wonder if I describe the question clearly.

                X Offline
                X Offline
                Xeqtr 0
                wrote on last edited by
                #11

                At first you should determine controls position and form size, then on WM_SIZE event change position of controls that will depends on width and height of your form.

                C 1 Reply Last reply
                0
                • X Xeqtr 0

                  By default CWnd defined in afxwin.h. You should find same definition CWnd* m_pMainWnd;

                  C Offline
                  C Offline
                  chikach
                  wrote on last edited by
                  #12

                  hi I am trying to use it in InitDialog() but they are showing undeclared identifier m_pMainWnd I saw this variable in the afxwin.h which is included by the StdAfx.h

                  X 1 Reply Last reply
                  0
                  • C chikach

                    hi I am trying to use it in InitDialog() but they are showing undeclared identifier m_pMainWnd I saw this variable in the afxwin.h which is included by the StdAfx.h

                    X Offline
                    X Offline
                    Xeqtr 0
                    wrote on last edited by
                    #13

                    What version of Visual Studio do you use? If 2010, there is another structure of default generated code. Anyways check that stdafx.h is include in your header file :-D

                    C 1 Reply Last reply
                    0
                    • X Xeqtr 0

                      What version of Visual Studio do you use? If 2010, there is another structure of default generated code. Anyways check that stdafx.h is include in your header file :-D

                      C Offline
                      C Offline
                      chikach
                      wrote on last edited by
                      #14

                      hai , I am using this code in InitDialog() int width=GetSystemMetrics(SM_CXSCREEN); int height=GetSystemMetrics(SM_CYSCREEN); SetWindowPos(AfxGetApp()->m_pMainWnd,0,0,width,height,SWP_SHOWWINDOW); It is not working.

                      C 1 Reply Last reply
                      0
                      • C chikach

                        hai , I am using this code in InitDialog() int width=GetSystemMetrics(SM_CXSCREEN); int height=GetSystemMetrics(SM_CYSCREEN); SetWindowPos(AfxGetApp()->m_pMainWnd,0,0,width,height,SWP_SHOWWINDOW); It is not working.

                        C Offline
                        C Offline
                        chikach
                        wrote on last edited by
                        #15

                        hey i got it . :) I chaged the last parameter to SWP_NOZORDER|SWP_SHOWWINDOW .then it was working. Thank u :)

                        1 Reply Last reply
                        0
                        • X Xeqtr 0

                          At first you should determine controls position and form size, then on WM_SIZE event change position of controls that will depends on width and height of your form.

                          C Offline
                          C Offline
                          chikach
                          wrote on last edited by
                          #16

                          which functions can i use to do this?

                          X 1 Reply Last reply
                          0
                          • C chikach

                            which functions can i use to do this?

                            X Offline
                            X Offline
                            Xeqtr 0
                            wrote on last edited by
                            #17

                            So the simplest way to use GetClientRect... and example

                            RECT clientScrRect;
                            GetClientRect(hWnd, &clientScrRect);

                            Instead hWnd write HWND of your controls. Finally you got coordinates of your controls.

                            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