Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

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.


advertisement
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.



Property

Relevant to

Description

OLEDragMode

Source

Determines whether OLE drag-and-drop operations are initiated manually (VbOLEDragManual, the default) or automatically (vBOLEDragAutomatic).

OLEDropMode

Target

Specifies whether OLE drops are ignored (vbOLEDropNone, the default), are handled manually (vbOLEDropManual), or handled automatically (vbOLEDropAutomatic).

OLEDragPicture

Source

Specifies 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.

OLEDropEffects

Target

Specifies the type of drop operations supported by the target.

OLEDropHasData

Target

Specifies how the target handles a drop operation.

Table 2. Events related to OLE drag-and-drop operations.

Event

Fires in

Fires when

OLEDragOver

Target

A source object is dragged over the target.

OLEDragDrop

Target

A source object is dropped on the target.

OLEStartDrag

Source

An OLE drag operation is initiated.

OLECompleteDrag

Source

The source is dropped on a target.

OLEGiveFeedback

Source

After every OLEDragOverEvent.

OLESetData

Source

When 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.

  1. Create a new Visual Basic project and place one Text Box and two Picture Box controls on the form.
  2. Set the OLEDragMode and OLEDropMode properties to Automatic for all three controls.
  3. Run the project.
  4. Launch a graphics program that supports OLE drag-and-drop. I know that PhotoShop does—for other programs you'll have to try and see if it works.





Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap