Dialog size should change to the system screen size
-
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?
One way is to use GetSystemMetrics() with SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN to retrieve the screen dimensions, then use SetWindowPos() to set your dialog to that size.
-
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?
-
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?
Call
ShowWindow(SW_SHOWMAXIMIZED)
[^].Software Zen:
delete this;
Fold With Us![^] -
Small example:
UINT width = GetSystemMetrics(SM_CXSCREEN);
UINT height = GetSystemMetrics(SM_CYSCREEN);
SetWindowPos(hWnd, HWND_TOP, 0, 0, width, height, SWP_NOZORDER | SWP_SHOWWINDOW);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.
-
Call
ShowWindow(SW_SHOWMAXIMIZED)
[^].Software Zen:
delete this;
Fold With Us![^]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.
-
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.
-
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?
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.
-
Small example:
UINT width = GetSystemMetrics(SM_CXSCREEN);
UINT height = GetSystemMetrics(SM_CYSCREEN);
SetWindowPos(hWnd, HWND_TOP, 0, 0, width, height, SWP_NOZORDER | SWP_SHOWWINDOW); -
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.
-
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
-
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
-
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.
-
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.