Click here to Skip to main content
16,004,647 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am working in MFC Application(MDI), The Application is not saving the state even though

...
C++
EnableLoadWindowPlacement(TRUE);

....
and
....
....
C#
if (!ReloadWindowPlacement(pMainFrame))
    {
        pMainFrame->ShowWindow(m_nCmdShow);
        pMainFrame->UpdateWindow();
    }


...
In InitInstance() of CMYAppClass, Also, I have made the
t
C++
SetRegistryBase(_T(MyApp)
.
despite the above changes, the Application is not retaining the last positions ,
Please update me the same.
Posted

1 solution

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.
 
Share this answer
 
Comments
Vishal_K89 4-Mar-11 9:19am    
I am simulating the VS2008 Demo version, wherein, said application has been implemented, in
<< EnableLoadWindowPlacement(TRUE); >> and <<ReloadWindowPlacement>> in InitInstance() of DemoVersion, emulating the same, in my application could not be same,
In demo version of VS2008, had implemented, CMainFrame::OnClose() to restore the position of app. during the subsequent instance,
Pls., let me know the URL where I can make workaround for restoring the window placement after application exit.

Any help in this regard would be much appreciated.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900