我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用win32gui.ClientToScreen()。
def OnInitDialog(self, hwnd, msg, wparam, lparam): self.hwnd = hwnd desktop = win32gui.GetDesktopWindow() dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop) centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)/2, (dt_b-dt_t)/2) ) bmCtrl = win32gui.GetDlgItem(self.hwnd, IDC_BITMAP) win32gui.SendMessage(bmCtrl, win32con.STM_SETIMAGE, win32con.IMAGE_BITMAP, self.hSplash) win32gui.SetWindowPos(self.hwnd, win32con.HWND_TOPMOST, centre_x-(self.bmWidth/2), centre_y-(self.bmHeight/2), self.bmWidth, self.bmHeight, win32con.SWP_HIDEWINDOW) win32gui.SetForegroundWindow(self.hwnd)
def rect(self): hwnd = self.hwnd if not self.exclude_border: left, top, right, bottom = win32gui.GetWindowRect(hwnd) else: _left, _top, _right, _bottom = win32gui.GetClientRect(hwnd) left, top = win32gui.ClientToScreen(hwnd, (_left, _top)) right, bottom = win32gui.ClientToScreen(hwnd, (_right, _bottom)) return Rect(left, top, right, bottom)
def __init_rect_size(self): hwnd = self.hwnd left, top, right, bottom = win32gui.GetWindowRect(hwnd) if self.exclude_border: _left, _top, _right, _bottom = win32gui.GetClientRect(hwnd) left, top = win32gui.ClientToScreen(hwnd, (_left, _top)) right, bottom = win32gui.ClientToScreen(hwnd, (_right, _bottom)) self._rect = Rect(left, top, right, bottom) self._size = Size(right-left, bottom-top)
def OnInitDialog(self, hwnd, msg, wparam, lparam): self.hwnd = hwnd # centre the dialog desktop = win32gui.GetDesktopWindow() l,t,r,b = win32gui.GetWindowRect(self.hwnd) dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop) centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)//2, (dt_b-dt_t)//2) ) win32gui.MoveWindow(hwnd, centre_x-(r//2), centre_y-(b//2), r-l, b-t, 0) self._SetupList() l,t,r,b = win32gui.GetClientRect(self.hwnd) self._DoSize(r-l,b-t, 1)
def OnInitDialog(self, hwnd, msg, wparam, lparam): self.hwnd = hwnd # centre the dialog desktop = win32gui.GetDesktopWindow() l,t,r,b = win32gui.GetWindowRect(self.hwnd) dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop) centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)//2, (dt_b-dt_t)//2) ) win32gui.MoveWindow(hwnd, centre_x-(r//2), centre_y-(b//2), r-l, b-t, 0)