嗬嗬,可以使用一个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
其实不用邮寄了,你分别创建文本文件,将以下代码拷贝,命名为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
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效果很好。可以加分吧?
[email protected]
5分钟后,我打开邮箱看
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