minimise the application

Posted on 2007-07-23
Last Modified: 2013-11-20
Hi Experts,
I want to minimise the outlook application whenever i lauch my application.
Question by:tariq6000
    LVL 11

    Expert Comment

    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;
    LVL 11

    Accepted Solution

    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;
    LVL 11

    Expert Comment

    just add the code from the second comment to your applications startup code.
    LVL 39

    Assisted Solution

    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 ))
              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


    Author Comment

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

    I used EnumProcesses(),EnumProcessModules() function.
    LVL 49

    Assisted Solution

    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
    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
    If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now