如何设置最后一个窗口位置 [英] How to set the Last Window Position

查看:129
本文介绍了如何设置最后一个窗口位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在MFC应用程序(MDI)中工作,即使
,应用程序也无法保存状态
...

I am working in MFC Application(MDI), The Application is not saving the state even though

...

EnableLoadWindowPlacement(TRUE);


....

....
....


....
and
....
....

if (!ReloadWindowPlacement(pMainFrame))
    {
        pMainFrame->ShowWindow(m_nCmdShow);
        pMainFrame->UpdateWindow();
    }



...
另外,在CMYAppClass的InitInstance()中,我制作了
t



...
In InitInstance() of CMYAppClass, Also, I have made the
t

SetRegistryBase(_T(MyApp)

.
尽管有上述更改,应用程序仍未保留最后位置,
请向我更新相同的内容.

.
despite the above changes, the Application is not retaining the last positions ,
Please update me the same.

推荐答案

MSDN [ ^ ]说:
默认情况下,主机的大小和位置是从注册表中与其他应用程序设置一起加载的."
这意味着EnableLoadWindowPlacement(TRUE);是冗余的,因为它是默认选项.

它还说:
"[加载]在CWinAppEx :: LoadState期间发生."
这意味着您需要调用LoadState.因为没有提及ReloadWindowPlacement,所以暗示它们不兼容.


如果您随后阅读了 ReloadWindowPlacement [
您正在使用2种单独的方法进行保存和加载,这些方法似乎以单独的注册表位置/键或格式保存/加载数据.

选择1.
MSDN[^] says:
"By default, the size and location of the main frame is loaded from the registry together with other application settings."
This means that EnableLoadWindowPlacement(TRUE); is redundant as it is the default option.

It also says:
"[The load] occurs during CWinAppEx::LoadState."
The means you need to call LoadState. Because there is no mention of ReloadWindowPlacement it is implied that they are incompatible.


If you then read the page for ReloadWindowPlacement[^] it says:
"Use the function CWinAppEx::StoreWindowPlacement to write the size and location of a window to the registry."

You are using 2 separate methods to save and load, which seem to save/load the data in separate registry locations/keys or formats.

Pick 1.


这篇关于如何设置最后一个窗口位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆