VB程序员博客

VB程序开发

例如:
鼠标点击拖动后实现效果:
###########################################

问题二:
画出直线或任意线(线条样式为虚线或者实线and点画线),在画线结束后线的末尾显示一个箭头。
例如:实现效果
————————————–>
1, 不懂什么意思
2,
    Me.Line (1, 1000)-(1000, 1000)
    Me.CurrentX = 1000
    Me.CurrentY = 900
    Print ">"
Picture1.OLEDragMode=ManualDragDrop事件:拖放事件,相当于MouseDown、MouseMove和MouseUp的组合。 
DragOver事件:鼠标在拖放过程中就会产生DragOver事件。能写上代码么?我是个新手!谢谢!第一个问题就是画出一条直线 而直线是被图片代替的!
画出一条直线 而直线是被图片代替的!??? 看不懂你在说啥 ??

既然直线是图片, 你还画什么线? 直接PaintPicture图片不就好了吗?

Private Sub Command1_Click()
  Me.Cls
  Me.CurrentX = 100: Me.CurrentY = 500 '指定位置
  Me.Print "———–>"
End Sub注:带箭头的直线和任意线是鼠标随意拖动画出来的下个CAD控件。利用下面代码, 座标已给你定好了, 你自己在座标位置 PaintPicture, 或将你的Picture或Image控件移到该位置, 因为不知道你真的想干什么, 不想浪费时间.

Dim X1!, Y1!, X2!, Y2!
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  If Button = 1 Then
      Me.DrawMode = 7: Me.DrawStyle = 1
      X1 = X: X2 = X
      Y1 = Y: Y2 = Y
  End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  If Button = 1 Then
      Me.Line (X1, Y1)-(X2, Y2), QBColor(10)
      Me.Line (X1, Y1)-(X, Y), QBColor(10)
      X2 = X: Y2 = Y
  End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  If Button = 1 Then
      Me.DrawMode = 13: Me.DrawStyle = 0
      Me.Line (X1, Y1)-(X, Y), QBColor(10)
      Me.CurrentX = X: Me.CurrentY = Y - (Me.TextHeight("-") 2)
      Me.Print "->"
  End If
End Sub


标签: , , ,