
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.