• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

minimise the application

Hi Experts,
I want to minimise the outlook application whenever i lauch my application.
0
tariq6000
Asked:
tariq6000
3 Solutions
 
Jase-CoderCommented:
Try something lke

      HWND h =  FindWindow(NULL, L"Inbox - Microsoft Outlook");

      if(h != NULL)
            SendMessage(h, WM_SYSCOMMAND, SC_MINIMIZE, NULL);
      else
            std::cout << "Cannot Find the window." << std::endl;
0
 
Jase-CoderCommented:
Actually the following code works on Vista

      HWND h =  FindWindow(NULL, L"Inbox - Microsoft Outlook");

      if(h != NULL)
            ShowWindow(h, SW_MINIMIZE);
      else
            std::cout << "Cannot Find the window." << std::endl;
0
 
Jase-CoderCommented:
just add the code from the second comment to your applications startup code.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
itsmeandnobodyelseCommented:
If you want to find Outlook when another folder was opened as well, you might iterate the desktop windows and check the windows title for Outlook:

    UINT cmd = GW_HWNDFIRST ;
    CWnd* pTopWnd;
    CString strTitle;
    while (pTopWnd = GetWindow(cmd ))
    {
          pTopWnd->GetWindowText(strTitle);
          if (strTitle.Find("Outlook") >= 0)
                pTopWnd->ShowWindow(SW_HIDE);
          cmd = GW_HWNDNEXT;
    }

Note, you may break the loop after finding Outlook (or search for more instances).

An alternative to GetWindow is EnumWindows which is more code and a callback but a little bit safer in case a current top level window was destroyed while it was evaluated in the above loop (rare chance).

Regards, Alex

0
 
tariq6000Author Commented:
Hi,
I have capture the handle of running application.How can i minimise the application through application handle.

I used EnumProcesses(),EnumProcessModules() function.
0
 
DanRollinsCommented:
First, I do suggest that you use either of the methods described above (that is, work with the window handle and the known title text of that window).  But if you feel that you must use the Process Handle,  then see:

      C++ Q&A July 2002 Get the Main Window
     http://msdn.microsoft.com/msdnmag/issues/02/07/CQA/

which suggests enumerating all top-level windows (like in itsmeandnobodyelse's comment) then using GetWindowThreadProcessId to compare that window's process ID to that of the known process.

-- Dan
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now