尽管提供了所有参数,SetWindowPos却什么也不做



我已经导入了SetWindowPos和GetForegroundWindow:

[DllImport("user32.dll", CharSet = CharSet.Ansi)]
private static extern IntPtr GetForegroundWindow();

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

我试过使用它们,虽然GetForegroundWindow确实返回了一个有效值,但SetWindowPos什么都不做:

IntPtr hWID = GetForegroundWindow();
SetWindowPos(hWID, IntPtr.Zero, 50, 500, 800, 800, 0x0004);

我需要设置一些功能吗?或者我忘记了许可?

它看起来像是同一块代码,插入到.NET项目中会产生所需的结果。有没有一种方法可以在UWP中实现这一点,或者我必须在.NET中做到这一点?

由于各种原因,大多数UserAPI无法用于UWP应用程序。应用商店也不支持它们,所以如果你想提交你的应用程序,你会无法接收。

UWP目前对窗口化的支持有限,尽管我们一直在寻求改进(比如在WPF应用程序中启用XAML控件(。

最新更新