一:创建单文档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中。
本文介绍了如何使用MFC在创建单文档应用程序时,通过`RepositionBars`函数实现窗口布局调整,以达到全屏显示或保留工具栏的效果。详细解释了两种方法的区别和应用。
1388

被折叠的 条评论
为什么被折叠?



