To create the drawing pad, you need to insert a common dialog control, a
picture box, four text boxes , six command buttons and the necessary labels. The
function of the common dialog control is to assist the users to choose colors. The text
boxes are for the user to enter the coordinates and the picture box is to display the
pictures drawn. The method to draw a straight line is Line, and the syntax is as follows:
[Link] (x1, y1)-(x2, y2), color
where picture1 is the picture box, (x1,y1) is the coordinates of the starting point, (x2,
y2) is the ending point and color understandably is the color of the line.
The syntax to draw a non-solid rectangle is
[Link] (x1, y1)-(x2, y2), color, B
The syntax to draw a solid rectangle is
[Link] (x1, y1)-(x2, y2), color, BF
The syntax to draw a circle is
[Link] (x3, y3), r, color
Where (x3, y3) is the center of the circle and r is the radius.
f you wish to draw a solid circle and fill it with the selected color, then add two more
lines to the above syntax:
[Link] = vbSolid
[Link] = color
The syntax to clear the picture is
[Link]
The Interface
The code
Private Sub cmd_Rectangle_Click()
x1 = [Link]
y1 = [Link]
x2 = [Link]
y2 = [Link]
[Link] (x1, y1)-(x2, y2), color, B
End Sub
Private Sub cmd_Color_Click()
[Link] = &H1&
[Link]
color = [Link]
End Sub
Private Sub cmd_Circle_Click()
On Error GoTo addvalues
x3 = [Link]
y3 = [Link]
r = [Link]
[Link] = vbSolid
[Link] = color
[Link] (x3, y3), r, color
Exit Sub
addvalues:
MsgBox ("Please fill in the coordinates ,the radius and the color")
End Sub
Private Sub Command5_Click()
[Link]
End Sub
Private Sub cmd_SolidRect_Click()
x1 = [Link]
y1 = [Link]
x2 = [Link]
y2 = [Link]
[Link] (x1, y1)-(x2, y2), color, BF
End Sub
The Interface
The code
Private Sub Form_Load()
Left = ([Link] - Width) \ 2
Top = ([Link] - Height) \ 2
'To offer the user selection of media files
[Link] = "*.wav"
[Link] "*.wav"
[Link] "*.mid"
[Link] "*.avi"
[Link] "*.mpeg;*.mpg;*.mp3"
[Link] "All files"
End Sub
Private Sub Combo1_Change()
'To allow the user to select a particular media file type
If ListIndex = 0 Then
[Link] = ("*.wav")
ElseIf ListIndex = 1 Then
[Link] = ("*.mid")
ElseIf ListIndex = 2 Then
[Link] = ("*.avi")
ElseIf ListIndex = 3 Then
[Link] = ("*.mpeg;*.mpg;*.mp3")
Else
[Link] = ("*.*")
End If
End Sub
Private Sub Dir1_Change()
[Link] = [Link]
If [Link] = 0 Then
[Link] = ("*.wav")
ElseIf [Link] = 1 Then
[Link] = ("*.mid")
ElseIf [Link] = 2 Then
[Link] = ("*.avi")
ElseIf [Link] = 3 Then
[Link] = ("*.mpeg;*.mpg;*.mp3")
Else
[Link] = ("*.*")
End If
End Sub
Private Sub Drive1_Change()
[Link] = [Link]
End Sub
Private Sub File1_Click()
'Allows the user to select a particular media file
If [Link] = 0 Then
[Link] = ("*.wav")
ElseIf [Link] = 1 Then
[Link] = ("*.mid")
ElseIf [Link] = 2 Then
[Link] = ("*.avi")
ElseIf [Link] = 3 Then
[Link] = ("*.mpeg;*.mpg;*.mp3")
Else
[Link] = ("*.*")
End If
If Right([Link], 1) <> "\" Then
filenam = [Link] + "\" + [Link]
Else
filenam = [Link] + [Link]
End If
[Link] = filenam
End Sub
Private Sub Open_Click()
If [Link] = 0 Then
[Link] = "WaveAudio"
End If
If [Link] = 1 Then
[Link] = "Sequencer"
End If
If [Link] = 2 Then
[Link] = "AVIVideo"
End If
If [Link] = 3 Then
[Link] = ""
End If
[Link] = [Link]
[Link] = "Open"
End Sub
Private Sub play_Click()
[Link] = True
[Link] = "Play"
[Link] = [Link]
End Sub
Private Sub Stop_Click()
If [Link] = 524 Then Exit Sub
If [Link] <> 525 Then
[Link] = True
[Link] = "Stop"
End If
[Link] = True
[Link] = "Close"
End Sub