Ensure Windows borderless window registers as taskbar app
This commit is contained in:
parent
2bf9776076
commit
3e6650eb2e
25
app/app.py
25
app/app.py
|
|
@ -111,16 +111,27 @@ class ICRAApp(
|
||||||
return
|
return
|
||||||
|
|
||||||
GWL_EXSTYLE = -20
|
GWL_EXSTYLE = -20
|
||||||
|
GWL_HWNDPARENT = -8
|
||||||
WS_EX_TOOLWINDOW = 0x00000080
|
WS_EX_TOOLWINDOW = 0x00000080
|
||||||
WS_EX_APPWINDOW = 0x00040000
|
WS_EX_APPWINDOW = 0x00040000
|
||||||
SWP_NOSIZE = 0x0001
|
SWP_NOSIZE = 0x0001
|
||||||
SWP_NOMOVE = 0x0002
|
SWP_NOMOVE = 0x0002
|
||||||
SWP_NOZORDER = 0x0004
|
SWP_NOZORDER = 0x0004
|
||||||
SWP_FRAMECHANGED = 0x0020
|
SWP_FRAMECHANGED = 0x0020
|
||||||
|
SWP_NOOWNERZORDER = 0x0200
|
||||||
|
SWP_SHOWWINDOW = 0x0040
|
||||||
|
|
||||||
user32 = ctypes.windll.user32 # type: ignore[attr-defined]
|
user32 = ctypes.windll.user32 # type: ignore[attr-defined]
|
||||||
shell32 = ctypes.windll.shell32 # type: ignore[attr-defined]
|
shell32 = ctypes.windll.shell32 # type: ignore[attr-defined]
|
||||||
|
|
||||||
|
set_long = getattr(user32, "SetWindowLongPtrW", user32.SetWindowLongW)
|
||||||
|
get_long = getattr(user32, "GetWindowLongPtrW", user32.GetWindowLongW)
|
||||||
|
ptr_type = ctypes.c_longlong if ctypes.sizeof(ctypes.c_void_p) == 8 else ctypes.c_long
|
||||||
|
get_long.restype = ptr_type # type: ignore[attr-defined]
|
||||||
|
get_long.argtypes = [wintypes.HWND, ctypes.c_int] # type: ignore[attr-defined]
|
||||||
|
set_long.restype = ptr_type # type: ignore[attr-defined]
|
||||||
|
set_long.argtypes = [wintypes.HWND, ctypes.c_int, ptr_type] # type: ignore[attr-defined]
|
||||||
|
|
||||||
style = user32.GetWindowLongW(hwnd, GWL_EXSTYLE)
|
style = user32.GetWindowLongW(hwnd, GWL_EXSTYLE)
|
||||||
new_style = (style & ~WS_EX_TOOLWINDOW) | WS_EX_APPWINDOW
|
new_style = (style & ~WS_EX_TOOLWINDOW) | WS_EX_APPWINDOW
|
||||||
if new_style != style:
|
if new_style != style:
|
||||||
|
|
@ -132,9 +143,19 @@ class ICRAApp(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED,
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED | SWP_SHOWWINDOW,
|
||||||
|
)
|
||||||
|
|
||||||
|
set_long(hwnd, GWL_HWNDPARENT, ptr_type(0))
|
||||||
|
user32.SetWindowPos(
|
||||||
|
hwnd,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_SHOWWINDOW,
|
||||||
)
|
)
|
||||||
user32.ShowWindow(hwnd, 5) # SW_SHOW
|
|
||||||
|
|
||||||
app_id = ctypes.c_wchar_p("ICRA.App")
|
app_id = ctypes.c_wchar_p("ICRA.App")
|
||||||
shell32.SetCurrentProcessExplicitAppUserModelID(app_id)
|
shell32.SetCurrentProcessExplicitAppUserModelID(app_id)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue