home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / drag&d2a / drag.frm (.txt)
Encoding:
Visual Basic Form  |  1999-09-10  |  4.4 KB  |  146 lines

  1. VERSION 2.00
  2. Begin Form frmDrag 
  3.    Caption         =   "Drag & Use"
  4.    ClientHeight    =   3015
  5.    ClientLeft      =   1890
  6.    ClientTop       =   3255
  7.    ClientWidth     =   6435
  8.    Height          =   3705
  9.    Left            =   1830
  10.    LinkTopic       =   "Form2"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   3015
  14.    ScaleWidth      =   6435
  15.    Top             =   2625
  16.    Width           =   6555
  17.    Begin CommandButton Command1 
  18.       Caption         =   "Exit"
  19.       Height          =   375
  20.       Left            =   5760
  21.       TabIndex        =   3
  22.       Top             =   2640
  23.       Width           =   735
  24.    End
  25.    Begin DriveListBox Drive1 
  26.       Height          =   315
  27.       Left            =   240
  28.       TabIndex        =   2
  29.       Top             =   120
  30.       Width           =   1935
  31.    End
  32.    Begin FileListBox File1 
  33.       FontBold        =   -1  'True
  34.       FontItalic      =   0   'False
  35.       FontName        =   "System"
  36.       FontSize        =   9.75
  37.       FontStrikethru  =   0   'False
  38.       FontUnderline   =   0   'False
  39.       Height          =   1950
  40.       Left            =   2400
  41.       Pattern         =   "*.txt;*.bmp;*.exe;*.hlp"
  42.       TabIndex        =   1
  43.       Top             =   120
  44.       Width           =   2055
  45.    End
  46.    Begin DirListBox Dir1 
  47.       FontBold        =   -1  'True
  48.       FontItalic      =   0   'False
  49.       FontName        =   "System"
  50.       FontSize        =   9.75
  51.       FontStrikethru  =   0   'False
  52.       FontUnderline   =   0   'False
  53.       Height          =   1380
  54.       Left            =   240
  55.       TabIndex        =   0
  56.       Top             =   600
  57.       Width           =   1935
  58.    End
  59.    Begin Image Image2 
  60.       Height          =   495
  61.       Left            =   2040
  62.       Top             =   2160
  63.       Width           =   2550
  64.    End
  65.    Begin Image Image1 
  66.       BorderStyle     =   1  'Fixed Single
  67.       Height          =   1935
  68.       Left            =   4680
  69.       Stretch         =   -1  'True
  70.       Top             =   120
  71.       Width           =   1725
  72.    End
  73.    Begin Menu mnufile 
  74.       Caption         =   "&File"
  75.       Begin Menu mnuback 
  76.          Caption         =   "Back to EasyWin"
  77.       End
  78.    End
  79. Sub Command1_Click ()
  80. End Sub
  81. Sub Dir1_Change ()
  82.     file1.Path = Dir1.Path
  83. End Sub
  84. Sub Drive1_Change ()
  85.     Dir1.Path = Drive1.Drive
  86. End Sub
  87. Sub File1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  88.     file1.DragIcon = Drive1.DragIcon
  89.     file1.Drag
  90. End Sub
  91. Sub Form_Load ()
  92.     frmdrag.Width = 6525
  93.     frmdrag.Height = 3500
  94. End Sub
  95. Sub Image1_DragDrop (Source As Control, X As Single, Y As Single)
  96.     ' Get last three letters of the dragged filename
  97.     temp = Right$(file1.FileName, 3)
  98.     ' If dragged file is in the root, append filename.
  99.     If Mid(file1.Path, Len(file1.Path)) = "\" Then
  100.       dropfile = file1.Path & file1.FileName
  101.     ' If dragged file is not in root, append "\" and filename.
  102.     Else
  103.       dropfile = file1.Path & "\" & file1.FileName
  104.     End If
  105.       
  106.     image1.Picture = LoadPicture("")
  107.     Select Case temp
  108.     Case "txt"
  109.         X = Shell("Notepad " + dropfile, 1)
  110.     Case "bmp", "wmf", "rle", "ico"
  111.         image1.Picture = LoadPicture(dropfile)
  112.     Case "exe"
  113.         X = Shell(dropfile, 1)
  114.     Case "hlp"
  115.         X = Shell("WinHelp " + dropfile, 1)
  116.     Case "wri"
  117.         X = Shell("write " + dropfile, 1)
  118. 'add your own case example
  119.     'case "mak"
  120.     '   x = shell("c:\vb\vb.exe + dropfile, 1)
  121.     Case Else
  122.         nl = Chr$(10) + Chr$(13)
  123.         msg = "Try one of these file types:"
  124.         msg = nl + msg + nl + nl + "     .txt, .bmp, .exe, .hlp"
  125.         MsgBox msg
  126.     End Select
  127. End Sub
  128. Sub Image1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  129.     Select Case State
  130.     Case 0
  131.         ' Display a new icon when the source
  132.         ' enters the drop area.
  133.         file1.DragIcon = Dir1.DragIcon
  134.     Case 1
  135.         ' Display the original DragIcon when the source
  136.         ' leaves the drop area.
  137.         file1.DragIcon = Drive1.DragIcon
  138.     End Select
  139. ' Note that Dir1.DragIcon and Drive1.DragIcon have been
  140. ' set at design time. This allows you to load the "Enter
  141. ' and "Leave" icons for File1 at runtime without requiring
  142. ' that the user has those icons are on disc.
  143. End Sub
  144. Sub mnuback_Click ()
  145. End Sub
  146.