例子:该例子获取各参数的值,没有菜单、工具栏、状态栏
int i;
i = GetSystemMetrics(SM_CLEANBOOT);//启动方式 0
i = GetSystemMetrics(SM_CMONITORS);//显示器数目 1
i = GetSystemMetrics(SM_CMOUSEBUTTONS);//鼠标上按键的数目 3
i = GetSystemMetrics(SM_CXBORDER);//窗口边框的宽度,3D外观下与SM_CXEDGE值相同 1
i = GetSystemMetrics(SM_CXCURSOR);//光标的宽度 32
i = GetSystemMetrics(SM_CXDLGFRAME);//与SM_CXFIXEDFRAME相同 3
i = GetSystemMetrics(SM_CXDOUBLECLK);//鼠标在某个矩形内连击两次被认为是双击,该矩形的宽度 4
i = GetSystemMetrics(SM_CXDRAG);//鼠标在某个矩形内单击移动被认为是拖曳,该矩形的宽度 4
i = GetSystemMetrics(SM_CXEDGE);//SM_CXBORDER在3D外观下的值 2
i = GetSystemMetrics(SM_CXFIXEDFRAME);//具有title bar和固定border的窗体的border的宽度 3
i = GetSystemMetrics(SM_CXFOCUSBORDER);//DrawFocusRect画出的矩形的左右边框的 1
i = GetSystemMetrics(SM_CXFRAME);//与SM_CXSIZEFRAME相同 4
i = GetSystemMetrics(SM_CXFULLSCREEN);//客户区(工作区)的宽度 1280
i = GetSystemMetrics(SM_CXHSCROLL);//水平滚动条上箭头位图的宽度 17
i = GetSystemMetrics(SM_CXHTHUMB);//水平滚动条滑块的宽度 17
i = GetSystemMetrics(SM_CXICON);//图标的默认宽度,LoadIcon只能载入该宽度和SM_CYICON指定高度的icon 32
i = GetSystemMetrics(SM_CXICONSPACING);//icon view中各icon的所占矩形的宽度,大于等于SM_CXICON 75
i = GetSystemMetrics(SM_CXMAXIMIZED);//最大化顶级窗口的宽度 1288
i = GetSystemMetrics(SM_CXMAXTRACK);//一个具有title bar和sizable的窗口所能达到的最大宽度 1292
i = GetSystemMetrics(SM_CXMENUCHECK);//菜单上位图的宽度 13
i = GetSystemMetrics(SM_CXMENUSIZE);//菜单条按钮的宽度,例如多文档中ChildFrame(最大化时)右上角的关闭按钮 19
i = GetSystemMetrics(SM_CXMIN);//窗体的最小宽度 123
i = GetSystemMetrics(SM_CXMINIMIZED);//最小化窗体的宽度 160
i = GetSystemMetrics(SM_CXMINSPACING);//各个最小化窗体所占的矩形的宽度,大于等于SM_MINIMIZED 160
i = GetSystemMetrics(SM_CXMINTRACK);//窗口能拖拽的最小宽度 123
i = GetSystemMetrics(SM_CXSCREEN);//屏幕宽度 1280
i = GetSystemMetrics(SM_CXSIZE);//title bar上按钮的宽度 25
i = GetSystemMetrics(SM_CXSIZEFRAME);//sizable窗体的横向border的宽度 4
i = GetSystemMetrics(SM_CXSMICON);//推荐的小图标(如title bar上的和icon view中的)的宽度 16
i = GetSystemMetrics(SM_CXSMSIZE);//caption中图标的宽度 17
i = GetSystemMetrics(SM_CXVIRTUALSCREEN);//virutal screen的宽度 1280
i = GetSystemMetrics(SM_CXVSCROLL);//垂直滚动条的宽度 17
i = GetSystemMetrics(SM_CYBORDER);// 1
i = GetSystemMetrics(SM_CYCAPTION);// 26
i = GetSystemMetrics(SM_CYCURSOR);// 32
i = GetSystemMetrics(SM_CYDLGFRAME);// 3
i = GetSystemMetrics(SM_CYDOUBLECLK);// 4
i = GetSystemMetrics(SM_CYDRAG);// 4
i = GetSystemMetrics(SM_CYEDGE);// 2
i = GetSystemMetrics(SM_CYFIXEDFRAME);// 3
i = GetSystemMetrics(SM_CYFOCUSBORDER);// 1
i = GetSystemMetrics(SM_CYFRAME);// 4
i = GetSystemMetrics(SM_CYFULLSCREEN);// 744
i = GetSystemMetrics(SM_CYHSCROLL);// 17
i = GetSystemMetrics(SM_CYICON);// 32
i = GetSystemMetrics(SM_CYICONSPACING);// 75
i = GetSystemMetrics(SM_CYMAXIMIZED);// 778
i = GetSystemMetrics(SM_CYMAXTRACK);// 812
i = GetSystemMetrics(SM_CYMENU);// 20
i = GetSystemMetrics(SM_CYMENUCHECK);// 13
i = GetSystemMetrics(SM_CYMIN);// 34=4+4+26
i = GetSystemMetrics(SM_CYMINIMIZED);// 31
i = GetSystemMetrics(SM_CYMINSPACING);// 31
i = GetSystemMetrics(SM_CYMINTRACK);// 34
i = GetSystemMetrics(SM_CYSCREEN);// 800
i = GetSystemMetrics(SM_CYSIZE);// 25
i = GetSystemMetrics(SM_CYSIZEFRAME);// 4
i = GetSystemMetrics(SM_CYSMCAPTION);// 18
i = GetSystemMetrics(SM_CYSMICON);// 16
i = GetSystemMetrics(SM_CYSMSIZE);// 17
i = GetSystemMetrics(SM_CYVIRTUALSCREEN);// 800
i = GetSystemMetrics(SM_CYVSCROLL);// 17
i = GetSystemMetrics(SM_CYVTHUMB);// 17
CRect rect;
GetClientRect(&rect);
GetWindowRect(&rect);
AfxGetMainWnd()->GetWindowRect(&rect);
初始状态(高*宽):
516*948
520*952 520-516=4=2+2两边的view的SM_CYEDGE(2)的值,952-948同理
554*960 554-520=34=4+4+26CMainFrame的SM_CYFRAME(4)*2+SM_CYCATION(26),960-952同理
最大化后
740*1276
744*1280 SM_CYFULLSCREEN*SM_CXFULLSCREEN
778*1288(-4 774 -4 1284) SM_CYMAXIMIZED*SM_CXMAXIMIZED此时客户区(包括edge(2))充满除任务栏外的区域,CMainFrame的border(4)没有显示(已经在屏幕外),但是caption(26)显示,26+744=770,所以任务栏的高度为800-770=30
拖拽到最大后
774*1280
778*1284
812*1292 SM_CYMAXTRACK*SM_CXMAXTRACK