visual-studio 如何使用 MFC 创建全屏窗口?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1832835/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create full screen window with MFC?
提问by Jim
I want to create full screen topmost (screen saver) window with MFC? How to create such full screen window in MFC? I tried to create win32 application and i am able to create fullscreen top most window but i want to create using MFC so later i can put different MFC controls on that window?
我想用 MFC 创建全屏最顶层(屏幕保护程序)窗口?如何在 MFC 中创建这样的全屏窗口?我试图创建 win32 应用程序,我能够创建全屏最顶部的窗口,但我想使用 MFC 创建以便稍后我可以在该窗口上放置不同的 MFC 控件?
Please help me.
请帮我。
Thanks, Jim.
谢谢,吉姆。
采纳答案by Jon Seigel
You should be able to adapt the example code here to do what you want:
您应该能够修改此处的示例代码以执行您想要的操作:
回答by Mark Ransom
I do it with a Dialog Box app. In the resource editor properties for the dialog resource, set Border=None and Title Bar=False to eliminate all border elements. In OnInitDialog, use the following to resize the dialog to the entire desktop:
我用一个对话框应用程序来做到这一点。在对话框资源的资源编辑器属性中,设置 Border=None 和 Title Bar=False 以消除所有边框元素。在 OnInitDialog 中,使用以下命令将对话框的大小调整为整个桌面:
CRect rcDesktop;
rcDesktop.left = GetSystemMetrics(SM_XVIRTUALSCREEN);
rcDesktop.right = rcDesktop.left + GetSystemMetrics(SM_CXVIRTUALSCREEN);
rcDesktop.top = GetSystemMetrics(SM_YVIRTUALSCREEN);
rcDesktop.bottom = rcDesktop.top + GetSystemMetrics(SM_CYVIRTUALSCREEN);
MoveWindow(rcDesktop, FALSE);
This code works on multiple monitors, unlike maximizing the window.
与最大化窗口不同,此代码适用于多个监视器。
No need to worry about making the window topmost, Windows will display it on a dedicated desktop with no other windows present.
无需担心将窗口置于最上方,Windows 会将其显示在没有其他窗口的专用桌面上。
回答by djeidot
I think removing the border from the dialog resource and showing the window as maximized (ShowWindow(SW_SHOWMAXIMIZED)) should do the job.
我认为从对话框资源中删除边框并将窗口显示为最大化 ( ShowWindow(SW_SHOWMAXIMIZED)) 应该可以完成这项工作。
As for topmost use the System Modalstyle in the dialog resource.
至于 topmost 使用对话框资源中的System Modal样式。

