Systray
-
Hello ! I am trying to develop a systray application using MFC. NOTE: I am beginner. I performed that application sucessfully, therefore, when I run the program I can see the icon on the systray, but, I also see the dialog window open as well. When the program runs the following lines: CTrayIco dlg; m_pMainWnd = &dlg; int nResponse = dlg.Modal(); the dialog windows appears, and I don't want to show it. I tried to delete these lines, but, the program didn`t run fine. I would like to put the icon on the systray as soon as I run the program without any dialog window. How can I do that ? Thanks in advance.
-
Hello ! I am trying to develop a systray application using MFC. NOTE: I am beginner. I performed that application sucessfully, therefore, when I run the program I can see the icon on the systray, but, I also see the dialog window open as well. When the program runs the following lines: CTrayIco dlg; m_pMainWnd = &dlg; int nResponse = dlg.Modal(); the dialog windows appears, and I don't want to show it. I tried to delete these lines, but, the program didn`t run fine. I would like to put the icon on the systray as soon as I run the program without any dialog window. How can I do that ? Thanks in advance.
Yes, I am assuming that these lines of code are in you InitInstance() function. You see the CWinApp class has a m_pMainWnd member which needs to be set to point to a window class, so messages can be pumped to it. If this member is NULL the CWinApp class receives a WM_QUIT message and terminates. So, you need a main window of some sort which should exist for the lifetime of your application. If you don't want to see it just create a window without the WS_VISIBLE flag set. But you must have some window and set the CWinApp::m_pMainWnd to point to it.
-
Hello ! I am trying to develop a systray application using MFC. NOTE: I am beginner. I performed that application sucessfully, therefore, when I run the program I can see the icon on the systray, but, I also see the dialog window open as well. When the program runs the following lines: CTrayIco dlg; m_pMainWnd = &dlg; int nResponse = dlg.Modal(); the dialog windows appears, and I don't want to show it. I tried to delete these lines, but, the program didn`t run fine. I would like to put the icon on the systray as soon as I run the program without any dialog window. How can I do that ? Thanks in advance.
you need to start your MFC modal dialog program with a hidden dialog, and the only way I found for this problem was to call ShowWindow(m_hWnd, SW_HIDE) in one of WM_NCPAINT or WM_PAINT message handlers. There is another way for this problem, but needs a little more modification of your program. The normal way would be to uncheck WS_VISIBLE style in resource editor, and start you dialog using CreateDialog , then make a message loop there by calling AfxPumpMessage in a loop like this: CMyDlg mydlg; mydlg.Create(IDD_MYDIALOG);// that IDD_MYDIALOG is // the dialog resource id, // you can find it in your // dialog class definition // (TrayIco.h as you said) // in a line like this: // enum { IDD = IDD_MYDIALOG }; // if you wanted to show dialog window // ShowWindow(m_hWnd, SW_SHOW); while(AfxPumpMessage()); // loop till the QUIT // message comes.