Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Systray

Systray

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++learning
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    margis
    wrote on last edited by
    #1

    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.

    I P 2 Replies Last reply
    0
    • M margis

      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.

      I Offline
      I Offline
      Ivor S Sargoytchev
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • M margis

        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.

        P Offline
        P Offline
        Peak
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups