OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   Get the position of the mouse (http://forum.oberonplace.com/showthread.php?t=1601)

gbottesi 30-06-2006 14:15

Get the position of the mouse
Hi people. This is the question:

Is there any posibility to get the position of the mouse as it appears in the low left corner in the status bar?

Thanks in advance.


shelbym 30-06-2006 15:30

Mouse Position
Sure you can get the mouse Position of were a user clicks. This will keep looping until l you press "ESC". Also the messagebox lets you know if the shift, control or Alt key was depressed when clicked.


Sub MousePosition()

Dim x As Double, y As Double
Dim Shift As Long
Dim b As Boolean
Dim txtKey As String

b = False
txtKey = "No Key"

While Not b
    b = ActiveDocument.GetUserClick(x, y, Shift, 10, False, cdrCursorEyeDrop)
        If Not b Then
            If (Shift And 1) <> 0 Then txtKey = "Shift" ' Shift depressed
            If (Shift And 2) <> 0 Then txtKey = "Ctrl" ' Ctrl depressed
            If (Shift And 4) <> 0 Then txtKey = "Alt" ' Alt depressed
            MsgBox "x: " & x & " y: " & y & Chr(13) & txtKey & " was depressed"
        End If
End Sub

Hope it helps,


gbottesi 17-07-2006 10:51

Thanks shelby, but I was thinking if there's a way to get the mouse position as it moves, like you can see in the lower left corner. If anybody knows, i'll appreciate the answer.

Alex 17-07-2006 20:55

Well, technically it should be possible. But you will definitely have to use Windows API.

Here is some code that can show you how to translate the current mouse coordinates into the document coordinates:


All times are GMT -5. The time now is 09:28.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com