我C#写的程序,想激活一个后台的IE浏览窗口。如何实现?
     还有怎么获得他的坐标?
     句柄我能获得到。
            System.Diagnostics.Process[] myPs;
            myPs = System.Diagnostics.Process.GetProcesses();
            foreach (System.Diagnostics.Process p in myPs)
            {
                string str = p.MainWindowTitle;
                if (p.ProcessName.Contains("test"))
                {
                    try
                    {
                      IntPtr newIeWindow = p.MainWindowHandle;
                    }
                    catch (Exception eKillProcess)
                    {
                    }
                }
            }

解决方案 »

  1.   


    //窗口句柄
    windowHandle = (IntPtr)hwnd;
    //获取标题
    StringBuilder sbuilder = new StringBuilder(256);
    NativeMethod.GetWindowText(windowHandle, sbuilder, sbuilder.Capacity);
    string strTitle = sbuilder.ToString();
    //如果标题相等,则拉至最前面
    if (strTitle == ApplicationTitle)
    {
      NativeMethod.ShowWindow(windowHandle, Const.SW_SHOWNORMAL);
      NativeMethod.SetForegroundWindow(windowHandle);
    }
      

  2.   

    1,设置窗体显示在最前 的API:  [DllImport("user32.dll", EntryPoint = "SetForegroundWindow")] 
      public static extern bool SetForegroundWindow(IntPtr hWnd); 
    你得到句柄就用这个API吧。
    SetForegroundWindow(你的句柄);
      

  3.   

     [DllImport("user32.dll", CharSet = CharSet.Auto)]
            public static public extern bool SetForegroundWindow(IntPtr hWnd);
      

  4.   

    可以设置窗体显示在最前 的API:   [DllImport("user32.dll", EntryPoint = "SetForegroundWindow")] 
      public static extern bool SetForegroundWindow(IntPtr hWnd); 
    你得到句柄就用这个API吧。 
    SetForegroundWindow(你的句柄);