4

The LA Fox Developer Newsletter
June 1995
Drag-and-Drop for Dummies
by David A. Greene, MA [Productive Solutions]

Our job as software developers is to build applications that are useable; not applications that we think are useable, but applications that really are useable by normal people. This involves knowing all the tools available to us, how they work, and when to use them. Microsoft has built so much into Visual FoxPro that it will be years before any one of us conquers everything this language has to offer, so this article came about as a way to share a few shortcuts about a tool that only a few of us have implemented in the past.

I had my initial doubts about using drag-and-drop. It was never clear to me why this was invented when so many other controls are adequate, but after using it in a few applications it became dear that users exert more control over the computing environment when they can both select an item and the action to be taken using that item. There are subtle user benefits, to be sure, but drag-and-drop is now state of the art and our clients (and superiors) are simply going to expect it.

The Scenario
A System Administrator (with some FoxPro training) can add, delete, or modify reports (.FRX/.FRT) for a particular system. There is no telling how many reports may be in the system at a given time, and users must be able to select whether a report is sent to the screen or to the printer.

Two tables will be used for this demonstration - a Reports table with two fields for report Descriptions and for report FileNames, and an Employee table - plagiarized from the Tasmanian Traders demo that comes with VFP.

In the form to the right, users are presented with the ListBox containing the report descriptions, two .BMP pictures as drop targets, and an “OK” button to close the form.

Building Drag-and-Drop Microsoft gives us two ways to use Drag-and-Drop:
Manual (default) and Automatic. There is less control over dragging when in Automatic mode so we’ll ignore it for now and go with what works best...
There are three components for Drag-and-Drop: the form, the source list , and the target(s) . Each has methods or properties that need to be filled in to make Drag-and-Drop work, and with a short descnption for each property or method, it should be easy to apply these concepts to any application.

The Form Holding Drag-and-Drop Objects

Use the New Property.. option from the Form menu to add the following PROPERTIES to the form:

CanTargetIcon
(enterC:\VFP\SAMPLES\GRAPHlCS\CURSORS~
BULLSEYE.CUR for this Property);

CanSourcelcon
(enter C:~VFP~SAMPLES\GRAPHlCS\CURSORS\
DRAGMOVE.CUR for this Propertyo;

NoDroplcon
(enter C:\VFP\SAMPLES\GRAPHICS\CURSORS\
NODROPOI .CUR for this Property);

DragThreshold
(enter 8 for this Property);

MouseX
(don’t enter anything now);

MouseY
(don’t enter anything now)

(Con't, page 5)
Page 4

4