Enabling OLE Drag-DropWith Visual Basic 5.0, some controls now provide OLEDragMode and OLEDropMode properties that enable OLE drag-drop. By default, these properties are set to 0 - None because previous versions of the controls didn't provide drag-drop. To enable drag-drop, simply reset these properties to Automatic where possible. To see how this works, create a new project and add a Text Box control to Form1. Set the control's OLEDragMode property to 1 - Automatic and its OLEDropMode property to 2 - Automatic. Run the project, then start WordPad and drag-drop text between the text box and the WordPad application as shown in Figure R.1. Set OLEDragMode and OLEDropMode to Automatic to enable OLE drag-drop. The Automatic setting tells Visual Basic to determine whether or not the data from the drag source is appropriate for the drop target. If the data's not valid - for instance, a bitmap is dragged to a text box - Visual Basic displays the vbNoDrop cursor and prevents the drop. Otherwise, the drop occurs normally. Of course, not all controls are automatically draggable. For instance, it's not clear what dragging a label should do, so the Label control doesn't have an OLEDragMode property. Similarly, not all objects allow an Automatic setting for OLEDropMode; Visual Basic can't determine what type of data is valid to drop in a frame or on a command button. In these cases, you have to use the new OLE drag-drop events to manually manage OLE drag-drop. The following sections tell you how to add OLE drag-drop to objects that don't provide Automatic settings for OLEDragMode or OLEDropMode properties. |
|
![]() |
![]() |
|||