5 |
The LA Fox Developer Newsletter
June 1995
Drag and Drop
(Con't from page 4)
The first three properties give us a convenient place
to store names of cursors; the DragThreshold num-
ber will tell us how far the left-clicked mouse needs
to move before we know the user wants to Drag-
and-Drop; and the MouseX and MouseY properties
are just temporary places to put the mouse location
information when we need it.
The following code goes into the lNlT method of the
form:
This code reads REPORT. DBF and populates the
source ListBox (IstSource) for us. It also populates
the aReports
array with
the corresponding names of
report files for
each report description.
So that’s it for the form.. .six properties and some
INIT code.
An aside...
Although not absolutely necessary, the OK button
has a Click event that reads: RELEASE THISFORM.
This will close the form and shoot you back to VFP,
the same
as a double-click
in
the control
box
in the
upper left corner of the form. I always use a button
to close the form unless users have a background
with the Macintosh. Now back to the good stuff...
The Drag-and-Drop Source
The Drag-and-Drop source is the object “lstSource”,
a ListBox holding the descriptions of system reports.
We need to modify three methods in this object.
The DragOver method should read:
Remember creating the CanSourcetcon property for
the form? This is where we use
it.
Same for
NoDroplcon. This code here changes the
cursor
as
the user moves it out of the ListBox, from an arrow
with a box next to it to a cirle & slash
cursor
like
those on No Smoking signs.. Impressive stuff
for
so
little work.
2.
The
MouseDown method should read:
Remember creating the Mousex and MouseY prop-
erties for the form? We use those now to record the
starting position of the mouse when the left mouse
button is first pressed.
3. The MouseMove property should read:
Remember adding Draglhreshold as a property for
the Form? Remember entering “8” in this property?
This code enables Dragging of the selected item
from the source ListBox if the user holds down the
left mouse button and moves the pointer more than
8 pixels. This gives users a little leeway before the
cursor changes, but you could set the
DragThreshold property to and number you wish.
So that’s it for the Source.. .only three methods
and
very little code!
The Drag-and-Drop Target(s)
Targets are even easier.. .there are only
two
meth-
ods in each target that need our attention.
1.
The DragOver method should look like this:
(Con't, page 6)
Page 5
|
5 |