【VB开源代码栏目提醒】:网学会员--在 VB开源代码编辑为广大网友搜集整理了:Ex13_13.frm绩等信息,祝愿广大网友取得需要的信息,参考学习。
VERSION 5.00
Begin VB.Form Ex13_13
Caption = "控件拖放应用实例"
ClientHeight = 4455
ClientLeft = 60
ClientTop = 450
ClientWidth = 4995
LinkTopic = "Form1"
ScaleHeight = 4455
ScaleWidth = 4995
StartUpPosition = 3 '窗口缺省
Begin VB.FileListBox File1
Height = 2250
Left = 2520
TabIndex = 4
Top = 240
Width = 2055
End
Begin VB.DirListBox Dir1
Height = 1770
Left = 240
TabIndex = 3
Top = 720
Width = 1935
End
Begin VB.DriveListBox Drive1
Height = 300
Left = 240
TabIndex = 2
Top = 240
Width = 1935
End
Begin
VB.PictureBox Picture1
Height = 1575
Left = 240
ScaleHeight = 1515
ScaleWidth = 4515
TabIndex = 0
Top = 2760
Width = 4575
End
Begin VB.Label Label1
Caption = "Label1"
Height = 255
Left = 2520
TabIndex = 1
Top = 240
Width = 2055
End
End
Attribute VB_Name = "Ex13_13"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_Load()
Label1.Visible = False
'设置文件的各种类型
File1.Pattern = "*.bmp;*.wmf;*.ico;*.gif;*.jpg"
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
'鼠标在文件列表框按下时,先将标签Label1 移动到File1位置,
'然后启动标签的拖动,用空标签显示文件的拖动。
Private Sub File1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single) '在File1 按下鼠标
Dim D
D = TextHeight("A") '取得一行的高度。
Label1.Move File1.Left, File1.Top + Y - D / 2, File1.Width, D
Label1.Drag 1 '拖标签轮廓。
End Sub
'当拖动进入Dirl 和Drivel 控件时,
'鼠标指针为禁止形状;当拖动离开时,鼠标指针为系统默认。
Private Sub Dir1_DragOver(Source As Control, _
X As Single, Y As Single, State As Integer)
If State = 0 Then Source .MousePointer = 12 '鼠标指针为禁止形状
If State = 1 Then Source .MousePointer = 0 '鼠标指针为
系统默认
End Sub
Private Sub Drive1_DragOver(Source As Control, _
X As Single, Y As Single, State As Integer)
If State = 0 Then Soure .MousePointer = 12
If State = 1 Then Soure .MousePointer = O
End Sub
'用鼠标指针形状显示不能拖动到驱动器
列表框,目录列表框和窗体的空白区
Private Sub Form_Dragover(Source As Control, _
X As Single, Y As Single, State As Integer)
If State = 0 Then Source.MousePointer = 12
If State = 1 Then Source.MousePointer = 0
End Sub
Private Sub Picture1_DragDrop(Source As Control, _
X As Single, Y As Single) '将拖动的图形装载到图片框
Picture1.Picture = LoadPicture(File1.Path + "\" + File1.FileName)
End Sub