home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / ch_code / ch04 / dragdrop / dragdrop.frm (.txt) next >
Encoding:
Visual Basic Form  |  1997-02-20  |  3.3 KB  |  101 lines

  1. VERSION 5.00
  2. Begin VB.Form DragDrop 
  3.    Caption         =   "DragDrop Demo"
  4.    ClientHeight    =   4890
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   5580
  8.    LinkTopic       =   "Form2"
  9.    ScaleHeight     =   4890
  10.    ScaleWidth      =   5580
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.PictureBox Picture1 
  13.       Height          =   3015
  14.       Left            =   240
  15.       ScaleHeight     =   2955
  16.       ScaleWidth      =   5115
  17.       TabIndex        =   2
  18.       Top             =   825
  19.       Width           =   5175
  20.    End
  21.    Begin VB.TextBox Text1 
  22.       DragMode        =   1  'Automatic
  23.       Height          =   330
  24.       Left            =   2925
  25.       TabIndex        =   1
  26.       Top             =   225
  27.       Width           =   2490
  28.    End
  29.    Begin VB.Label Label2 
  30.       BorderStyle     =   1  'Fixed Single
  31.       Caption         =   $"DragDrop.frx":0000
  32.       BeginProperty Font 
  33.          Name            =   "MS Sans Serif"
  34.          Size            =   9.75
  35.          Charset         =   0
  36.          Weight          =   400
  37.          Underline       =   0   'False
  38.          Italic          =   0   'False
  39.          Strikethrough   =   0   'False
  40.       EndProperty
  41.       Height          =   810
  42.       Left            =   255
  43.       TabIndex        =   3
  44.       Top             =   3975
  45.       Width           =   5160
  46.    End
  47.    Begin VB.Label Label1 
  48.       BorderStyle     =   1  'Fixed Single
  49.       DragMode        =   1  'Automatic
  50.       Height          =   330
  51.       Left            =   210
  52.       TabIndex        =   0
  53.       Top             =   225
  54.       Width           =   2490
  55.    End
  56. Attribute VB_Name = "DragDrop"
  57. Attribute VB_GlobalNameSpace = False
  58. Attribute VB_Creatable = False
  59. Attribute VB_PredeclaredId = True
  60. Attribute VB_Exposed = False
  61. Option Explicit
  62. Private Sub Form_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
  63.     If State = 0 Then Source.MousePointer = 12
  64.     If State = 1 Then Source.MousePointer = 0
  65. End Sub
  66. Private Sub Label1_DragDrop(Source As Control, X As Single, Y As Single)
  67. If TypeOf Source Is TextBox Then
  68.     Label1.Caption = Source.Text
  69. End If
  70. End Sub
  71. Private Sub Label1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
  72.     MousePointer = vbDefault
  73. End Sub
  74. Private Sub Label2_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
  75.     If State = 0 Then Source.MousePointer = 12
  76.     If State = 1 Then Source.MousePointer = 0
  77. End Sub
  78. Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
  79. Dim imgName
  80. If TypeOf Source Is TextBox Then
  81.     imgName = Source.Text
  82.     imgName = Source.Caption
  83. End If
  84. On Error GoTo NOIMAGE
  85. Picture1.Picture = LoadPicture(imgName)
  86. Exit Sub
  87. NOIMAGE:
  88.     MsgBox "This is not a valid file name"
  89. End Sub
  90. Private Sub Picture1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
  91.     MousePointer = vbDefault
  92. End Sub
  93. Private Sub Text1_DragDrop(Source As Control, X As Single, Y As Single)
  94. If TypeOf Source Is Label Then
  95.     Text1.Text = Label1.Caption
  96. End If
  97. End Sub
  98. Private Sub Text1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
  99.     MousePointer = vbDefault
  100. End Sub
  101.