|
5.
Projects using Intrinsic and Professional ActiveX Controls(4)
3.
Colored
Pixels:
Pixels
are
created
using
the
Pset
method
and
they
are
colored
randomly
using
the
QB
color
function. Drag
two
command
buttons
on
the
form
and
position
them
as
shown
in
the
figure
5. Open
the
code
window
of
the
command
buttons
and
enter
the
code
as
shown
in
the
figure
6a. Save
and
run
the
project. You
will
find
the
pixels
are
created
in
random
colors.
The
output
will
look
as
in
the
figure
6.

Figure 5
Private
Sub
Command1_Click()
Dim
cx,
cy,
msg,
xpos,
ypos
ScaleMode
= 3
DrawWidth
= 5
ForeColor
=
QBColor(4)
FontSize
= 24
cx
=
ScaleWidth
/ 2
cy
=
ScaleHeight
/ 2
Cls
msg
=
"happy
new
year"
CurrentX
= cx
-
TextWidth(msg)
/ 2
CurrentY
= cy
-
TextHeight(msg)
Print
msg
Do
xpos
=
Rnd
*
ScaleWidth
ypos
=
Rnd
*
ScaleHeight
PSet
(xpos,
ypos),
QBColor(Rnd
*
15)
DoEvents
Loop
End
Sub
Private
Sub
Command2_Click()
End
End
Sub
Figure
6a

Figure
6
   |