MouseMoveWin
Mouse movement event with window coordinates.
[event]
MouseMoveWin([in] short button, [in] short shift, [in] int winX, [in] int winY)
This event will be called when the user moves the mouse.
Mouse events must be enabled first - see enableMouseEvents
and
enableMouseMoveEvents
.
The event will be called with four arguments:
button
: the mouse button number - one ofvbLeftButton
,vbMiddleButton
, orvbRightButton
; or 0 if no button is pressedshift
: the shift/control/alt bit mask, which contains zero or more bit flags fromvbShiftMask
,vbCtrlMask
, andvbAltMask
winX, winY
: the position where the mouse pointer is located, in window coordinates
convertWindowToPDFCoords2
.
This event is similar to MouseMove2
, except that (a) it is called
with window coordinates instead of PDF coordinates, and (b) it will be
called even if the mouse is moved outside of a PDF page.
IMPORTANT: In order to receive MouseMoveWin
and
MouseUpWin
events when the mouse is outside the XpdfViewer window
(not just outside the PDF pages), you must
call SetCapture
in the MouseDownWin
event handler.
See the example below.
VB:
viewer.enableMouseEvents = True
viewer.enableMouseMoveEvents = True
...
Private Sub viewer_MouseDownWin(button As Integer, shift As Integer, _
winX As Long, winY As Long) _
Handles viewer.MouseDownWin
Dim pg As Long, x As Double, y As Double
viewer.convertWindowToPDFCoords2(winX, winY, pg, x, y)
' ... use pg, x, y ...
' capture the mouse so we receive MoveWin and UpWin events outside the window
SetCapture(viewer.windowHandle)
End Sub
Private Sub viewer_MouseUpWin(button As Integer, shift As Integer, _
winX As Long, winY As Long) _
Handles viewer.MouseUpWin
' release the capture that was initiated in MouseDownWin
ReleaseCapture()
Dim pg As Long, x As Double, y As Double
viewer.convertWindowToPDFCoords2(winX, winY, pg, x, y)
' ... use pg, x, y ...
End Sub
Private Sub viewer_MouseMoveWin(button As Integer, shift As Integer, _
winX As Long, winY As Long) _
Handles viewer.MouseMoveWin
Dim pg As Long, x As Double, y As Double
viewer.convertWindowToPDFCoords2(winX, winY, pg, x, y)
' ... use pg, x, y ...
End Sub
Private Sub viewer_MouseDoubleClickWin(button As Integer, shift As Integer, _
winX As Long, winY As Long) _
Handles viewer.MouseDoubleClickWin
Dim pg As Long, x As Double, y As Double
viewer.convertWindowToPDFCoords2(winX, winY, pg, x, y)
' ... use pg, x, y ...
End Sub