一:创建单文档MFC应用程序,在CMainFrame类的OnCreate函数中添加代码:
<span style="font-family:Courier New;font-size:14px;">CRect rectClient;
CRect rectWindow;
GetWindowRect(&rectWindow);
//方法一
RepositionBars(0,0xffff,AFX_IDW_PANE_FIRST,reposQuery,&rectClient);
//方法二
//GetClientRect(rectClient);
ClientToScreen(rectClient);
int nWidth=GetSystemMetrics(SM_CXSCREEN);
int nHeigth=GetSystemMetrics(SM_CYSCREEN);
CRect rectScreen;
rectScreen.left=rectWindow.left-rectClient.left;
rectScreen.top=rectWindow.top-rectClient.top;
rectScreen.right=rectWindow.right-rectClient.right+nWidth;
rectScreen.bottom=rectWindow.bottom-rectClient.bottom+nHeigth;
WINDOWPLACEMENT wpm;
wpm.length=sizeof(WINDOWPLACEMENT);
wpm.flags=0;
wpm.showCmd=SW_SHOWNORMAL;
wpm.rcNormalPosition=rectScreen;
SetWindowPlacement(&wpm);</span>
方法一是全屏显示:
方法二保留了工具栏
二:
RepositionBars(0,0xffff,AFX_IDW_PANE_FIRST,reposQuery,&rectClient); 将内非客户区(标题栏、菜单兰和边框)和控制栏(工具栏和状态栏)区域排除,将剩下的矩形区域填充到rectClient中。