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. Starting a program hidden (Tray Icon)

Starting a program hidden (Tray Icon)

Scheduled Pinned Locked Moved C / C++ / MFC
helpadobetutorial
6 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.
  • B Offline
    B Offline
    Bret Faller
    wrote on last edited by
    #1

    I am developing a program that resides in the system tray and want it to start hidden. But, I am having a slight problem. I know how to start with the main window hidden, that's the easy part. The part that I'm having trouble with is that when I start the program you can see the main window flash for a split second. I've tried removing WS_VISIBLE from the mainframe, SW_HIDE on m_pMainWnd in theApp class, adding WS_ICONIC to the mainframe style, but no go. Any help on this is greatly appreciated. Bret Faller Odyssey Computing, Inc.

    L F B 3 Replies Last reply
    0
    • B Bret Faller

      I am developing a program that resides in the system tray and want it to start hidden. But, I am having a slight problem. I know how to start with the main window hidden, that's the easy part. The part that I'm having trouble with is that when I start the program you can see the main window flash for a split second. I've tried removing WS_VISIBLE from the mainframe, SW_HIDE on m_pMainWnd in theApp class, adding WS_ICONIC to the mainframe style, but no go. Any help on this is greatly appreciated. Bret Faller Odyssey Computing, Inc.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      try to resize the window to zero by using the method call MoveWindow(...) Good luck.

      1 Reply Last reply
      0
      • B Bret Faller

        I am developing a program that resides in the system tray and want it to start hidden. But, I am having a slight problem. I know how to start with the main window hidden, that's the easy part. The part that I'm having trouble with is that when I start the program you can see the main window flash for a split second. I've tried removing WS_VISIBLE from the mainframe, SW_HIDE on m_pMainWnd in theApp class, adding WS_ICONIC to the mainframe style, but no go. Any help on this is greatly appreciated. Bret Faller Odyssey Computing, Inc.

        F Offline
        F Offline
        Frank Deo
        wrote on last edited by
        #3

        This is a wierd situation, and the solution is even wierder. I had to do this in an app a while ago and it took me a while to solve it. Change this: m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); To this: m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); And add this: m_nCmdShow = SW_HIDE; Right before you register your doc templates. Hope this helps, Frank

        B 1 Reply Last reply
        0
        • F Frank Deo

          This is a wierd situation, and the solution is even wierder. I had to do this in an app a while ago and it took me a while to solve it. Change this: m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); To this: m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); And add this: m_nCmdShow = SW_HIDE; Right before you register your doc templates. Hope this helps, Frank

          B Offline
          B Offline
          Bret Faller
          wrote on last edited by
          #4

          Thanks for the info. It surprisingly worked, somewhat. It does start hidden but when the listview refreshes the first time (2-3sec after startup) it flashes on screen. I don't see why the m_nCmdShow is any different than just passing it a simple SW_HIDE but it works better. Thanks. Bret Faller Odyssey Computing, Inc.

          1 Reply Last reply
          0
          • B Bret Faller

            I am developing a program that resides in the system tray and want it to start hidden. But, I am having a slight problem. I know how to start with the main window hidden, that's the easy part. The part that I'm having trouble with is that when I start the program you can see the main window flash for a split second. I've tried removing WS_VISIBLE from the mainframe, SW_HIDE on m_pMainWnd in theApp class, adding WS_ICONIC to the mainframe style, but no go. Any help on this is greatly appreciated. Bret Faller Odyssey Computing, Inc.

            B Offline
            B Offline
            Bret Faller
            wrote on last edited by
            #5

            Ok, after further analysis I've discovered the problem. After the view refreshes I have a function called ProcessReminders() and in it if a reminder has the dialog option set that means show the window. I call showwindow on the mainframe ((CMainFrame*)AfxGetMainWnd()) and pass it SW_SHOW which causes it to be shown but then the app hides it do to the SW_HIDE value of m_nCmdShow. If I comment out the showwindow line everything starts up how I want it to, but if a reminder is set to show the window I need it to show. Bret Faller Odyssey Computing, Inc.

            F 1 Reply Last reply
            0
            • B Bret Faller

              Ok, after further analysis I've discovered the problem. After the view refreshes I have a function called ProcessReminders() and in it if a reminder has the dialog option set that means show the window. I call showwindow on the mainframe ((CMainFrame*)AfxGetMainWnd()) and pass it SW_SHOW which causes it to be shown but then the app hides it do to the SW_HIDE value of m_nCmdShow. If I comment out the showwindow line everything starts up how I want it to, but if a reminder is set to show the window I need it to show. Bret Faller Odyssey Computing, Inc.

              F Offline
              F Offline
              Frank Deo
              wrote on last edited by
              #6

              Cool...glad you got it working the way you wanted. Cheers! Frank

              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