From: bernd on
Hi,

how is it possible to start the programm / sdi-application with the
last-open document (with all its configurations e.g. which checkbox is
checked and which is not) ?


best regards
Bernd
From: David Lowndes on
>how is it possible to start the programm / sdi-application with the
>last-open document (with all its configurations e.g. which checkbox is
>checked and which is not) ?

You inevitably have to save all that information and make use of it on
startup.

I've not used it myself, but maybe the restart manager support in the
latest version of MFC (VS2010) may be of interest to you if you're
trying to handle restart after a crash situation.

Dave
From: Joseph M. Newcomer on
I find this is most easily done by storing the state in the Registry. When the program
starts up, you check the Registry, and locate the file name that was saved. If this file
is still in existence, you would read the rest of the settings, then open that file for
your document. Most of this would happen in OnOpenDocument.
joe

On Mon, 17 May 2010 07:11:00 -0700 (PDT), bernd <bernd.schuster12(a)googlemail.com> wrote:

>Hi,
>
>how is it possible to start the programm / sdi-application with the
>last-open document (with all its configurations e.g. which checkbox is
>checked and which is not) ?
>
>
>best regards
>Bernd
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: DanB on
bernd wrote:
> Hi,
>
> how is it possible to start the programm / sdi-application with the
> last-open document (with all its configurations e.g. which checkbox is
> checked and which is not) ?
>

Are you running with an MRU? I do this in InitInstance:

if( cmdInfo.m_nShellCommand == cmdInfo.FileOpen )
OpenDocumentFile( cmdInfo.m_strFileName );

else if( oProfile.bOpenLastProject &&
(*m_pRecentFileList)[0].GetLength() > 0 )
OnOpenRecentFile( ID_FILE_MRU_FIRST );

In my case I have an app level configuration previously loaded, (oProfile).

i.e., I have global settings that encompass all projects/(documents) and
the project/(document) settings. If you are going to grow this app you
may want to think that way and use xml files to store info. I'm sure you
would be setting conditions at both a global and project level as you go
along.

I have only two registry entries, the path to the program folder and the
path to the user, (global settings), folder.

Best, Dan.

From: Goran on
On May 17, 8:49 pm, bernd <bernd.schuste...(a)googlemail.com> wrote:
> Storing the data in the registry will be done in the Initinstance()
> function:
> SetRegistryKey(_T("Local AppWizard-Generated Applications"));

You should put your organization name there (see how HKEY_CURRENT_USER
\Software is organized). If you do SetRegistryKey(_T("MyOrg")) and
your program is called "MyProg", your most recent file list will be
stored by MFC into HKEY_CURRENT_USER\Software\MyOrg\MyProg. After you
call LoadStdProfileSettings, you can do e.g.:

if (m_pRecentFileList && m_pRecentFileList->GetSize()>0)
{
cmdInfo.m_nShellCommand=CCommandLineInfo::FileOpen;
cmdInfo.m_strFileName=(*m_pRecentFileList)[0];
}

and let MFC do the rest. In other words, you can simply modify cmdInfo
before going to ProcessShellCommand and that's it.

Goran.