最大化窗口恢复全屏
使用 CWnd::ShowWindow(SW_SHOWMAXIMIZED) 可以按预期最大化我的应用程序窗口。
但是,当单击应用程序上的恢复按钮(或双击标题栏)时,恢复的大小与最大化窗口的大小相同,这会让用户感到困惑。
使用这个替代代码有同样的问题:
WINDOWPLACEMENT wndpl;
GetWindowPlacement(&wndpl);
wndpl.showCmd = SW_SHOWMAXIMIZED;
SetWindowPlacement(&wndpl);
如何在恢复时保持默认的非最大化大小。
Using CWnd::ShowWindow(SW_SHOWMAXIMIZED)
maximizes my app window as expected.
However, when clicking the restore button on the app (or double clicking the title-bar), the restored size is the same size as the maximized window, which is confusing for the user.
Using this alternative code has the same problem:
WINDOWPLACEMENT wndpl;
GetWindowPlacement(&wndpl);
wndpl.showCmd = SW_SHOWMAXIMIZED;
SetWindowPlacement(&wndpl);
How can I keep the default un-maximized size when restoring.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经解决了我的问题,该解决方案也可能会解决您的问题。我的问题是,即使我在 CMainFrame::OnCreate 中调用 SetWindowPlacement(&wndpl) ,如果窗口最大化,窗口也无法正确恢复。我在SetWindowPlacement之前添加了两行代码,现在它按预期工作了。
这两行有助于底层代码在调用 ActivateFrame 时不要搞乱事情,ActivateFrame 使用从 CWinApp::m_nCmdShow 获取的参数调用 ShowWindow。
I've solved my problem, and the solution might solve yours too. My problem was that even though I called SetWindowPlacement(&wndpl) within CMainFrame::OnCreate the window was not properly restored if it was maximized. I added two lines of code before SetWindowPlacement, and now it works as expected.
These two lines helps underlying code not to mess things up when calling ActivateFrame, which calls ShowWindow with parameter obtained from CWinApp::m_nCmdShow.