WS_EX_TOPMOST macht scheinbar nichts
Posted: 24 Dec 2024, 19:38
Ich habe eine Pyglet-Window-Unterklasse, die dies in seiner __init__-Funktion hat. Jedes Flag funktioniert außer WS_EX_TOPMOST.
Der vollständige __init__-Code ist ein komplettes Durcheinander, aber ich werde ihn auch bereitstellen, um Missverständnisse zu vermeiden.
Code: Select all
hwnd = self._hwnd # type: ignore
GWL_EXSTYLE = -20
WS_EX_LAYERED = 0x80000
WS_EX_TOOLWINDOW = 0x00000080
WS_EX_TOPMOST = 0x00000008
LWA_COLORCODE = 0x1
ex_style = windll.user32.GetWindowLongW(hwnd, GWL_EXSTYLE)
windll.user32.SetWindowLongW(hwnd, GWL_EXSTYLE, ex_style | WS_EX_LAYERED | WS_EX_TOOLWINDOW | WS_EX_TOPMOST)
windll.user32.SetLayeredWindowAttributes(hwnd, 0, 255, LWA_COLORCODE)
windll.user32.SetWindowPos(hwnd, -1, 0, 0, 0, 0, 0x0001 | 0x0002)
Code: Select all
def __init__(self, *args, **kwargs):
# Overriding something for beauty's sake
kwargs['style'] = 'borderless'
kwargs['width'] = bg_img.width
kwargs['height'] = screen.height
super().__init__(*args, **kwargs)
glClearColor(0, 0, 0, 0)
# Doing some unusual low-level gibberish to explain Windows how our pyglet app should behave and look like
hwnd = self._hwnd # type: ignore
GWL_EXSTYLE = -20
WS_EX_LAYERED = 0x80000
WS_EX_TOOLWINDOW = 0x00000080
WS_EX_TOPMOST = 0x00000008
LWA_COLORCODE = 0x1
ex_style = windll.user32.GetWindowLongW(hwnd, GWL_EXSTYLE)
windll.user32.SetWindowLongW(hwnd, GWL_EXSTYLE, ex_style | WS_EX_LAYERED | WS_EX_TOOLWINDOW | WS_EX_TOPMOST)
windll.user32.SetLayeredWindowAttributes(hwnd, 0, 255, LWA_COLORCODE)
windll.user32.SetWindowPos(hwnd, -1, 0, 0, 0, 0, 0x0001 | 0x0002)
self.set_location(screen.width - self.width, 0)
self.shown = True
self.cursors = {
'default': self.get_system_mouse_cursor(Window.CURSOR_DEFAULT),
'hand': self.get_system_mouse_cursor(Window.CURSOR_HAND)
}
# omelette w/ bacon
self.batch = Batch()
self.bg = Sprite(bg_img, batch = self.batch)