Using OLE Drag-and-Drop in Visual Basic 6 : Page 2
There are two types of Drag-and-Drop functionality in Visual Basic: the traditional kind and OLE. This second type of drag-and-drop allows users to drag data between applications as well as within an application. However, it only works with applications that support it. Luckily, this includes most Microsoft applications and many programs from other vendors as well. In this article, learn how to use this basic but essential functionality.
by Peter Aitken
Oct 21, 2002
Page 2 of 5
Properties and Events for Drag and Drop
There are several properties and events related to OLE drag-and-drop, some relevant to sources and some to targets. They are described in Tables 1 and 2.
Table 1. OLE drag-and-drop related properties.
whether OLE drag-and-drop operations are initiated manually (VbOLEDragManual,
the default) or automatically (vBOLEDragAutomatic).
whether OLE drops are ignored (vbOLEDropNone, the default), are handled
manually (vbOLEDropManual), or handled automatically (vbOLEDropAutomatic).
the image displayed under the mouse cursor during an OLE drag-and-drop
operation. Possible formats are .bmp, .dib, .jpg, .gif, .ani, .cur, and .ico.
the type of drop operations supported by the target.
how the target handles a drop operation.
Table 2. Events related to OLE drag-and-drop operations.
source object is dragged over the target.
source object is dropped on the target.
OLE drag operation is initiated.
source is dropped on a target.
the source is dropped on a target but the data has not been loaded into the DataObject.
Take a look at a simple example of OLE drag-and-Drop using the automatic settings before getting into the details.
Create a new Visual Basic project and place one Text Box and two Picture Box controls on the form.
Set the OLEDragMode and OLEDropMode properties to Automatic for all three controls.
Run the project.
Launch a graphics program that supports OLE drag-and-drop. I know that PhotoShop doesfor other programs you'll have to try and see if it works.