|
-
Sep 11th, 2000, 11:11 PM
#1
hey there everybody... umm... quick question...
i know how to get the raw cursor position on the
screen with an API call... but is it possible to
get cursor position _relative_ to a form or
control, such as a picture box?
Dubious, 2K
-
Sep 12th, 2000, 09:15 AM
#2
transcendental analytic
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Sep 12th, 2000, 03:49 PM
#3
Add the following to a Form with a Timer.
Code:
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
Dim PT As POINTAPI
GetCursorPos PT
Cls
Print PT.x - (Me.Left / Screen.TwipsPerPixelX) & "," & PT.y - (Me.Top / Screen.TwipsPerPixelY)
End Sub
-
Sep 13th, 2000, 03:12 AM
#4
transcendental analytic
What are you trying to demonstrate meg? the declaration of ClienttoWindow but not the usage?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Sep 15th, 2000, 02:00 PM
#5
Maybe I don't get the point, but for the same problem, i.e.
getting the cursor coordinates (x,y) I'm just using standard VB stuff. The x and y will be given in the used scalemode (i.e. pixel, twips or whatever)
/code
sub picturebox.mouse_move
ActualCursorX=X
ActualCursorY=Y
end sub
/code
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Sep 15th, 2000, 02:15 PM
#6
the answer
Private Declare Function SetCapture Lib "user32.dll" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32.dll" (ByVal hWnd As Long) As Long
Private Sub Command1_Click()
SetCapture Picture1.hWnd
End Sub
Private Sub Command2_Click()
ReleaseCapture Picture1.hWnd
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print X, Y
End Sub
by first click of the mouse the picturebox get the event and it make automaticaly a ReleasCapture
by the next click of the mouse the right control or form get the event
-
Sep 15th, 2000, 04:09 PM
#7
Fanatic Member
if you use SetCapture & Release Capture, then other windows won't proccess clicks, it will all be sent to your program
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|