1、在AppWizard中更改Windos Style 来改变窗口初始是否最大化、最小化,以及是否允许更改。
2、更方便的改变可以在PreCreateWindow()中,用代码实现,如
(1)//centern window at a certain percentage of full screen
#define PRCTG 50/100 //define percentage
int xSize =::GetSystemMetrics(SM_CSSCREEN);// more information of the function see MSDN
int ySize=::GetSystemMetrics(SM_CYSCREEN);
cs.cx=xSize*PRCTG;//resize the window
cs.cy=ySize*PRCTG;
cs.x=(xSize-cs.cx)/2;
cs.y=(ySize-cs.cy)/2;
return CMainFrame::PreCreateWindow(cs);
(2) //delete the caption of the window
cs.style&=~FWS_ADDTOTITLE;// more information see MSDN about CREATESTRUCT
(3) //remove the maximize and minimize button from caption
cs.style&=~(WS_MAXIMIZEBOX|WS_MINIMIZEBOX);//you can remove only one button too
(4) // fixed the application window
cs.style&=~WS_THICKFRAME;
(5)//maximize the application window when execute
pMainFrame->ShowWindow(SW_SHOWMAXIMIZED)//in CWinApp
pMainFrame->UpdateWindow();//you can minimize too
(6) //maximize a childwindow in a MDI application
cs.style=WS_CHILD|WS_VISIBLE|WS_OVERLAPPED|WS_CAPTION_
|WS_SYSMENU|FWS_ADDTOTITLE|WS_THICKFRAME
|WS_MINIMIZEDBOX|WS_MAXIMIZEDBOX|WS_MAXIMIZE;
return CMDIChildWnd::PreCreateWindow(cs);
评论