def HitTest(self): pt = POINT() if not user32.GetCursorPos(byref(pt)): raise WinError(GetLastError()) hittest = self.DefWindowProc(self.Hwnd, self.Msg.WM_NCHITTEST, 0, MAKELONG(pt.x, pt.y)) try: return HT_FLAGS[hittest] except: return 'unknown'
def Deselect(self, i, stop=0): if self.GetStyleL('style') & self.Style.LBS_MULTIPLESEL: if stop: result = self.SendMessage(self.Hwnd, self.Msg.LB_SELITEMRANGE, 0, MAKELONG(i, stop)) if result == LB_ERR: raise "could not select items" else: result = self.SendMessage(self.Hwnd, self.Msg.LB_SETSEL, 0, i) if result == LB_ERR: raise "could not deselect item" else: self.SendMessage(self.Hwnd, self.Msg.LB_SETCURSEL, -1, 0)
def SetRange(self, low=0, high=100): result = self.SendMessage(self.Hwnd, self.Msg.PBM_SETRANGE, 0, MAKELONG(low, high)) return (LOWORD(result), HIWORD(result))
def CharFromPos(self, x, y): result = self.SendMessage(self.Hwnd, self.Msg.EM_CHARFROMPOS, 0, MAKELONG(x, y)) return LOWORD(result)
def CopyData(hwndSource, hwndDest, lp, data, reserved=0): p = create_string_buffer(SZ_GUID_COPYDATA + data) ## do not include NULL byte in cbData cd = COPYDATASTRUCT(MAKELONG(lp, reserved), sizeof(p) - 1, addressof(p)) return bool( user32.SendMessageA(hwndDest, WM_COPYDATA, hwndSource, byref(cd)))
def AddressToDword(self, i0, i1, i2, i3): if not self._IsUByte(i0, i1, i2, i3): raise ValueError("invalid address: %s" % repr((i0, i1, i2, i3))) return MAKELONG(MAKEWORD(i3, i2), MAKEWORD(i1, i0))
def SetTrackTipPos(self, x, y): self.SendMessage(self.Hwnd, self.Msg.TTM_TRACKPOSITION, 0, MAKELONG(x, y))
def DeselectItems(self, start, stop): result = self.SendMessage(self.Hwnd, self.Msg.LB_SELITEMRANGE, 0, MAKELONG(start, stop)) if result == LB_ERR: raise "could not deselect items"
def FindXY(self, x, y): result = self.SendMessage(self.Hwnd, self.Msg.LB_ITEMFROMPOINT, 0, MAKELONG(x, y)) if not HIWORD(result): return LOWORD(result)
def PlayAnim(self, repeat=-1, start=0, stop=-1): if not self.SendMessage(self.Hwnd, self.Msg.ACM_PLAY, repeat, MAKELONG(start, stop)): raise "could not play animation"
def SetItemSize(self, w, h): result=self.SendMessage(self.Hwnd, self.Msg.TCM_SETITEMSIZE , 0, MAKELONG(w, h)) return LOWORD(result), HIWORD(result)