示例#1
0
    def OnLeftDown(self, event):
        x1, y1 = GetCursorPos()
        x2, y2 = self.parent.GetScreenPosition()
        self.offset = (x1 - x2, y1 - y2)

        # from now on we want all mouse motion events
        self.Bind(wx.EVT_MOTION, self.OnDrag)
        # and the left up event
        self.Bind(wx.EVT_LEFT_UP, self.OnDragEnd)

        # and call Skip in for handling focus events etc.
        event.ResumePropagation(wx.EVENT_PROPAGATE_MAX)
        event.Skip()
        # start capturing the mouse exclusively
        self.CaptureMouse()
 def OnDrag(self, event):
     # get the mouse coordinates
     point = GetCursorPos()
     # find the window under cursor
     hwnd = BestWindowFromPoint(point)
     # do we have targeted a new window?
     if hwnd != self.lastTarget:
         if self.lastTarget is not None:
             # unhighlight previous window
             HighlightWindow(self.lastTarget)
         _, pid = GetWindowThreadProcessId(hwnd)
         if pid == eg.processId:
             self.lastTarget = None
         else:
             HighlightWindow(hwnd)
             self.lastTarget = hwnd
     event.Skip()
示例#3
0
 def OnDrag(self, event):
     x1, y1 = GetCursorPos()
     x2, y2 = self.offset
     self.parent.SetPosition((x1 - x2, y1 - y2))