From: Saint Atique on
Firstly, as I am novice my questions can be naive. Never mind.

What I want to do is:
# Check command line arguments
# If arguments provide enough information
then show the main window to perform some tasks

# If command line arguments are not sufficient then I need to show a
dialog box so that user can input missing informations, after dialog
box is done I will show the main window

Now inside ::InitInstance() how will I write to show the dialog box as
I cannot use m_pMainWnd as the dialog box is not my main frame window.

Please give me hint.

Or is it possible to show a dialogbox and then perform operations
using another dialogbox without having a mainwindow?

With trillions of advanced thanks.

-- Saint Atique,
Hobbyist MFC Programmer
From: David Ching on
"Saint Atique" <unix9n(a)gmail.com> wrote in message
news:6b86631d-c9eb-4746-9072-fd33c5195239(a)i28g2000yqa.googlegroups.com...
> Now inside ::InitInstance() how will I write to show the dialog box as
> I cannot use m_pMainWnd as the dialog box is not my main frame window.
>
> Please give me hint.
>

Use AppWizard to create a MFC EXE project which has a dialog as the main
window. Then
Use AppWizard to create a MFC EXE project which is SDI or MDI.

Examine the InitInstance() prduced for both projects. Copy and paste them
so that the dialog is first shown, then CMainFrame-based window.

-- David

From: Goran on
On Jun 25, 11:56 am, Saint Atique <uni...(a)gmail.com> wrote:
> Firstly, as I am novice my questions can be naive. Never mind.
>
> What I want to do is:
> # Check command line arguments
> # If arguments provide enough information
>             then show the main window to perform some tasks
>
> # If command line arguments are not sufficient then I need to show a
> dialog box so that user can input missing informations, after dialog
> box is done I will show the main window
>
> Now inside ::InitInstance() how will I write to show the dialog box as
> I cannot use m_pMainWnd as the dialog box is not my main frame window.
>
> Please give me hint.
>
> Or is it possible to show a dialogbox and then perform operations
> using another dialogbox without having a mainwindow?

AFAIK, yes, there's no problem whatsoever. You might want to set
m_pMainWnd to your dialog while you're running DoModal in
InitInstance, but I'd be surprised if that was really necessary.

Goran.
From: David Wilkinson on
Saint Atique wrote:
> Firstly, as I am novice my questions can be naive. Never mind.
>
> What I want to do is:
> # Check command line arguments
> # If arguments provide enough information
> then show the main window to perform some tasks
>
> # If command line arguments are not sufficient then I need to show a
> dialog box so that user can input missing informations, after dialog
> box is done I will show the main window

Just show the dialog before creating the main window.

CMyDialog dlg;
dlg.DoModal();

I do this in my applications, and I have never had any problem with it.

--
David Wilkinson
Visual C++ MVP
From: Joseph M. Newcomer on
See below...
On Fri, 25 Jun 2010 02:56:00 -0700 (PDT), Saint Atique <unix9n(a)gmail.com> wrote:

>Firstly, as I am novice my questions can be naive. Never mind.
>
>What I want to do is:
># Check command line arguments
># If arguments provide enough information
> then show the main window to perform some tasks
****
InitInstance will handle this
****
>
># If command line arguments are not sufficient then I need to show a
>dialog box so that user can input missing informations, after dialog
>box is done I will show the main window
****
Show the dialog, get the information, put it into the place where the parameters will be
found (I suggest a struct)

If the dialog is dismissed or cancelled, return FALSE from InitInstance
***
>
>Now inside ::InitInstance() how will I write to show the dialog box as
>I cannot use m_pMainWnd as the dialog box is not my main frame window.
****
Why would m_pMainWnd even come into the discussion? It has nothing to do with the
problem.

Note that InitInstance is not a global function as you indicate; it is a member of your
CWinApp-derived class, that is,it would be CMyApp::InitInstance, not ::InitInstance.
****
>
>Please give me hint.
>
>Or is it possible to show a dialogbox and then perform operations
>using another dialogbox without having a mainwindow?
****
It would depend on the CDialog code and whether or not it requires a main window.

If it requiresa a window, then after the main window is created, suppress the ShowWindow
call until you are ready to show the window.

Have you tried any of this?
joe
****
>
>With trillions of advanced thanks.
>
>-- Saint Atique,
>Hobbyist MFC Programmer
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm