本文整理匯總了Python中ctypes.wintypes.RECT屬性的典型用法代碼示例。如果您正苦於以下問題:Python wintypes.RECT屬性的具體用法?Python wintypes.RECT怎麽用?Python wintypes.RECT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類ctypes.wintypes
的用法示例。
在下文中一共展示了wintypes.RECT屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _set_argtypes
# 需要導入模塊: from ctypes import wintypes [as 別名]
# 或者: from ctypes.wintypes import RECT [as 別名]
def _set_argtypes(self):
''' Functions arguments. '''
self.MONITORENUMPROC = WINFUNCTYPE(INT, DWORD, DWORD, POINTER(RECT),
DOUBLE)
windll.user32.GetSystemMetrics.argtypes = [INT]
windll.user32.EnumDisplayMonitors.argtypes = [HDC, c_void_p,
self.MONITORENUMPROC,
LPARAM]
windll.user32.GetWindowDC.argtypes = [HWND]
windll.gdi32.CreateCompatibleDC.argtypes = [HDC]
windll.gdi32.CreateCompatibleBitmap.argtypes = [HDC, INT, INT]
windll.gdi32.SelectObject.argtypes = [HDC, HGDIOBJ]
windll.gdi32.BitBlt.argtypes = [HDC, INT, INT, INT, INT, HDC, INT, INT,
DWORD]
windll.gdi32.DeleteObject.argtypes = [HGDIOBJ]
windll.gdi32.GetDIBits.argtypes = [HDC, HBITMAP, UINT, UINT, c_void_p,
POINTER(BITMAPINFO), UINT]
示例2: enum_display_monitors
# 需要導入模塊: from ctypes import wintypes [as 別名]
# 或者: from ctypes.wintypes import RECT [as 別名]
def enum_display_monitors(self, screen=-1):
''' Get positions of one or more monitors.
Returns a dict with minimal requirements.
'''
if screen == -1:
SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN = 76, 77
SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN = 78, 79
left = windll.user32.GetSystemMetrics(SM_XVIRTUALSCREEN)
right = windll.user32.GetSystemMetrics(SM_CXVIRTUALSCREEN)
top = windll.user32.GetSystemMetrics(SM_YVIRTUALSCREEN)
bottom = windll.user32.GetSystemMetrics(SM_CYVIRTUALSCREEN)
yield ({
b'left': int(left),
b'top': int(top),
b'width': int(right - left),
b'height': int(bottom - top)
})
else:
def _callback(monitor, dc, rect, data):
''' Callback for MONITORENUMPROC() function, it will return
a RECT with appropriate values.
'''
rct = rect.contents
monitors.append({
b'left': int(rct.left),
b'top': int(rct.top),
b'width': int(rct.right - rct.left),
b'height': int(rct.bottom - rct.top)
})
return 1
monitors = []
callback = self.MONITORENUMPROC(_callback)
windll.user32.EnumDisplayMonitors(0, 0, callback, 0)
for mon in monitors:
yield mon
示例3: __init__
# 需要導入模塊: from ctypes import wintypes [as 別名]
# 或者: from ctypes.wintypes import RECT [as 別名]
def __init__(self):
"""Initialize our object"""
# Find the start x,y pos of the main pygame *screen* (the screen in the
# window):
sdlpos = os.getenv("SDL_VIDEO_WINDOW_POS")
if sdlpos is None:
raise Exception("Must have previously setup a Pygame window starting position via the 'SDL_VIDEO_WINDOW_POS' evn var.")
self.initPygameScreenPos = [int(i) for i in sdlpos.split(",")]
# Run our ctypes code to query window position:
try:
# It's said that not all systems support this dictionary key. I'm
# not sure what systmes those are, but might as well put a check in.
self.hwnd = pygame.display.get_wm_info()["window"]
except KeyError:
raise Exception("Your system isn't accepting the code: 'pygame.display.get_wm_info()[\"window\"]', must not be supported :-(")
self.prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT))
self.paramflags = (1, "hwnd"), (2, "lprect")
self.GetWindowRect = self.prototype(("GetWindowRect", windll.user32), self.paramflags)
# Find the initial *window* position:
rect = self.GetWindowRect(self.hwnd)
# Calculate the thickness of the *window* border to the *screen* object inside:
self.borderThickness = int(self.initPygameScreenPos[0]) - rect.left
self.titleThickness = int(self.initPygameScreenPos[1]) - rect.top
# borderThickness is the left, right, and bottom window edges. titleThickness
# is th thickness of the top title-bar of the window.