正文
How to change windows applicatioin's position via Win32 API
小程序:扫一扫查出行
【扫一扫了解最新限行尾号】
复制小程序
【扫一扫了解最新限行尾号】
复制小程序
可以使用的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), width / , , width / , height, 0x0040);
}
}