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