Hello,

I created an application with MFC's Doc/View structure on Pocket PC 2002. In
InitInstance of CWinApp derived Class, I putted code to show a Modal dialog
box before other initailization. If the user click OK, the program will
continue to run. Otherwise the InitInstance will returns FALSE to stop the
program.
The problem is that after the dialog box returns IDOK, the program is still
running, but the main window is hidden in background. Do I implement this in
wrong way? I can move this code to OnNewDocument of CMyDocument or somewhere
else. I am wondering why the main window will be hidden after a dialog box
displayed.

Thanks,

Shangwu

Re: Show a dialog box in InitInstance by Arvind

Arvind
Mon Oct 27 23:51:07 CST 2003

in INITINSTANCE call the dialog to display..


and from the initdialog of the corresponding dialog. do all the coding..

your problem will be fixed..

Thanks

Arvind

"Shangwu" <sqisoft@coxDOTnet> wrote in message
news:OD$jG7LnDHA.2272@tk2msftngp13.phx.gbl...
> Hello,
>
> I created an application with MFC's Doc/View structure on Pocket PC 2002.
In
> InitInstance of CWinApp derived Class, I putted code to show a Modal
dialog
> box before other initailization. If the user click OK, the program will
> continue to run. Otherwise the InitInstance will returns FALSE to stop the
> program.
> The problem is that after the dialog box returns IDOK, the program is
still
> running, but the main window is hidden in background. Do I implement this
in
> wrong way? I can move this code to OnNewDocument of CMyDocument or
somewhere
> else. I am wondering why the main window will be hidden after a dialog box
> displayed.
>
> Thanks,
>
> Shangwu
>
>



Re: Show a dialog box in InitInstance by Alexander

Alexander
Tue Oct 28 01:18:37 CST 2003


If main window is already created when the dialog is displayed, you should
assign it as dialog's owner. To do this, pass a pointe to main window object
to dialog's constructor.

If this is not the case, please show us some code.

--
Alexander Shargin
Microsoft MVP in Mobile Devices

mailto:alex@rsdn.ru
http://www.rsdn.ru - Russian Software Developer Network
http://www.pocketpcdn.com - Pocket PC Developer Network


"Shangwu" <sqisoft@coxDOTnet> wrote in message
news:OD$jG7LnDHA.2272@tk2msftngp13.phx.gbl...
> Hello,
>
> I created an application with MFC's Doc/View structure on Pocket PC 2002.
In
> InitInstance of CWinApp derived Class, I putted code to show a Modal
dialog
> box before other initailization. If the user click OK, the program will
> continue to run. Otherwise the InitInstance will returns FALSE to stop the
> program.
> The problem is that after the dialog box returns IDOK, the program is
still
> running, but the main window is hidden in background. Do I implement this
in
> wrong way? I can move this code to OnNewDocument of CMyDocument or
somewhere
> else. I am wondering why the main window will be hidden after a dialog box
> displayed.
>
> Thanks,
>
> Shangwu
>
>



Re: Show a dialog box in InitInstance by no-one

no-one
Tue Oct 28 07:07:02 CST 2003

On Tue, 28 Oct 2003 10:18:37 +0300, "Alexander Shargin" <alex@rsdn.ru>
wrote:

>
>If main window is already created when the dialog is displayed, you should
>assign it as dialog's owner.

I'm not sure about MFC, but I know that in standard Win32 programming,
the main window is usually created somewhere in InitInstance. If the
OP wants to use this dialog box as a means of aborting the program,
then he should make sure the dialog box appears before the main window
is created. If for some reason the main window is already created,
then the OP should use the handle to that window as the parent in the
dialog box call and, if he decides to abort, send a WM_CLOSE message
to the main window.


-Robert Scott
Ypsilanti, Michigan
(Reply through newsgroups, not by direct e-mail, as automatic reply address is fake.)


Re: Show a dialog box in InitInstance by Shangwu

Shangwu
Tue Oct 28 08:56:08 CST 2003

Thank you for your feedback.
Here is the sample code to show a dialog. The dialog class could be
anything.
===================================
BOOL CTdlgApp::InitInstance()
{
CDlg dlg;
dlg.m_bFullScreen = FALSE;
if (dlg.DoModal() != IDOK)
return FALSE;

SetRegistryKey(_T("Local AppWizard-Generated Applications"));

CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CTdlgDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CTdlgView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);

// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;

// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
=====================================

"Alexander Shargin" <alex@rsdn.ru> wrote in message
news:eKvY3OSnDHA.2268@TK2MSFTNGP12.phx.gbl...
>
> If main window is already created when the dialog is displayed, you should
> assign it as dialog's owner. To do this, pass a pointe to main window
object
> to dialog's constructor.
>
> If this is not the case, please show us some code.
>
> --
> Alexander Shargin
> Microsoft MVP in Mobile Devices
>
> mailto:alex@rsdn.ru
> http://www.rsdn.ru - Russian Software Developer Network
> http://www.pocketpcdn.com - Pocket PC Developer Network
>
>
> "Shangwu" <sqisoft@coxDOTnet> wrote in message
> news:OD$jG7LnDHA.2272@tk2msftngp13.phx.gbl...
> > Hello,
> >
> > I created an application with MFC's Doc/View structure on Pocket PC
2002.
> In
> > InitInstance of CWinApp derived Class, I putted code to show a Modal
> dialog
> > box before other initailization. If the user click OK, the program will
> > continue to run. Otherwise the InitInstance will returns FALSE to stop
the
> > program.
> > The problem is that after the dialog box returns IDOK, the program is
> still
> > running, but the main window is hidden in background. Do I implement
this
> in
> > wrong way? I can move this code to OnNewDocument of CMyDocument or
> somewhere
> > else. I am wondering why the main window will be hidden after a dialog
box
> > displayed.
> >
> > Thanks,
> >
> > Shangwu
> >
> >
>
>