-
-
Notifications
You must be signed in to change notification settings - Fork 709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always on Top can't be disabled #1848
Labels
Comments
This issue has not yet been fixed. I suggest using my way with ctypes: import os
from ctypes import WINFUNCTYPE, WinDLL, Structure, c_long, byref, wintypes
user32 = WinDLL("user32")
user32.SetWindowPos.restype = wintypes.BOOL
user32.SetWindowPos.argtypes = [wintypes.HWND, wintypes.HWND, wintypes.INT, wintypes.INT, wintypes.INT, wintypes.INT, wintypes.UINT, ]
WNDENUMPROC = WINFUNCTYPE(wintypes.BOOL,
wintypes.HWND,
wintypes.LPARAM)
user32.EnumWindows.argtypes = [WNDENUMPROC,
wintypes.LPARAM]
def get_hwnd_from_pid(pid: int) -> int | None:
import ctypes
result = None
def callback(hwnd, _):
nonlocal result
lpdw_PID = ctypes.c_ulong()
user32.GetWindowThreadProcessId(hwnd, ctypes.byref(lpdw_PID))
hwnd_PID = lpdw_PID.value
if hwnd_PID == pid:
result = hwnd
return False
return True
cb_worker = WNDENUMPROC(callback)
user32.EnumWindows(cb_worker, 0)
return result
def set_always_top(value: bool):
# window = user32.GetForegroundWindow()
window = get_hwnd_from_pid(os.getpid())
if window is None:
return
class RECT(Structure):
_fields_ = [
('left', c_long),
('top', c_long),
('right', c_long),
('bottom', c_long),
]
def width(self): return self.right - self.left
def height(self): return self.bottom - self.top
rc = RECT()
user32.GetWindowRect(window, byref(rc))
value = -1 if value else -2
user32.SetWindowPos(window, value, rc.left, rc.top, 0, 0, 0x0001)
import dearpygui.dearpygui as dpg
dpg.create_context()
with dpg.window():
dpg.add_checkbox(label='Always On Top', callback=lambda _, value: set_always_top(value))
dpg.create_viewport()
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context() |
hoffstadt
pushed a commit
that referenced
this issue
Oct 22, 2022
* Fix for 1716 * Fix für 1795 * Fix for Issue 1848 Co-authored-by: mstuder <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version of Dear PyGui
Version: 16.3.
Operating System: Win10
My Issue/Question
dpg.always_on_top can't be disabled on windows
A clear and concise description of what the issue/question is. Please provide as much context as possible.
-- already fixed with next PR.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots/Video
XXX (you can drag files here)
Standalone, minimal, complete and verifiable example
The text was updated successfully, but these errors were encountered: