如何在鼠标左键按下时,一直执行Form1.PSet (X, Y)呢?
我想利用PSet (X, Y)模仿个画笔。
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Text = X
Text2.Text = Y
Form1.PSet (X, Y)
End Sub

解决方案 »

  1.   

    只需要添加一点判断条件就行了,
    If (Button = 1) Then
        Text1.Text = X
        Text2.Text = Y
        Form1.PSet (X, Y)
    End If
    有个缺点就是,当鼠标移动太快时,会出现“断线”。
      

  2.   

    说了要给分哦!
    代码如下:
    Private Sub Form_mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    if button=1 then
    currentx=x
    currenty=y
    endif
    End Sub
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (Button = 1) Then  
        Form1.line(currentx,currenty)- (X, Y) 
    End If 
    End Sub
    这样就可以模仿画笔了!
      

  3.   

    -_-!
    写好了才发现楼上都有了。。
    楼上的代码在最前加个Private CurrentX As Single,CurrentY As Single
      

  4.   

    你的代码实现的效果正是我所预想的。
    能否给解释一下其中的关键点呢?我不是很理解。
    Form1.line(currentx,currenty)- (X, Y)中的(currentx,currenty)和(X, Y)是不是有个先后关系?有个先来后到?
    请指点。
      

  5.   

    能否给解释一下其中的关键点呢?我不是很理解。 
    Form1.line(currentx,currenty)- (X, Y)中的(currentx,currenty)和(X, Y)是不是有个先后关系?有个先来后到? 
    请指点。
      

  6.   

    '当Me.ScaleMode = 3,并去掉Me.Line (x0, Y0)-(X, Y), RGB(0, 0, 255), BF后面的“,BF”时,所画图和3楼一样
    '改变Me.ScaleMode值,可以画出不同粗细的线条。不过有的线有点难看。
    '要画出好看的线,并画了各种粗细并连续的线条,只用有关画笔的API。Option Explicit
    Private x0 As Integer, Y0 As Integer
    Private Sub Form_Load()
            Me.ScaleMode = 3
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
            If Button = 1 Then
               Me.PSet (X, Y), RGB(255, 0, 0)
               Me.Line (x0, Y0)-(X, Y), RGB(0, 0, 255), BF
            End If
            x0 = X: Y0 = Y
    End Sub