home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / drag&d1a / mainfo~1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-08-22  |  3.3 KB  |  65 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Drag & Drop Demonstration"
  5.    ClientHeight    =   8235
  6.    ClientLeft      =   240
  7.    ClientTop       =   1545
  8.    ClientWidth     =   6585
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    OLEDropMode     =   1  'Manual
  13.    ScaleHeight     =   8235
  14.    ScaleWidth      =   6585
  15.    StartUpPosition =   2  'CenterScreen
  16. Attribute VB_Name = "Form1"
  17. Attribute VB_GlobalNameSpace = False
  18. Attribute VB_Creatable = False
  19. Attribute VB_PredeclaredId = True
  20. Attribute VB_Exposed = False
  21. Private i As Integer ' Used for the loop
  22. Sub SetSplashText(Text As String)
  23.     ' This sub will set the text on the splash screen.
  24.     frmSplash.lblText = Text
  25. End Sub
  26. Private Sub Form_Load()
  27. End Sub
  28. Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
  29.     ' To detect files that is dropped to the control/form, we must the the Data-property.
  30.     ' However, the data is an array, and we can't use ubound or lbound to detect the
  31.     ' beginning or end of the array. So we'll have to test until we find the end.
  32.     ' The Data.Files contains files dropped onto the from/control, however, this is
  33.     ' an array, so to use it, we'll have to type like this: Debug.Print Data.Files(1).
  34.     ' This is the tricky part. Determinate the code below.
  35.     SetSplashText "Processing information..." ' Set splash-screen text
  36.     Me.Hide ' Hide main form
  37.     frmSplash.Show ' Show splash-screen
  38.     ' Remember, do NOT show it modally, it will cause the splash screen to be there and
  39.     ' nothing will happend, cause the program will wait until the splash screen is unloaded.
  40.     For i = 1 To 9999 ' Start the loop
  41.         ' Remember, that the number 9999 is the last number we shall test in the array.
  42.         ' If you want to test less, then change the 9999 to some other number.
  43.         ' For example 10. Then it should be like this: For i = 1 To 10
  44.         ' In this example, we will print the filenames dragged onto the form to the
  45.         ' debug-window.
  46.         On Error Resume Next
  47.         ' If the array-number doesn't exist then skip it and go on with the next array
  48.         ' number.
  49.         Debug.Print Data.Files(i) ' Print the filesname to the debug-window
  50.     Next i ' Continue the loop
  51.     ' The tricky with this is that it will loop until it have done it 9999 times, wich
  52.     ' may take some time. A good idea is to show a splash screen while doing this.
  53.     Unload frmSplash ' Remove splash-screen
  54.     Me.Show ' Show main form
  55.     ' X As Single, Y As Single
  56.     ' Some other variables to use is Button.
  57.     ' This variable detects with wich button the user dragged the files onto the form.
  58.     ' Eg. the right mouse-button, 1 means left mouse-button, 2 means right mouse-button.
  59.     ' Use the shift-variable to detect the state of alt, ctrl and shift. Consult the VB
  60.     ' help-file for help about this.
  61.     ' The X as Y variables are values where the mouse is on the screen when dropping the
  62.     ' files onto the form. Remarks: These values are not the same as the GetCursorPos API.
  63.     ' Eg. If X contains 1000, it's maybe 100 when using the GetCursorPos API.
  64. End Sub
  65.