Board index » Visual Studio » hidden dialog

hidden dialog

Visual Studio253
Hi,



I am working on an MFC application created by the app wizard as a dialog

application. I have put a tray icon down in the system tray and I would

like the main dialog to only appear based on interaction with the tray icon.

I need the dialog to be created and running, but not to show itself at all

(not even flash, preferably). In CMainApp::InitInstance(), it creates the

dialog and calls dlg.DoModal() - surely there's got to be a way to start the

dialog invisibly, no?



Thanks in advance!

Chris


-
 

Re:hidden dialog

Look at Shell_NotifyIcon().



"Chris Ellis" <chriseAtStompsoftDotCom>wrote in message

Quote
Hi,



I am working on an MFC application created by the app wizard as a

dialog

application. I have put a tray icon down in the system tray and I would

like the main dialog to only appear based on interaction with the tray

icon.

I need the dialog to be created and running, but not to show itself at all

(not even flash, preferably). In CMainApp::InitInstance(), it creates the

dialog and calls dlg.DoModal() - surely there's got to be a way to start

the

dialog invisibly, no?



Thanks in advance!

Chris









-

Re:hidden dialog

I'm using Shell_NotifyIcon. I've got the tray icon working fine. The

problem is that I want the tray icon to be the only thing that starts (from

the user's perspective), but the tray icon needs a window with which to

interface. That window is my main dialog. So I need the main dialog to

start first, but not to show itself. Currently, CMainApp::InitInstance()

ends with:



INT_PTR nResponse = dlg.DoModal();



The system tray icon is actually set up from within the OnInitDialog()

function in the dialog. So I need the dialog to be created and initialized,

and then go into its message loop without ever becoming visible. Is there

some combination of method calls and/or flags that can produce that effect?



Thanks,

Chris



"David Crow [MCSD]" <david.no.spam.crow@pbsnow.no.spam.com>wrote in message

Quote
Look at Shell_NotifyIcon().



"Chris Ellis" <chriseAtStompsoftDotCom>wrote in message

news:euInxp9UEHA.1164@tk2msftngp13.phx.gbl...

>Hi,

>

>I am working on an MFC application created by the app wizard as a

dialog

>application. I have put a tray icon down in the system tray and I would

>like the main dialog to only appear based on interaction with the tray

icon.

>I need the dialog to be created and running, but not to show itself at

all

>(not even flash, preferably). In CMainApp::InitInstance(), it creates

the

>dialog and calls dlg.DoModal() - surely there's got to be a way to start

the

>dialog invisibly, no?

>

>Thanks in advance!

>Chris

>

>









-

Re:hidden dialog

Actually, I figured it out by tinkering around. Please let me know if I'm

doing a major MFC No-No, otherwise I will assume that I have stumbled onto

the solution.



In CMainApp::InitInstance() I am now using the Create() method of the

dialog, as opposed to the DoModal() method. I am then returning TRUE from

the InitInstance() method to tell the application that I want it to enter

its own message pump. I moved cleanup code from directly after the call to

DoModal() to the CMainApp::ExitInstance() method. And I turned off the

Visible flag in the main dialog. It is now created and begins its message

pump without ever being visible. Everything seems to work exactly as

expected.





"David Crow [MCSD]" <david.no.spam.crow@pbsnow.no.spam.com>wrote in message

Quote
Look at Shell_NotifyIcon().



"Chris Ellis" <chriseAtStompsoftDotCom>wrote in message

news:euInxp9UEHA.1164@tk2msftngp13.phx.gbl...

>Hi,

>

>I am working on an MFC application created by the app wizard as a

dialog

>application. I have put a tray icon down in the system tray and I would

>like the main dialog to only appear based on interaction with the tray

icon.

>I need the dialog to be created and running, but not to show itself at

all

>(not even flash, preferably). In CMainApp::InitInstance(), it creates

the

>dialog and calls dlg.DoModal() - surely there's got to be a way to start

the

>dialog invisibly, no?

>

>Thanks in advance!

>Chris

>

>









-