# DEPARTMENT OF TECHNICAL EDUCATION ANDHRA PRADESH

Name Designation Branch Institute Year/Semester Subject Subject Code Topic Duration Sub-Topic Teaching Aids used : Nand Kishore Singh : Lecturer : D.C.C.P. : SGM G.P.T., Abdullapurmet : V Semester : VISUAL BASIC-I : CCP-503 : MDI Applications and Graphics : 50 Mts : Graphics – Miscellaneous : PPT, Animations, Window outputs
CCP503.60 1

Duration to cover each Objective
Recap Paint picture method Use of Paint picture method Differences between Picture & Image controls Examples on Dots, Line & Circle methods Examples on Line and Shape controls Summary Quiz and Questions 05 Min 05 Min 05 Min 05 Min 10 Min 10 Min 05 Min 05 Min

CCP503.60

2

Objectives
On completion of this period, you will be able to:
 Know and Use Paintpicture method  Know Differences between Picture & Image controls  Solve difficult assignments on dot, line and circle methods  Solve difficult questions on line and shape controls

CCP503.60

3

Recap
   Use of graphic Controls & Methods Picture control & Image control Relation to present lesson

CCP503.60

4

Paintpicture() method
Definition:
Paintpicture() is a method of forms & printer objects to send the contents of PictureBox to printer and other forms.

Syntax:
Destination.Paintpicture Source, x, y, picture, dest.height, dest.width

CCP503.60

5

Explanation:
 Destination may be a form or printer  Printer is also treated as an object  Source is the picture to be printed or drawn  X, Y are the coordinates on the destination object from where the picture should appear  Dest.height and dest.width indicate the sizes of the picture in terms of the size of the destination objects, be it form or printer
CCP503.60 6

Use of Paintpicture method
Explanation:  Create Two forms named ‘Form1’ and ‘Form2’  Paste a Picture control on Form1 and load a picture on it  Write the following code for form click events as follows: Form1 Form1_click Form2.show End Sub
CCP503.60 7

 Form2:
Form2_Click Form2.Paintpicture Form1.Picture1,0,0, Form2.width/2,Form2.height/2 End Sub

NOTE: When Form1(Source) is clicked, Form2
appears. When Form2 is clicked, the picture of Picture control in Form1 appears on Form2 with half of the height and width of the form2 (Destination) from 0,0 position of Form2
CCP503.60 8

Differences between Picture control and Image control
Picture Control
Suitable for advanced computers with latest operating system Supports Graphics methods like Pset, line and circle Autosize property controls its size Supports a large number of properties and so is flexible in its usage Acts as a container on which we can place other controls Allows to draw graphics on it

Image Control
Suitable for old computers with old Operating system Does not support graphic methods Stretch property controls its size Has a few properties and is not flexible Does not act as a container Does not allowto draw graphics on it.
CCP503.60 9

Examples of Dots, Lines & Circles-I
Dim x As Integer, y As Integer Form1_click() Form1.BackColor = vbBlack DRAW THE DOTTED-LINE-STAR Form1.Height = 5000 AS SHOWN IN PICTURE Form1.Width = 5000 For n = 1 To 8 x1 = Form1.Width / 2 y1 = Form1.Height / 2 For i = 1 To 50 Form1.PSet (x1, y1), vbMagenta Select Case n Case 1 x1 = x1 + 20
CCP503.60 10

Case 2 y1 = y1 + 20 Case 3 x1 = x1 - 20 Case 4 y1 = y1 - 20 x1 = x1 + 20 Case 5 y1 = y1 - 20 Case 6 x1 = x1 + 20 y1 = y1 + 20

Case 7 x1 = x1 - 20 y1 = y1 + 20 Case 8 x1 = x1 - 20 y1 = y1 - 20 End Select Next i Next n End Sub

CCP503.60

11

Examples of Dots, Lines & Circles-II
Private Sub Form1_Click() x1 = Form1.Width / 2 y1 = Form1.Height / 2 X2 = x1 + 1000 Y2 = y1 - 1000 For I = 1 To 20 Form1.Line (x1, y1)-(X2, Y2), vbMagenta X2 = X2 - 100
CCP503.60 12

Draw a lines pattern as shown in picture with line method

Next I x1 = Form1.Width / 2 y1 = Form1.Height / 2 X2 = x1 + 1000 Y2 = y1 + 1000 For I = 1 To 20 Form1.Line (x1, y1)-(X2, Y2), vbBlue X2 = X2 - 100 Next I End Sub
CCP503.60 13

Examples of Dots, Lines & Circles-III
Private Sub Form1_Click() Form1.Height = 5000 Form1.Width = 5000 Form1.Circle (2000, 1500), 700, vbRed Form1.Circle (3000, 1500), 700, vbCyan Form1.Circle (1500, 2500), 700, vbBlue Form1.Circle (2500, 2500), 700, vbGreen Form1.Circle (3500, 2500), 700, vbYellow End Sub Draw symbol as shown in the picture

CCP503.60

14

Examples on Lines & Shape Controls
Write a program that shows
(ii) (iii)

line-control changing width and colors and shape control changing its fill style and fill color properties at runtime for every second as shown below:

CCP503.60

15

General code: Dim k(7) As String Dim i As Long For Form_load event Private Sub Form_Load() k(0) = vbRed k(1) = vbGreen k(2) = vbBlue k(3) = vbMagenta k(4) = vbCyan k(5) = vbBlack k(6) = vbYellow i=0 End Sub
CCP503.60 16

Private Sub Timer1_Timer() If i > 6 Then i=0 End If x=i*6 If x = 0 Then x=1 End If Line1.BorderColor = k(i) Line1.BorderWidth = x y=i+1 If y > 5 Then y=0 End If Shape1.Shape = y Shape1.BorderColor = y Shape1.FillStyle = y Shape1.FillColor = k(y) i=i+1 End Sub
CCP503.60 17

SUMMARY
 Paintpicture() method  Differences between Picture & Image Controls  Working with difficult problems on dot, line and circle methods and solutions

CCP503.60

18

Quiz – Objective Type
1.

Contents of a Picture can be printed on paper with
Paintpicture ___________method False Image control acts as a container (T/F)_______

2. 3.

The property that allows changing the image size in image control
Stretch is_____________ False

4. 5. 6.

The default value of Stretch property is________ The method to show a picture in Image control is__________

False The image control allows drawing of graphics on it (T/F)_____

CCP503.60

19

1. 2.

Explain difference between Picture and Image control Explain Paint Picture methods with a example

CCP503.60

20

Assignment
1.

Draw a graphic on a form and write the code to print it on printer

CCP503.60

21

Thank You

CCP503.60

22