-2

我已经导入了 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 中做到这一点?

4

1 回答 1

1

由于各种原因,大多数UserAPI 不适用于 UWP 应用程序。商店也不支持它们,因此如果您想提交您的应用程序,您将无法提取。

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

于 2018-11-21T04:24:42.870 回答