mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-15 00:30:33 +03:00
Take into account non-client area when positioning popup window
This commit is contained in:
parent
1e6d2df573
commit
758997002c
17
prefs.py
17
prefs.py
@ -53,6 +53,10 @@ elif platform=='win32':
|
||||
class BROWSEINFO(ctypes.Structure):
|
||||
_fields_ = [("hwndOwner", HWND), ("pidlRoot", LPVOID), ("pszDisplayName", LPWSTR), ("lpszTitle", LPCWSTR), ("ulFlags", UINT), ("lpfn", BrowseCallbackProc), ("lParam", LPCWSTR), ("iImage", ctypes.c_int)]
|
||||
|
||||
GetParent = ctypes.windll.user32.GetParent
|
||||
GetParent.argtypes = [HWND]
|
||||
GetWindowRect = ctypes.windll.user32.GetWindowRect
|
||||
GetWindowRect.argtypes = [HWND, ctypes.POINTER(RECT)]
|
||||
CalculatePopupWindowPosition = ctypes.windll.user32.CalculatePopupWindowPosition
|
||||
CalculatePopupWindowPosition.argtypes = [ctypes.POINTER(POINT), ctypes.POINTER(SIZE), UINT, ctypes.POINTER(RECT), ctypes.POINTER(RECT)]
|
||||
|
||||
@ -357,8 +361,9 @@ class PreferencesDialog(tk.Toplevel):
|
||||
# Ensure fully on-screen
|
||||
if platform == 'win32':
|
||||
position = RECT()
|
||||
GetWindowRect(GetParent(self.winfo_id()), position)
|
||||
if CalculatePopupWindowPosition(POINT(parent.winfo_rootx(), parent.winfo_rooty()),
|
||||
SIZE(self.winfo_width(), self.winfo_height()),
|
||||
SIZE(position.right - position.left, position.bottom - position.top),
|
||||
0x10000, None, position):
|
||||
self.geometry("+%d+%d" % (position.left, position.top))
|
||||
|
||||
@ -684,7 +689,15 @@ class AuthenticationDialog(tk.Toplevel):
|
||||
self.parent.wm_attributes('-topmost', 0) # needed for dialog to appear ontop of parent on OSX & Linux
|
||||
self.wait_visibility()
|
||||
self.grab_set()
|
||||
#self.wait_window(self) # causes duplicate events on OSX
|
||||
|
||||
# Ensure fully on-screen
|
||||
if platform == 'win32':
|
||||
position = RECT()
|
||||
GetWindowRect(GetParent(self.winfo_id()), position)
|
||||
if CalculatePopupWindowPosition(POINT(parent.winfo_rootx(), parent.winfo_rooty()),
|
||||
SIZE(position.right - position.left, position.bottom - position.top),
|
||||
0x10000, None, position):
|
||||
self.geometry("+%d+%d" % (position.left, position.top))
|
||||
|
||||
self.bind('<Return>', self.apply)
|
||||
|
||||
|
7
stats.py
7
stats.py
@ -17,6 +17,10 @@ import prefs
|
||||
if platform=='win32':
|
||||
import ctypes
|
||||
from ctypes.wintypes import *
|
||||
GetParent = ctypes.windll.user32.GetParent
|
||||
GetParent.argtypes = [HWND]
|
||||
GetWindowRect = ctypes.windll.user32.GetWindowRect
|
||||
GetWindowRect.argtypes = [HWND, ctypes.POINTER(RECT)]
|
||||
CalculatePopupWindowPosition = ctypes.windll.user32.CalculatePopupWindowPosition
|
||||
CalculatePopupWindowPosition.argtypes = [ctypes.POINTER(POINT), ctypes.POINTER(SIZE), UINT, ctypes.POINTER(RECT), ctypes.POINTER(RECT)]
|
||||
|
||||
@ -269,8 +273,9 @@ class StatsResults(tk.Toplevel):
|
||||
# Ensure fully on-screen
|
||||
if platform == 'win32':
|
||||
position = RECT()
|
||||
GetWindowRect(GetParent(self.winfo_id()), position)
|
||||
if CalculatePopupWindowPosition(POINT(parent.winfo_rootx(), parent.winfo_rooty()),
|
||||
SIZE(self.winfo_width(), self.winfo_height()),
|
||||
SIZE(position.right - position.left, position.bottom - position.top),
|
||||
0x10000, None, position):
|
||||
self.geometry("+%d+%d" % (position.left, position.top))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user