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. Opening a running process programmatically

Opening a running process programmatically

Scheduled Pinned Locked Moved C / C++ / MFC
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.
  • L Offline
    L Offline
    lctrncs
    wrote on last edited by
    #1

    I am a beginner who wants to restore the main window of a clock program that resides in the System Tray when running. What I want to do programatically is done normally by right clicking on the clock program's icon in the System Tray, then selecting "Restore Main Window" from the context menu. I have tried many things, and the closest I can get is using SetForegroundWindow, which will only work when I have already selected "Restore Main Window" from the context menu and then minimized the restored main window. I think I must be missing some fundamental concept about what I am trying to do. Consider the pseudocode below... void MyApp::OnLaunchSysTrayApp { CWnd*m_hWnd = FindWindow(NULL, "System Tray Application Name") if (m_hWnd) { m_hWnd->SetForegroundWindow(); //Displays restored main window if not on top //m_hWnd->GetWindow(NULL); //Fails //m_hWnd->ShowWindow(SW_RESTORE); //Fails //m_hWnd->SetActiveWindow(); //Fails BOOL m_bIconic; m_bIconic=m_hWnd->IsIconic() if (m_bIconic) { //m_hWnd->GetWindow(NULL); //Fails //m_hWnd->ShowWindow(SW_RESTORE); //Fails //m_hWnd->SetActiveWindow(); //Fails } etc. } } I would appreciate any suggestions about how I might achieve my goal, or information about whatever basic concept I (probably) currently fail to understand. Thank you.

    "For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash

    I M 2 Replies Last reply
    0
    • L lctrncs

      I am a beginner who wants to restore the main window of a clock program that resides in the System Tray when running. What I want to do programatically is done normally by right clicking on the clock program's icon in the System Tray, then selecting "Restore Main Window" from the context menu. I have tried many things, and the closest I can get is using SetForegroundWindow, which will only work when I have already selected "Restore Main Window" from the context menu and then minimized the restored main window. I think I must be missing some fundamental concept about what I am trying to do. Consider the pseudocode below... void MyApp::OnLaunchSysTrayApp { CWnd*m_hWnd = FindWindow(NULL, "System Tray Application Name") if (m_hWnd) { m_hWnd->SetForegroundWindow(); //Displays restored main window if not on top //m_hWnd->GetWindow(NULL); //Fails //m_hWnd->ShowWindow(SW_RESTORE); //Fails //m_hWnd->SetActiveWindow(); //Fails BOOL m_bIconic; m_bIconic=m_hWnd->IsIconic() if (m_bIconic) { //m_hWnd->GetWindow(NULL); //Fails //m_hWnd->ShowWindow(SW_RESTORE); //Fails //m_hWnd->SetActiveWindow(); //Fails } etc. } } I would appreciate any suggestions about how I might achieve my goal, or information about whatever basic concept I (probably) currently fail to understand. Thank you.

      "For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      Too much of this depends on the particular application to usefully answer. Maybe the clock window is destroyed, or maybe it is the main window for the application but is hidden. Maybe, maybe... In short, I don;t think there is a generic way of doing this. Iain.

      1 Reply Last reply
      0
      • L lctrncs

        I am a beginner who wants to restore the main window of a clock program that resides in the System Tray when running. What I want to do programatically is done normally by right clicking on the clock program's icon in the System Tray, then selecting "Restore Main Window" from the context menu. I have tried many things, and the closest I can get is using SetForegroundWindow, which will only work when I have already selected "Restore Main Window" from the context menu and then minimized the restored main window. I think I must be missing some fundamental concept about what I am trying to do. Consider the pseudocode below... void MyApp::OnLaunchSysTrayApp { CWnd*m_hWnd = FindWindow(NULL, "System Tray Application Name") if (m_hWnd) { m_hWnd->SetForegroundWindow(); //Displays restored main window if not on top //m_hWnd->GetWindow(NULL); //Fails //m_hWnd->ShowWindow(SW_RESTORE); //Fails //m_hWnd->SetActiveWindow(); //Fails BOOL m_bIconic; m_bIconic=m_hWnd->IsIconic() if (m_bIconic) { //m_hWnd->GetWindow(NULL); //Fails //m_hWnd->ShowWindow(SW_RESTORE); //Fails //m_hWnd->SetActiveWindow(); //Fails } etc. } } I would appreciate any suggestions about how I might achieve my goal, or information about whatever basic concept I (probably) currently fail to understand. Thank you.

        "For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash

        M Offline
        M Offline
        Member 754960
        wrote on last edited by
        #3

        Try posting the SW_RESTORE command to the application.

        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