用VB2010制作一个像WIN7自带的看图软件一样,可以使图片跟随鼠标或滚动条移动,要求能平滑移动。
展开全部
Option Explicit
Private Declare Function GetCursorPos Lib"user32"(lpPoint As POINTAPI) As Long
PrivateType POINTAPI
X AsLong
Y AsLong
End Type
Dim p AsPOINTAPI, X1 As Long, Y1 As Long
Private Sub form1_load()
Picture1.picture=loadpicture()
end sub
Private Sub Picture1_MouseDown(Button As integer, Shift As Integer, X As Single, Y As Single)
Timer1.Interval = 10
Timer1.Enabled = True '注意timer1.enabled初始关
GetCursorPos p
x1 = p.X
Y1 = p.Y
EndSub
Private Sub Picture1_MouseUp(Button AsInteger, Shift AsInteger, X AsSingle, Y AsSingle)
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
GetCursorPos p
Form1.Left =Picture1.Left + (p.X - X1) * 15
Form1.Top = Picture1.Top + (p.Y - Y1) * 15
X1 = p.X
Y1 = p.Y
End Sub
Private Declare Function GetCursorPos Lib"user32"(lpPoint As POINTAPI) As Long
PrivateType POINTAPI
X AsLong
Y AsLong
End Type
Dim p AsPOINTAPI, X1 As Long, Y1 As Long
Private Sub form1_load()
Picture1.picture=loadpicture()
end sub
Private Sub Picture1_MouseDown(Button As integer, Shift As Integer, X As Single, Y As Single)
Timer1.Interval = 10
Timer1.Enabled = True '注意timer1.enabled初始关
GetCursorPos p
x1 = p.X
Y1 = p.Y
EndSub
Private Sub Picture1_MouseUp(Button AsInteger, Shift AsInteger, X AsSingle, Y AsSingle)
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
GetCursorPos p
Form1.Left =Picture1.Left + (p.X - X1) * 15
Form1.Top = Picture1.Top + (p.Y - Y1) * 15
X1 = p.X
Y1 = p.Y
End Sub
追问
我试了VB6可以实现 可是.net不能实现图片移动不知道该如何实现
追答
.net没用过,不好意思,帮不了你了。
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询