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()
def OnDragEnd(self, dummyEvent): # revert box to normal image self.dragBoxImage.SetBitmap(self.dragBoxBitmap) self.dragBoxText.SetLabel(self.text.drag1) # unbind the unneded events self.Unbind(wx.EVT_MOTION) self.Unbind(wx.EVT_LEFT_UP) # stop processing the mouse capture self.ReleaseMouse() if self.lastTarget is not None: # unhighlight last window if we have highlighted one HighlightWindow(self.lastTarget) self.endFunc()