minimise the application

Hi Experts,
I want to minimise the outlook application whenever i lauch my application.
tariq6000Asked:
Who is Participating?
 
Jase-CoderConnect With a Mentor Commented:
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:
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:
just add the code from the second comment to your applications startup code.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
itsmeandnobodyelseConnect With a Mentor Commented:
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
 
DanRollinsConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.