windowUtils module
Utilities for working with windows (HWNDs).
When working on this file, consider moving to winAPI.
- windowUtils.findDescendantWindow(parent, visible=None, controlID=None, className=None)
Find a descendant window matching specified criteria. @param parent: The handle of the parent window to search within. @type parent: int @param visible: Whether the window should be visible or C{None} if irrelevant. @type visible: bool @param controlID: The control ID of the window or C{None} if irrelevant. @type controlID: int @param className: The class name of the window or C{None} if irrelevant. @type className: str @return: The handle of the matching descendant window. @rtype: int @raise LookupError: if no matching window is found.
- windowUtils.logicalToPhysicalPoint(window, x, y)
Converts the logical coordinates of a point in a window to physical coordinates. This should be used when points are received directly from a window that is not DPI aware. @param window: The window handle. @param x: The logical x coordinate. @type x: int @param y: The logical y coordinate. @type y: int @return: The physical x and y coordinates. @rtype: tuple of (int, int)
- windowUtils.physicalToLogicalPoint(window, x, y)
Converts the physical coordinates of a point in a window to logical coordinates. This should be used when sending points directly to a window that is not DPI aware. @param window: The window handle. @param x: The physical x coordinate. @type x: int @param y: The physical y coordinate. @type y: int @return: The logical x and y coordinates. @rtype: tuple of (int, int)
- windowUtils.getWindowScalingFactor(window: int) int
Gets the logical scaling factor used for the given window handle. This is based off the Dpi reported by windows for the given window handle / divided by the “base” DPI level of 96. Typically this is a result of using the scaling percentage in the windows display settings. 100% is typically 96 DPI, 150% is typically 144 DPI. @param window: a native Windows window handle (hWnd) @returns the logical scaling factor. EG. 1.0 if the window DPI level is 96, 1.5 if the window DPI level is 144
- class windowUtils.CustomWindow(*args, **kwargs)
Bases:
AutoPropertyObject
Base class to enable simple implementation of custom windows. Subclasses need only set L{className} and implement L{windowProc}. Simply create an instance to create the window. The window will be destroyed when the instance is deleted, but it can be explicitly destroyed using L{destroy}.
Constructor. @param windowName: The name of the window. @param windowStyle: The style of the window.
This is a combination of the C{winUser.WS_*} constants.
- @param extendedWindowStyle: The extended style of the window.
This is a combination of the C{winUser.WS_EX_*} constants.
@param parent: The handle of the parent window, if any. @raise WindowsError: If an error occurs.
- _wClass: WNDCLASSEXW = <winUser.WNDCLASSEXW object>
- classmethod _get__wClass()
- _abstract_className = True
- className: str = None
- classmethod _get_className() str
The class name of this window.
- _hwndsToInstances = <WeakValueDictionary at 0x48d8af0>
- handle: int | None = None
The handle to the created window.
- destroy()
Destroy the window. This will be called automatically when this instance is deleted, but you may wish to call it earlier.
- abstract windowProc(hwnd, msg, wParam, lParam)
Process messages sent to this window. @param hwnd: The handle to this window. @type hwnd: int @param msg: The message. @type msg: int @param wParam: Additional message information. @type wParam: int @param lParam: Additional message information. @type lParam: int @return: The result of the message processing
or C{None} to call DefWindowProc.
@rtype: int or None
- _abc_impl = <_abc._abc_data object>
- _rawWindowProc = <WinFunctionType object>