1。控件有个DRAGMODE属性设置成AUTOMATIC,然后在它的拖动事件编写相关代码;
2。如果你是想LABEL随着鼠标动,可以用GETCURSORPOS API函数获得位置,然后在MOVE事件或者TIMER事件中编写相关代码。

解决方案 »

  1.   

    嗬嗬,可以使用一个label1和一个image1来模拟:设置image1使用flat的外观,要边界,透明,不可视。代码:Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        
        With Label1
            x0 = .Left - X
            y0 = .Top - Y
            Image1.Left = .Left
            Image1.Top = .Top
            Image1.Width = .Width
            Image1.Height = .Height
            .Visible = False
        End With
        
    End SubPrivate Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)    If Button <> 1 Then Exit Sub
        
        With Image1
            .Visible = True
            .Left = x0 + X
            .Top = y0 + Y
        End WithEnd SubPrivate Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)    With Image1
            Label1.Left = .Left
            Label1.Top = .Top
            Label1.Visible = True
            .ZOrder 1
        End With
        
    End Sub效果很好。可以加分吧?
      

  2.   

    使用DragMode属性 + DragDrop事件,就不知道鼠标按下的时候,准确的XY坐标值。因为DragMode=Automatic的话,将忽略所有的鼠标按键。
      

  3.   

    漏了一句,在.ZOrder 1之前,还需要加上.Visible = False
      

  4.   

    哈哈,好呀,那email呢?我用VB5,你的应该也是吧?
      

  5.   

    我用VB6
    [email protected]
    5分钟后,我打开邮箱看
      

  6.   

    其实不用邮寄了,你分别创建文本文件,将以下代码拷贝,命名为form1.frm,双击打开并运行:
    VERSION 5.00
    Begin VB.Form Form1 
       Caption         =   "Form1"
       ClientHeight    =   5130
       ClientLeft      =   60
       ClientTop       =   345
       ClientWidth     =   7965
       LinkTopic       =   "Form1"
       ScaleHeight     =   5130
       ScaleWidth      =   7965
       StartUpPosition =   3  'Windows Default
       Begin VB.Label Label1 
          BackStyle       =   0  'Transparent
          Caption         =   "我是能使用鼠标移动的标签。试试?"
          Height          =   495
          Left            =   240
          TabIndex        =   0
          Top             =   360
          Width           =   3255
       End
       Begin VB.Image Image1 
          Appearance      =   0  'Flat
          BorderStyle     =   1  'Fixed Single
          Height          =   615
          Left            =   240
          Top             =   1200
          Visible         =   0   'False
          Width           =   1335
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Dim x0 As Single, y0 As Single
    Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        
        With Label1
            x0 = .Left - X
            y0 = .Top - Y
            Image1.Left = .Left
            Image1.Top = .Top
            Image1.Width = .Width
            Image1.Height = .Height
            .Visible = False
        End With
        
    End SubPrivate Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)    If Button <> 1 Then Exit Sub
        
        With Image1
            .Visible = True
            .Left = x0 + X
            .Top = y0 + Y
        End WithEnd SubPrivate Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)    With Image1
            Label1.Left = .Left
            Label1.Top = .Top
            Label1.Visible = True
            .Visible = False
            .ZOrder 1
        End With
        
    End Sub