|
-
Feb 24th, 2000, 11:24 PM
#1
Thread Starter
Hyperactive Member
-
Feb 25th, 2000, 02:23 AM
#2
Hyperactive Member
This isn't tested Matt, but if you have any problems let me know:
In a module:
Code:
Type POINT_TYPE
x As Long
y As Long
End Type
Public Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINT_TYPE) As Long
In a timer in your form:
Code:
Dim coord As POINT_TYPE ' receives coordinates of cursor
Dim retval As Long ' return value
retval = GetCursorPos(coord) ' read cursor location
If coord.y > 6000 then
picture1.top = picture1.top - (coord.y - 6000)
End If
-
Feb 25th, 2000, 03:34 AM
#3
Wade's idea is a good one and will work, but you need to make some modification to the code, first of all, the Coords are returned in Pixels, so you'll need to do a Conversion, also, the Coords are returned relative to the Top, Left Corner of the Screen, so you'd need to Adjust them to be from the Top, Left of your Form, you can do this with the ScreenToClient API, ie.
Code:
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib "user32" Alias "ScreenToClient" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Sub Timer1_Timer()
Dim tPOINT As POINTAPI
Call GetCursorPos(tPOINT)
Call ScreenToClient(hWnd, tPOINT)
If tPOINT.y > ScaleY(6000, vbTwips, vbPixels) Then Picture1.Top = Picture1.Top - (ScaleY(tPOINT.y, vbPixels, vbTwips) - 6000)
End Sub
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
|