This commit is contained in:
dan_clark@outlook.com
2022-03-23 15:44:32 +00:00
commit 2ac0e3ed26
129 changed files with 4197 additions and 0 deletions
@@ -0,0 +1,37 @@
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.UI.WindowsAndMessaging;
namespace TheXamlGuy.TaskbarGroup.Core
{
public class WindowHelper
{
public static void MoveAndResize(HWND handle, int x, int y, int width, int height)
{
PInvoke.SetWindowPos(handle, new HWND(), x, y, width, height, 0);
}
public static void BringToForeground(HWND handle)
{
if (TryGetBounds(handle, out var bounds))
{
PInvoke.SetWindowPos(handle, new HWND(), bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top, SET_WINDOW_POS_FLAGS.SWP_SHOWWINDOW | SET_WINDOW_POS_FLAGS.SWP_NOACTIVATE);
}
}
public static HWND Find(string windowName) => PInvoke.FindWindow(windowName, null);
public static HWND Find(string windowName, HWND parentHandle)
{
return PInvoke.FindWindowEx(parentHandle, new HWND(), windowName, null);
}
public static unsafe bool TryGetBounds(IntPtr handle, out RECT rect)
{
fixed (RECT* lpRectLocal = &rect)
{
return PInvoke.GetWindowRect(new HWND(handle), lpRectLocal);
}
}
}
}