BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
int xSize=::GetSystemMetrics(SM_CXSCREEN);
int ySize=::GetSystemMetrics(SM_CXSCREEN);
cs.cx=xSize;
cs.cy=ySize; return TRUE;
}
这段代码可实现窗体最大化,请问SM_CXSCREEN和SM_CXSCREEN是什么意思?

解决方案 »

  1.   

    SM_CXSCREEN,SM_CYSCREEN 
    Width and height, in pixels, of the screen of the primary display monitor. These are the same values you obtain by calling GetDeviceCaps(hdcPrimaryMonitor, HORZRES/VERTRES).
      

  2.   

    窗体创建之前,PreCreateWindow(CREATESTRUCT& cs),并根据你对cs的设置,来创建窗体。
    由于本例中cs.cx和cs.cy被设置成了屏幕最大像素值,所以一上来就能最大化。