From: Jeova Almeida on
Hello,

I have an application that will run in background and won't show a window.

I have a dialog, which I use to perform the actions my app needs to do.

I've tested my app with the wizard generated InitInstance() method:

BOOL CMyApp::InitInstance()
{
CWinAppEx::InitInstance();
SetRegistryKey(_T("MyCompany"));

CMyDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}

return FALSE;
}

Now I need to stop showing the main window, and the code above shows the
dialog modally. How I can do it? Can I show the CDialog derived class object
hidden? I think that would solve the problem.

After the line
m_pMainWnd = &dlg;
I tried
dlg.ShowWindow(SW_HIDE);

But I got ASSERT errors.


From: Scott McPhillips [MVP] on
Change the dialog to modeless. To do that call Create in the dialog's
constructor. Then your InitInstance should do this:

m_pMainWnd = new CMyDlg();
return TRUE;

--
Scott McPhillips [VC++ MVP]

"Jeova Almeida" <jeovaalmeida(a)yahoo.com> wrote in message
news:%23iQxCJYUJHA.4372(a)TK2MSFTNGP04.phx.gbl...
> Hello,
>
> I have an application that will run in background and won't show a window.
>
> I have a dialog, which I use to perform the actions my app needs to do.
>
> I've tested my app with the wizard generated InitInstance() method:
>
> BOOL CMyApp::InitInstance()
> {
> CWinAppEx::InitInstance();
> SetRegistryKey(_T("MyCompany"));
>
> CMyDlg dlg;
> m_pMainWnd = &dlg;
> INT_PTR nResponse = dlg.DoModal();
> if (nResponse == IDOK)
> {
> // TODO: Place code here to handle when the dialog is
> // dismissed with OK
> }
> else if (nResponse == IDCANCEL)
> {
> // TODO: Place code here to handle when the dialog is
> // dismissed with Cancel
> }
>
> return FALSE;
> }
>
> Now I need to stop showing the main window, and the code above shows the
> dialog modally. How I can do it? Can I show the CDialog derived class
> object hidden? I think that would solve the problem.
>
> After the line
> m_pMainWnd = &dlg;
> I tried
> dlg.ShowWindow(SW_HIDE);
>
> But I got ASSERT errors.
>
>


From: Jeova Almeida on
It worked.
Thanks a lot Scott.

"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> escreveu na mensagem
news:efzhi1YUJHA.5920(a)TK2MSFTNGP06.phx.gbl...
> Change the dialog to modeless. To do that call Create in the dialog's
> constructor. Then your InitInstance should do this:
>
> m_pMainWnd = new CMyDlg();
> return TRUE;
>
> --
> Scott McPhillips [VC++ MVP]
>
> "Jeova Almeida" <jeovaalmeida(a)yahoo.com> wrote in message
> news:%23iQxCJYUJHA.4372(a)TK2MSFTNGP04.phx.gbl...
>> Hello,
>>
>> I have an application that will run in background and won't show a
>> window.
>>
>> I have a dialog, which I use to perform the actions my app needs to do.
>>
>> I've tested my app with the wizard generated InitInstance() method:
>>
>> BOOL CMyApp::InitInstance()
>> {
>> CWinAppEx::InitInstance();
>> SetRegistryKey(_T("MyCompany"));
>>
>> CMyDlg dlg;
>> m_pMainWnd = &dlg;
>> INT_PTR nResponse = dlg.DoModal();
>> if (nResponse == IDOK)
>> {
>> // TODO: Place code here to handle when the dialog is
>> // dismissed with OK
>> }
>> else if (nResponse == IDCANCEL)
>> {
>> // TODO: Place code here to handle when the dialog is
>> // dismissed with Cancel
>> }
>>
>> return FALSE;
>> }
>>
>> Now I need to stop showing the main window, and the code above shows the
>> dialog modally. How I can do it? Can I show the CDialog derived class
>> object hidden? I think that would solve the problem.
>>
>> After the line
>> m_pMainWnd = &dlg;
>> I tried
>> dlg.ShowWindow(SW_HIDE);
>>
>> But I got ASSERT errors.
>>
>>
>
>