How to display a picture if you drag the Picture file to Picture Box
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 'Graphics - How to display a picture if you drag the Picture file to Picture Box Option Explicit 'If you drag the file Test.gif from Windows Explorer to the picture box, 'the picture will be displayed in the picture box. 'Add a Picture Box to your form and set the Picture Box OLEDropMode Property to 1 - manual. Private Sub Picture1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, _ Shift As Integer, X As Single, Y As Single) On Error GoTo Picture1_OLEDragDrop_Error Picture1.Picture = LoadPicture(Data.Files(1)) On Error GoTo 0 Exit Sub Picture1_OLEDragDrop_Error: Call MsgBox("Unable to load the picture you dragged", vbExclamation, App.Title) End Sub |