Restore preview card on system wake

pc went to sleep, hover preview was missing (minimized?)
this workaround works, maybe I can deduplicate the dllimport in PokePreview, or make this more abstract for future hover card previews like encounters?
This commit is contained in:
Kurt
2026-06-10 23:19:55 -05:00
parent a71b808b77
commit 740a3c5b90
2 changed files with 22 additions and 3 deletions

View File

@@ -467,7 +467,6 @@ public void MoveForm(int x, int y)
const uint SWP_ASYNCWINDOWPOS = 0x4000;
const uint flags = SWP_NOZORDER | SWP_NOSIZE | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_ASYNCWINDOWPOS;
const int HWND_TOPMOST = -1;
SetWindowPos(Handle, HWND_TOPMOST, x, y, 0, 0, flags);
return;

View File

@@ -70,12 +70,32 @@ private static void SetWindowState(Form frm, bool visible)
{
try
{
if (!frm.IsHandleCreated || frm.IsDisposed)
return;
const int SW_SHOWNOACTIVATE = 4;
var state = visible ? SW_SHOWNOACTIVATE : 0;
ShowWindowAsync(frm.Handle, state);
const int HWND_TOPMOST = -1;
const uint SWP_NOMOVE = 0x0002;
const uint SWP_NOSIZE = 0x0001;
const uint SWP_NOACTIVATE = 0x0010;
const uint SWP_SHOWWINDOW = 0x0040;
const uint SWP_NOOWNERZORDER = 0x0200;
if (visible)
{
ShowWindowAsync(frm.Handle, SW_SHOWNOACTIVATE);
SetWindowPos(frm.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOOWNERZORDER);
}
else
{
ShowWindowAsync(frm.Handle, 0);
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern bool ShowWindowAsync(nint hWnd, int nCmdShow);
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern bool SetWindowPos(nint hWnd, nint hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
}
catch
{