home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form1
- BorderStyle = 1 'Fixed Single
- Caption = "Drag & Drop Demonstration"
- ClientHeight = 8235
- ClientLeft = 240
- ClientTop = 1545
- ClientWidth = 6585
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- OLEDropMode = 1 'Manual
- ScaleHeight = 8235
- ScaleWidth = 6585
- StartUpPosition = 2 'CenterScreen
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private i As Integer ' Used for the loop
- Sub SetSplashText(Text As String)
- ' This sub will set the text on the splash screen.
- frmSplash.lblText = Text
- End Sub
- Private Sub Form_Load()
- End Sub
- Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
- ' To detect files that is dropped to the control/form, we must the the Data-property.
- ' However, the data is an array, and we can't use ubound or lbound to detect the
- ' beginning or end of the array. So we'll have to test until we find the end.
- ' The Data.Files contains files dropped onto the from/control, however, this is
- ' an array, so to use it, we'll have to type like this: Debug.Print Data.Files(1).
- ' This is the tricky part. Determinate the code below.
- SetSplashText "Processing information..." ' Set splash-screen text
- Me.Hide ' Hide main form
- frmSplash.Show ' Show splash-screen
- ' Remember, do NOT show it modally, it will cause the splash screen to be there and
- ' nothing will happend, cause the program will wait until the splash screen is unloaded.
- For i = 1 To 9999 ' Start the loop
- ' Remember, that the number 9999 is the last number we shall test in the array.
- ' If you want to test less, then change the 9999 to some other number.
- ' For example 10. Then it should be like this: For i = 1 To 10
- ' In this example, we will print the filenames dragged onto the form to the
- ' debug-window.
- On Error Resume Next
- ' If the array-number doesn't exist then skip it and go on with the next array
- ' number.
- Debug.Print Data.Files(i) ' Print the filesname to the debug-window
- Next i ' Continue the loop
- ' The tricky with this is that it will loop until it have done it 9999 times, wich
- ' may take some time. A good idea is to show a splash screen while doing this.
- Unload frmSplash ' Remove splash-screen
- Me.Show ' Show main form
- ' X As Single, Y As Single
- ' Some other variables to use is Button.
- ' This variable detects with wich button the user dragged the files onto the form.
- ' Eg. the right mouse-button, 1 means left mouse-button, 2 means right mouse-button.
- ' Use the shift-variable to detect the state of alt, ctrl and shift. Consult the VB
- ' help-file for help about this.
- ' The X as Y variables are values where the mouse is on the screen when dropping the
- ' files onto the form. Remarks: These values are not the same as the GetCursorPos API.
- ' Eg. If X contains 1000, it's maybe 100 when using the GetCursorPos API.
- End Sub
-