Bringing a window to the front

Posted on 2004-11-22
Last Modified: 2013-12-03
I'm working on a program that needs to bring an already opened IE window to the front of the screen.  I looked on the MSDN site for help.  I've tried using ShowWindow(), ShowWindowAsync(), BringWindowToTop() and SwitchToThisWindow() [which wouldn't compile].  Does anybody know of any other functions that will do this, or is there anything special that I need to do to get one of the above functions to work?
Question by:spikey_nick

    Author Comment

    I shoud also add that I'm writing this in C++ using Visual Studio 6
    LVL 55

    Expert Comment

    by:Jaime Olivares
    SetWindowPos() works well, assumming you have the HWND handler of the window.

    An example:

    BOOL SetWindowPos( hWnd, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE);
    LVL 48

    Accepted Solution

    This code works in my project:

    HWND hChild = GetLastActivePopup(hWnd);

    if ( IsIconic(hChild) )
        ShowWindow(hChild, SW_RESTORE);


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
    This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (, we saw how to put the Delete button back there where it belongs.  "Delete" is …
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    737 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

    22 Experts available now in Live!

    Get 1:1 Help Now