4. Projects using Intrinsic and Professional
ActiveX Controls(3)
3.
Project
involving
Drag-Drop
Operations:
Many
of
the
controls
in
VB-5
have
a
DragMode
property
which
determines
whether
a
control
can
be
dragged
or
not
with
the
mouse. In
this
project
the
drag property
of a
command
button
is
illustrated
by
dragging
it
over
a
PictureBox
Control.
Drag
a
PictureBox
and
a
commands
button
and
position
them
as
shown
in
the
figure
5. Set
the
DragMode
property
of
the
button
as
1-automatic. Open
the
code
window of
the
PictureBox
and
enter
the
code
as
shown
in
the
figure
5a.

Figure
5
Private
Sub
Picture1_DragDrop(Source
As
Control,
X As
Single,
Y As
Single)
Picture1.BackColor
=
vbBlue
End
Sub
Private
Sub
Picture1_DragOver(Source
As
Control,
X As
Single,
Y As
Single,
State
As
Integer)
If
State
= 0
Then
Picture1.BackColor
=
vbRed
If
State
= 2
Then
Form1.Caption
=
"source
control
moves
over
the
PictureBox"
If
State
= 1
Then
Picture1.BackColor
=
vbGreen
Form1.Caption
=
"Drag
and
Drop
demo"
End
If
End
Sub
Figure
5a
On
running
the
project
you
will
notice
that
when
the
button
is
first
dragged
over
the
picture
box,
it
is
paintede
red. When
the
button
leaves
the
picture
box,
the
picture
box
is
painted
green. If
the
user
drops
the
button
while
it
is
over
the
picture
box,
the
picure
box
is
painted
blue. The
run
mode
window
is
shown
in
the
figure
6.

Figure
6
   |