开发者

Maximized Window Restores to Full Screen

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.


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.

CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...
    // Obtain wndpl, maybe from registry
    AfxGetApp()->m_nCmdShow = wndpl.showCmd;
    wndpl.showCmd = SW_SHOW;
    SetWindowPlacement(&wndpl);
}

These two lines helps underlying code not to mess things up when calling ActivateFrame, which calls ShowWindow with parameter obtained from CWinApp::m_nCmdShow.


All information are in the file with extension .RC. I never used a Maximize/Restore procedures though you should look for a 'DIALOGEX' for the same window. You can change it using any editor (notepad, ultraedit etc.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜