提问人:theateist 提问时间:4/18/2023 更新时间:4/21/2023 访问量:141
WinAPI SetWindowPos 不适用于记事本和计算器等简单应用程序
WinAPI SetWindowPos not working for simple apps like notepad and calc
问:
我在 Windows 10 上开发。
我想移动外部应用程序并调整其大小。我试着先用记事本和计算器让它工作。但是,无论我做什么,记事本/校准都不会移动或调整大小。我尝试使用 ,但没有任何效果。我调试了代码,并且执行了内部部分。SetWindowPos
UpdateWindow
MoveWindow
foreach
我试图按照此处的建议以管理员身份运行它,但没有帮助。
static void foo()
{
foreach (var p in Process.GetProcesses().Where(p => p.ProcessName.ToLower().Contains("calculatorapp")))
{
SetWindowPos(p.Handle, HWND.TopMost, 10, 10, 100, 300, (uint)(SWP.SHOWWINDOW));
int err = Marshal.GetLastWin32Error();
UpdateWindow(p.Handle);
//SetWindowPos(p.Handle, 0, 0, 250, 250, true);
MoveWindow(p.Handle, 0, 0, 250, 250, true);
}
}
答:
评论