views:

393

answers:

3

I'm writing an application in C++ that runs as a system tray icon. When the application initially starts up the main dialog loads up and takes focus, which isn't the behavior I intend it to have. Is there a way to load the system tray icon without having the main dialog load up?

+2  A: 

I'd say you have to separate your systray code and your window code, and only display the window when the systray is called. however you can always call

ShowWindow(SH_HIDE);

check http://www.codeguru.com/forum/showthread.php?t=231032

OneOfOne
+1  A: 

If you used the standard mfc project wizard, then the code that displays the dialog is in your applications's InitInstance method.

Just comment out the dlg.DoModal() and m_pMainWnd = &dlg; parts and you will be fine.

Note that you might have to code your own message loop otherwise your application will just exit after these changes.

Can
A: 

The usual way I do this is to create an invisible dialog-based application, and only show the window when the user interacts with your tray icon. For sample code on how to do this, see here.

Bob Moore