Re: IE to the front

Tim Hibbs <[email protected]>
Newsgroups gmane.comp.windows.devel.jawin
Message-ID <LISTSERV%[email protected]>
I have developed a small app in C# that does something similar to your
app, and the reason I'm on the Jawin list is that I'd like to access the
Win32 function directly without the .NET overhead. Haven't done it yet,
but would appreciate your code "in exchange" maybe...

The function you need to change the Z order is SetWindowPos. Here's the
relevant C# code:

namespace OnTopBrowser
{
/// <summary>
/// Summary description for Win32 class
/// </summary>
    class Win32
    {
        [DllImport("user32.dll", EntryPoint = "SetWindowPos")]
        public static extern bool SetWindowPos(
            int hWnd,               // window handle
            int hWndInsertAfter,    // placement-order handle
            int X,                  // horizontal position
            int Y,                  // vertical position
            int cx,                 // width
            int cy,                 // height
            uint uFlags);           // window positioning flags
        public const int HWND_TOPMOST = -0x1;
        public const uint SWP_NOSIZE = 0x1;
        public const uint SWP_NOMOVE = 0x2;
        public const uint SWP_SHOWWINDOW = 0x40;

        public void FloatToTop(BrowserForm aForm)
        {
            SetWindowPos((int)aForm.Handle,
                Win32.HWND_TOPMOST,
                0, 0, 0, 0,
                Win32.SWP_NOMOVE | Win32.SWP_NOSIZE |
Win32.SWP_SHOWWINDOW);
        }
    }
}

The key element here is HWND_TOPMOST, which places the window on top of
the others.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.