鼠标依次递减?可以自定义递减数值怎么写?
答案:1 悬赏:80 手机版
解决时间 2021-04-28 12:14
- 提问者网友:斑駁影
- 2021-04-27 23:22
Y坐标不变,X坐标递减或者递加,应该怎么写?递加或者递减的数值最好可以自定义。求高手详细解答!谢谢了!
最佳答案
- 五星知识达人网友:神鬼未生
- 2021-04-28 00:42
Private Type POINTAPI '定义坐标的类型
X As Long
Y As Long
End Type
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
'5480.88 3472.43
Private Sub Form_Load()
Dim I As Double
Dim J As Double
Me.Height = 12330
Me.Width = 14865
Me.Scale (398924.16, 4323446.22)-(404405.04, 4319973.79) '自定义坐标系
For I = 399617.646 To 404405.04 Step 1097.376 '画网格线
CurrentX = I '标注
CurrentY = 4319973.79 + 100
Print CStr(I)
Me.Line (I, 4319973.79)-(I, 4323446.22)
Next
For J = 4322752.734 To 4320667.276 Step -693.486
CurrentX = 398520.27 + 400
CurrentY = J - 50
Print J
Me.Line (398520.27, J)-(404405.04, J)
Next
Me.PSet (401114.912, 4321362.762), vbRed '测试它与label1 label2 的值是否相差很大
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MousePS As POINTAPI
'Dim ps As POINTAPI
GetCursorPos MousePS '获取鼠标在屏幕的位置
ScreenToClient Me.hwnd, MousePS '把鼠标的屏幕位置换成窗口位置
'*********************************************************
'***算式(1)(2)是把窗口坐标换成自定义的坐标
'***点(398924.16, 4323446.22)为自定义坐标系在窗口的顶点
'***982 791 为窗口坐标时坐标的最大值
'***5480.88 3472.43 为自定义坐标 X Y 方向上的最大差值
'*********************************************************
Label1 = 398924.16 + (MousePS.X / 982) * 5480.88 '算式 (1)
Label2 = 4319973.79 + (791 - MousePS.Y) / 791 * 3742.43 '算式 (2)
End Sub
X As Long
Y As Long
End Type
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
'5480.88 3472.43
Private Sub Form_Load()
Dim I As Double
Dim J As Double
Me.Height = 12330
Me.Width = 14865
Me.Scale (398924.16, 4323446.22)-(404405.04, 4319973.79) '自定义坐标系
For I = 399617.646 To 404405.04 Step 1097.376 '画网格线
CurrentX = I '标注
CurrentY = 4319973.79 + 100
Print CStr(I)
Me.Line (I, 4319973.79)-(I, 4323446.22)
Next
For J = 4322752.734 To 4320667.276 Step -693.486
CurrentX = 398520.27 + 400
CurrentY = J - 50
Print J
Me.Line (398520.27, J)-(404405.04, J)
Next
Me.PSet (401114.912, 4321362.762), vbRed '测试它与label1 label2 的值是否相差很大
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MousePS As POINTAPI
'Dim ps As POINTAPI
GetCursorPos MousePS '获取鼠标在屏幕的位置
ScreenToClient Me.hwnd, MousePS '把鼠标的屏幕位置换成窗口位置
'*********************************************************
'***算式(1)(2)是把窗口坐标换成自定义的坐标
'***点(398924.16, 4323446.22)为自定义坐标系在窗口的顶点
'***982 791 为窗口坐标时坐标的最大值
'***5480.88 3472.43 为自定义坐标 X Y 方向上的最大差值
'*********************************************************
Label1 = 398924.16 + (MousePS.X / 982) * 5480.88 '算式 (1)
Label2 = 4319973.79 + (791 - MousePS.Y) / 791 * 3742.43 '算式 (2)
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯