Help: Starting MFC app with its window hidden 
Author Message
 Help: Starting MFC app with its window hidden

Hi!

I'm trying to have my MFC dialog-based application start with its main
window hidden, but I can't seem to figure out how to do it.  Can anyone give
me a few pointers?

Thanks!



Sun, 21 Nov 2004 21:08:18 GMT  
 Help: Starting MFC app with its window hidden


Wed, 18 Jun 1902 08:00:00 GMT  
 Help: Starting MFC app with its window hidden

Steps to hide a dialog based app..

example..consider your app name is Test1....
CTest1App     Test1.cpp and Test1.h
CTest1Dlg      Test1Dlg.cpp and Test1Dlg.h

1. "uncheck" the Dialog properties visible checkbox
2. add #include "test1dlg.h" in the Test1.h
3. add CTest1Dlg  *m_pDlg; as a member variable to CTest1App class.
4. delete the CTest1Dlg dlg line in InitInstance of Test1App.cpp
5. your InitInstance method should look like this....and add the
ExitInstance method also

////////////////////////////////////////////////////////////////////////////
/
// CTest1App initialization
BOOL CTest1App::InitInstance()
{
 AfxEnableControlContainer();

#ifdef _AFXDLL
 Enable3dControls();   // Call this when using MFC in a shared DLL
#else
 Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

 m_pDlg = new CTest1Dlg;

 m_pMainWnd = m_pDlg;

 m_pDlg->Create(IDD_TEST1_DIALOG);
 m_pDlg->ShowWindow (SW_HIDE);

 return TRUE;

Quote:
}

int CTest1App::ExitInstance()
{
 delete m_pDlg;
 return CWinApp::ExitInstance();

Quote:
}

It should work...

cheers
Ekkoratha


Quote:
> Hi!

> I'm trying to have my MFC dialog-based application start with its main
> window hidden, but I can't seem to figure out how to do it.  Can anyone
give
> me a few pointers?

> Thanks!



Mon, 22 Nov 2004 02:02:32 GMT  
 Help: Starting MFC app with its window hidden


Wed, 18 Jun 1902 08:00:00 GMT  
 Help: Starting MFC app with its window hidden
PostMessage a user-defined message and respond to it by hiding the window.

Note: if you want to eliminate the flash, in OnInitDialog, position the window off-screen,
then after you hide it, reposition it to be on-screen so when it becomes visible it is
actually seeable.
                                joe

Quote:

>Hi!

>I'm trying to have my MFC dialog-based application start with its main
>window hidden, but I can't seem to figure out how to do it.  Can anyone give
>me a few pointers?

>Thanks!

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Mon, 22 Nov 2004 00:59:30 GMT  
 Help: Starting MFC app with its window hidden


Wed, 18 Jun 1902 08:00:00 GMT  
 Help: Starting MFC app with its window hidden
Other than the fact that m_pMainWnd is not set, which has other {*filter*} implications...
                        joe

Quote:

>Steps to hide a dialog based app..

>example..consider your app name is Test1....
>CTest1App     Test1.cpp and Test1.h
>CTest1Dlg      Test1Dlg.cpp and Test1Dlg.h

>1. "uncheck" the Dialog properties visible checkbox
>2. add #include "test1dlg.h" in the Test1.h
>3. add CTest1Dlg  *m_pDlg; as a member variable to CTest1App class.
>4. delete the CTest1Dlg dlg line in InitInstance of Test1App.cpp
>5. your InitInstance method should look like this....and add the
>ExitInstance method also

>////////////////////////////////////////////////////////////////////////////
>/
>// CTest1App initialization
>BOOL CTest1App::InitInstance()
>{
> AfxEnableControlContainer();

>#ifdef _AFXDLL
> Enable3dControls();   // Call this when using MFC in a shared DLL
>#else
> Enable3dControlsStatic(); // Call this when linking to MFC statically
>#endif

> m_pDlg = new CTest1Dlg;

> m_pMainWnd = m_pDlg;

> m_pDlg->Create(IDD_TEST1_DIALOG);
> m_pDlg->ShowWindow (SW_HIDE);

> return TRUE;
>}

>int CTest1App::ExitInstance()
>{
> delete m_pDlg;
> return CWinApp::ExitInstance();
>}

>It should work...

>cheers
>Ekkoratha



>> Hi!

>> I'm trying to have my MFC dialog-based application start with its main
>> window hidden, but I can't seem to figure out how to do it.  Can anyone
>give
>> me a few pointers?

>> Thanks!

Joseph M. Newcomer [MVP]

Web: http://www.*-*-*.com/ ~newcomer
MVP Tips: http://www.*-*-*.com/ ~newcomer/mvp_tips.htm


Mon, 22 Nov 2004 01:10:58 GMT  
 Help: Starting MFC app with its window hidden
Take a look at this: http://www.mooremvp.freeserve.co.uk/Win32/w32tip26.htm

--
Ajay Kalra [MVP - VC++]


Quote:
> Hi!

> I'm trying to have my MFC dialog-based application start with its main
> window hidden, but I can't seem to figure out how to do it.  Can anyone
give
> me a few pointers?

> Thanks!



Mon, 22 Nov 2004 06:07:13 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Starting app with hidden window

2. Starting Doc/View app with hidden window

3. Starting app with hidden window

4. MFC: Starting an app as a CHILD Window?

5. dialog based mfc app that starts without showing the main window

6. Start App when Windows starts

7. Can I start my SDI app hidden?

8. How to Start Dialog App Hidden?

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

10. Q: Start App hidden

11. ? Start a Doc/view App as Hidden ?

12. Can I start a dialog app initially hidden?

 

 
Powered by phpBB® Forum Software