可以使用的Win32 API是:

[DllImport("user32.dll")]
private extern static bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);

 

static void SetWindowPosition(string locationURL)
        {
            SHDocVw.ShellWindows windows = new SHDocVw.ShellWindows();
            SHDocVw.InternetExplorer currentWindow = null;
            foreach (SHDocVw.InternetExplorer window in windows)
            {
                if (window.LocationURL.Contains(locationURL))
                {
                    currentWindow = window;
                    break;
                }
            }

            if (currentWindow != null)
            {
                IntPtr handle = (IntPtr)currentWindow.HWND;
                var width = Screen.PrimaryScreen.Bounds.Width;
                var height = Screen.PrimaryScreen.Bounds.Height;
                SetWindowPos(handle, (IntPtr)0, width / 2, 0, width / 2, height, 0x0040);
            }
        }

 

相关文章:

  • 2022-02-10
  • 2022-12-23
  • 2021-09-09
  • 2021-11-27
  • 2021-11-27
  • 2021-06-25
猜你喜欢
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
  • 2021-11-15
  • 2021-09-10
相关资源
相似解决方案