minimise the application

Hi Experts,
I want to minimise the outlook application whenever i lauch my application.
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);
            std::cout << "Cannot Find the window." << std::endl;
Try something lke

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

      if(h != NULL)
            SendMessage(h, WM_SYSCOMMAND, SC_MINIMIZE, NULL);
            std::cout << "Cannot Find the window." << std::endl;
just add the code from the second comment to your applications startup code.
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:

    CWnd* pTopWnd;
    CString strTitle;
    while (pTopWnd = GetWindow(cmd ))
          if (strTitle.Find("Outlook") >= 0)
          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

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

I used EnumProcesses(),EnumProcessModules() function.
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

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
Forced accept.

EE Admin
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.