Form controller is the controller of your program.
We are going to give the user easy way to control the drawing of your
simple program. Click here to download the code
In the Project Window, do Right Click and it show a pop up menu,
choose Add > Form. In the dialog window, press Open button
Change the Name of the form into frmController and the Caption
property into Controller. Change the MinButton and MaxButton properties
to False. It is mean we will not resize the form.
In the VB menu, select Project > Project1 Properties. In the
General Tab, StartUp Object, select frmController, then OK . This
is to make VB run from the frmController instead of frmMap.
Drag and drop two Frame control into the frmController. Arrange
the two frames so that Frame1 is in the top of Frame2
Change the Caption property of Frame1 into Draw, and the Caption
property of Frame2 into Auto Drawing.
Drag and drop two Option button into Frame1. Change the Caption
of Option1 into Manually, and the Name into optManual. Change the
Caption of Option1 into Automatically, and the name into optAutomatic.
Change the Value property of optManual into True.
Drag and drop one Checkbox control, one Label control, one horizontal
Scrollbar and one Listbox control into Frame2.
Change the Checkbox Caption into Animate, and the Name into chkAnimate
Change the Label1 Caption into Max Line, and the AutoSize property
into True.
Change the Name property of Scrollbar into ScrlMaxLine. The Max
property into 1000, Min property into 10 and Value property into 200.
Arrange the controls so that it looks like this
figure. You can try to run the program and feel how it looks like.After
we finish arrange the components and giving the name, captions and
change some properties, we can start the programming.
In the frmController load event , we initialize the Listbox using
code below:
Private Sub Form_Load()
' fill the content of ListBox
List1.List(0) = "Star"
List1.List(1) = "Messy"
List1.List(2) = "Chain"
List1.List(3) = "Rays"
' initialize the first value
List1.Text = "Star"
End Sub
Examine the width and height properties of your form with the Frame2
and without Frame2. For example: with Frame2 the width is 2150 and the
height is 3480, while without Frame2, the width is the same, but the
height is 1320. Then we fixed the size of the form using the following
code:
Private Sub Form_Resize()
Me.Width = 2150
If optManual.Value = True Then
Me.Height = 1320
Else 'If optAutomatic.Value = True Then
Me.Height = 3480
End If
End Sub
15. Double click the option button one by one and type code below
Private Sub optAutomatic_Click()
Call Form_Resize
End Sub
Private Sub optManual_Click()
Call Form_Resize
End Sub
16. Double click the checkbox and type the following code:
The last code contains a call to a timer that we haven’t
put yet into the control. Go to frmMap, add Timer control into frmMap.
Double click the Timer and type the following code:
Private Sub Timer1_Timer()
Dim PointColor As Long
Dim LineColor As Long
Dim maxLine As Integer
Dim DrawingType As String