Start selection dialog before the application starts ... 
Author Message
 Start selection dialog before the application starts ...

I would like to start a dialog where the user can choose what he or she
wants to do, before the application itself is "fully" started (e.g. no empty
document is already opened).

It should look similar to what applications like Microsoft Access or
InstallShield Express do. After starting these applications, they let you
choose whether you want to start from scratch, open an existing document or
start some wizard to perform certain tasks. I would like to add similar
functionality to my application.

The question(s) are: where would I best call such a dialog, so that I may
for example automatically open an example file or start some wizard based on
a new file?Which event should I handle in which class (CMainFrm, CApp, ...)
or which virtual method should I overwrite (I have a single document
application).

Many thanks in advance for any additonal help

Helmut (Lorek)



Sun, 09 May 2004 21:30:18 GMT  
 Start selection dialog before the application starts ...
    You need to do this in the InitInstance() member function of your App
class, before creating the doc/view framework.

Somewhere along the lines of

        CYourDialog dlg;

        switch ( dlg.DoModal() )
        {
            case IDOK:
                                // Store OK related info in the App class
for later use by the docuement and views.
                            break;

            case IDCANCEL:
                                // Store CANCEL related info in the App
class for later use by the docuement and views.
                            break;
        }

        CSingleDocTemplate* pDocTemplate;
        pDocTemplate = new
ngleDocTemplate(
                    IDR_MAINFRAME,
                    RUNTIME_CLASS(CYourDoc),
                    RUNTIME_CLASS(CMainFrame),       // main SDI frame window
                    RUNTIME_CLASS(CYourView));

        AddDocTemplate(pDocTemplate);
        .............................
        .............................
        .............................

        HTH

Cheers
Check Abdoul
-------------------

Quote:

> I would like to start a dialog where the user can choose what he or she
> wants to do, before the application itself is "fully" started (e.g. no empty
> document is already opened).

> It should look similar to what applications like Microsoft Access or
> InstallShield Express do. After starting these applications, they let you
> choose whether you want to start from scratch, open an existing document or
> start some wizard to perform certain tasks. I would like to add similar
> functionality to my application.

> The question(s) are: where would I best call such a dialog, so that I may
> for example automatically open an example file or start some wizard based on
> a new file?Which event should I handle in which class (CMainFrm, CApp, ...)
> or which virtual method should I overwrite (I have a s
ingle document
> application).

> Many thanks in advance for any additonal help

> Helmut (Lorek)



Sun, 09 May 2004 22:38:13 GMT  
 Start selection dialog before the application starts ...
Contrary to what CheckAbdoul suggests, I would not display a dialog in the
InitInstance.  Instead, modify the code at the end of InitInstance to be similar
to this:

// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo ;
ParseCommandLine( cmdInfo ) ;

if ( cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew )
    cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing ;
// Dispatch commands specified on the command line
if ( ProcessShellCommand( cmdInfo ) )
{
    pMainFrame->ShowWindow( m_nCmdShow ) ;
    pMainFrame->UpdateWindow() ;
[etc.]

The change to CCommandLineInfo::FileNothing will prevent a blank document from
being opened automatically.

Then, in your CMainFrame class's OnCreate, use PostMessage to post a custom
message to itself:

#define WMP_DISPLAY_INITIAL_DIALOG  (WM_APP+1)

BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
    //{{AFX_MSG_MAP(CMainFrame)
    ON_WM_CREATE()
    //}}AFX_MSG_MAP
    ON_MESSAGE(WMP_DISPLAY_INITIAL_DIALOG, OnDisplayInitialDialog)
END_MESSAGE_MAP()

LRESULT CMainFrame::OnDisplayInitialDialog( WPARAM, LPARAM )
{
[etc.]

The ID of the message and name of the function are entirely up to you, but it
gives you the idea.



Mon, 10 May 2004 01:53:14 GMT  
 Start selection dialog before the application starts ...
Maybe I understood something wrong in your mail. But if I include the
following two lines

Quote:
> if ( cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew )
>     cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing ;

than I get an assertion in

BOOL CWnd::ShowWindow(int nCmdShow)
{
 ASSERT(::IsWindow(m_hWnd));

 if (m_pCtrlSite == NULL)
  return ::ShowWindow(m_hWnd, nCmdShow);
 else
  return m_pCtrlSite->ShowWindow(nCmdShow);

Quote:
}

Any idea what I missed, or is it because I use a single document
application?

Helmut



Quote:
> Contrary to what CheckAbdoul suggests, I would not display a dialog in the
> InitInstance.  Instead, modify the code at the end of InitInstance to be
similar
> to this:

> // Parse command line for standard shell commands, DDE, file open
> CCommandLineInfo cmdInfo ;
> ParseCommandLine( cmdInfo ) ;

> if ( cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew )
>     cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing ;
> // Dispatch commands specified on the command line
> if ( ProcessShellCommand( cmdInfo ) )
> {
>     pMainFrame->ShowWindow( m_nCmdShow ) ;
>     pMainFrame->UpdateWindow() ;
> [etc.]

> The change to CCommandLineInfo::FileNothing will prevent a blank document
from
> being opened automatically.

> Then, in your CMainFrame class's OnCreate, use PostMessage to post a
custom
> message to itself:

> #define WMP_DISPLAY_INITIAL_DIALOG  (WM_APP+1)

> BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
>     //{{AFX_MSG_MAP(CMainFrame)
>     ON_WM_CREATE()
>     //}}AFX_MSG_MAP
>     ON_MESSAGE(WMP_DISPLAY_INITIAL_DIALOG, OnDisplayInitialDialog)
> END_MESSAGE_MAP()

> LRESULT CMainFrame::OnDisplayInitialDialog( WPARAM, LPARAM )
> {
> [etc.]

> The ID of the message and name of the function are entirely up to you, but
it
> gives you the idea.



Mon, 10 May 2004 02:32:47 GMT  
 Start selection dialog before the application starts ...
Yes, it is because SDI always expects to open a document.  Sorry that I didn't
think about that.  I almost always use MDI.  If you really need to stay with
SDI, then do not use my method.


Thu, 13 May 2004 08:43:09 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Start a dialog based application minimized

2. Starting a Dialog based application (MFC)

3. Starting dialog based application minimised

4. Starting application from my application

5. How to Modify a Commercial Windows Application to Start an other Application

6. start application within an application

7. how to minimize program started with Process.Start

8. Starting a CMD and making sure it is not started twice

9. Start/no start app using command line?

10. Start App when Windows starts

11. App not starting in start in dir.

12. HOWTO: hide dialog when a dialog-based app starts

 

 
Powered by phpBB® Forum Software