mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-13 18:25:24 -05:00
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:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user