在窗体上有好多的直线,我想用鼠标实现他的功能。
鼠标点击任意一条直线的任意部位时,被点上的直线变为红色,然后按住鼠标的左键拖动直线放在任意的位置。
鼠标点击任意一条直线的任意部位时,被点上的直线变为红色,然后按住鼠标的左键拖动直线放在任意的位置。
解决方案 »
- SQL语句怎么表达
- VsFlexGrid的输入技巧问题。
- DataReport怎样添加合计"列"啊???急,在线等
- [急!]如何响应运行添加的控件的事件
- 奇怪的ACCESS 的SQL语句查询问题。
- 如何让一个窗体A永远的在另一个窗体B之上(无论进行什么操作),当窗体B隐藏时,窗体A也隐藏。注意不是窗体A在所有窗体之上。高分相赠!
- 用VB如何生成随机数的序列?
- 急!richtextbox实现彩色文本的问题!
- 有谁知道api函数Sendmessage 的详细用法
- 不好意思,本来我有2000多分,怎么最多只能让我给34分。只能请各位哥们帮帮忙,谁有workflow for exchange,不胜感谢。
- 如果只知道文件扩展名,如何找到与之关联的(大小)图标呢?
- 请高手指路:怎样做帮助文件啊?我做好了程序,想做一个帮助文件(最好是动态的)!给高分!
line.forecolor=vbred
按住鼠标的左键拖动直线放在任意的位置:
line.move
line1.forecolor=vbred
end sub移动:Dim iPx As Integer, iPy As Integer, iMy As Integer
Dim bb As Boolean '控件拖动MouseDown/MouseUp判断
Private Sub line1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
bb = True
iPx = X
iPy = Y
MousePointer = 5End SubPrivate Sub line1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If bb Then
line1.Move stop1.Left + X - iPx, line1.Top + Y - iPy
End If
End SubPrivate Sub line1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
bb = False
MousePointer = 0End Sub
例如用Frame控件,把高度设小一点,然后在Click事件中改变背景色,在MouseDown事件中移动控件
具体的我没试,仅供参考
不太好弄。
Private Sub Frame1_Click()
Frame1.BackColor = vbRed
End Sub
Private Sub Frame1_Click()
Frame1.BackColor = vbRed
End Sub
建立一个数组,判断鼠标点击时选中哪条线(X,Y),再重画
这样也可以吧!没有楼上简单~_~
line1.forecolor=vbred
end sub移动:Dim iPx As Integer, iPy As Integer, iMy As Integer
Dim bb As Boolean '控件拖动MouseDown/MouseUp判断
Private Sub line1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
bb = True
iPx = X
iPy = Y
MousePointer = 5End SubPrivate Sub line1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If bb Then
line1.Move stop1.Left + X - iPx, line1.Top + Y - iPy
End If
End SubPrivate Sub line1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
bb = False
MousePointer = 0End Sub