Transfer@once by Quasidata
Many applications allow users to transfer data to another application by dragging and dropping the data with the mouse, or by using the clipboard. With Transfer@once to build applications that transfer data both ways is now as easy as put a component on a form. The aim of the Transfer@once component suite is to extend VCL components with full-blown clipboard and drag-and-drop capabilities.
The core functionality is implemented in components called controllers. Place a controller on a form just as you place other nonvisual components and associate it with a visual control.
- The controller holds format objects to convert data during drag-and-drop and clipboard operations. There are some ready-to-use format classes, as well as format classes customizable at design-time.
Right now you can accept data as BIFF5 (supported by MS Access), BIFF8 (native to MS Excel), file names and Shell items (native to Windows Explorer, Desktop), virtual files (supported by MS Outlook, Outlook Express), hyperlinks (native to Internet Explorer and Netscape Navigator), Internet shortcuts (native to Windows Explorer and Desktop), and Text/Unicode Text (supported by everything).
You can supply data as RTF (native to MS Word and WordPad), BIFF8 (native to MS Excel), tabular text (supported by MS Access), file names and Shell items (native to Windows Explorer, Desktop, supported by Delphi/C++Builder IDE), hyperlinks (native to Internet Explorer and Netscape Navigator), Internet shortcuts (native to Windows Explorer and Desktop), and Text/Unicode Text (supported by everything, isn't it?)
- The inter-application drag-and-drop provided by OLE works with standard properties and events the same way as the internal drag-and-drop managed by the VCL does and thus works seamlessly. Since the controller is aware of drag-and-drop events, it can handle them for you implicitly, so you can know nothing about implementation of drag-and-drop in the VCL. Of cource, if you need manual control, usual properties and events are available as well.
- The controller monitors mouse movement to provide visual feedback to the user. If the mouse pointer is hovering over a control for a given period of time, controller tests pick conditions to determine whether to allow the user pick up selected data and begin dragging. To indicate that a drag operation can be started, it sets cursor to another value. The controller can begin a drag operation automatically when the user presses the left mouse button. To avoid interference with normal mouse activity, it provides the OnBeforeLeftButtonDown event.
- When the mouse pointer is over an area that is a drop target, the controller provides visual feedback in the control, indicating where the drop is to occur.
- If the mouse during a drag-and-drop operation is held near the border of the window for some time, the controller starts scrolling the window in the appropriate direction.
- On the drop action, if the control was not active, the controller sets focus to the control's window.
- Some of clipboard formats are time-consuming to render, thus the controller delays rendering in the particular clipboard format until the data placed on the clipboard is really needed. To leave the data on the clipboard after the application is closed, the controller can flush the clipboard at application shutdown.
- In response to a Paste Special command the controller invokes the standard Paste Special dialog box, allowing the user to select the format of the clipboard object to be pasted.
TtaoWinControl is a general-purpose customizable controller designed to work with any visual control. Only a single component is needed to allow a visual control to support the clipboard as well as drag-and-drop.
TtaoStringGrid allows TStringGrid to support clipboard and drag-and-drop data transfer. A single string as well as a tabular range of strings can be supplied as RTF and Text and accepted as Text.
TtaoDbGrid makes TDBGrid to be able to copy and paste records as well as a single cell in many popular clipboard formats, including ones native to MS Office. It supports drag-and-drop of a single cell also. If the TtaoDbGrid component is unable to paste one or more records, it stores them in an in-memory dataset, so the user is able to fix the problems that resulted in the paste errors.
TtaoDbGrid introduces a number of features to improve user interface provided by TDBGrid.
- The user can select a single cell (with a mouse click), a range of records (with Shift+Click), multiple records (with Ctrl+Click) in the same mode.
- Vertical scrolling is more intuitive. Records are scrolled line-by-line when the user clicks a scroll arrow on the vertical scroll bar. The indicator stays on the same row when the user scrolls records page-by-page with scroll bar.
- Using a mouse equipped with a wheel, the user can scroll records line-by-line or, when holding down the Ctrl key, page-by-page.
TtaoDragCursors replaces images for the cursors predefined in the VCL with ones used by OLE, so that they look like common Windows GUI cursors during drag-and-drop operations.
There are action classes for most common user commands. To use actions is the standard way in the user interface development in Delphi.
Transfer@once 1.3 supports Delphi 4, 5, 6, 7 and C++Builder 4, 5, 6. Documentation and demo applications are provided. Please visit www.quasidata.com for additional information.
© 2001, 2002 Quasidata