0% found this document useful (0 votes)
64 views22 pages

CCP503

1. The document summarizes a lecture on graphics miscellaneous topics in Visual Basic, including the Paintpicture method, differences between Picture and Image controls, and examples of using dots, lines, circles, and shape controls. 2. Key points covered include using the Paintpicture method to send a PictureBox contents to a printer or other form, differences in functionality between Picture and Image controls, and code examples to draw dotted lines, lines, circles, and dynamically changing lines and shapes. 3. The lecture concludes with a quiz to test objectives, frequently asked questions, and an assignment to print a graphic to a printer.

Uploaded by

api-3849444
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views22 pages

CCP503

1. The document summarizes a lecture on graphics miscellaneous topics in Visual Basic, including the Paintpicture method, differences between Picture and Image controls, and examples of using dots, lines, circles, and shape controls. 2. Key points covered include using the Paintpicture method to send a PictureBox contents to a printer or other form, differences in functionality between Picture and Image controls, and code examples to draw dotted lines, lines, circles, and dynamically changing lines and shapes. 3. The lecture concludes with a quiz to test objectives, frequently asked questions, and an assignment to print a graphic to a printer.

Uploaded by

api-3849444
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 22

DEPARTMENT OF TECHNICAL EDUCATION

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

Recap 05 Min
Paint picture method 05 Min
Use of Paint picture method 05 Min
Differences between Picture & Image controls 05 Min
Examples on Dots, Line & Circle methods 10 Min
Examples on Line and Shape controls 10 Min
Summary 05 Min
Quiz and Questions 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 Image Control
Suitable for advanced computers Suitable for old computers with
with latest operating system old Operating system
Supports Graphics methods like Does not support graphic
Pset, line and circle methods
Autosize property controls its size Stretch property controls its size
Supports a large number of Has a few properties and is not
properties and so is flexible in its flexible
usage
Acts as a container on which we Does not act as a container
can place other controls
Allows to draw graphics on it 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
Case 7
y1 = y1 + 20
x1 = x1 - 20
Case 3
y1 = y1 + 20
x1 = x1 - 20
Case 8
Case 4
x1 = x1 - 20
y1 = y1 - 20
y1 = y1 - 20
x1 = x1 + 20 End Select
Case 5 Next i
y1 = y1 - 20 Next n
Case 6 End Sub
x1 = x1 + 20
y1 = y1 + 20

CCP503.60 11
Examples of Dots, Lines & Circles-II

Private Sub Form1_Click()


x1 = Form1.Width / 2 Draw a lines pattern as shown
in picture with line method
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
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() Draw symbol as shown in the


Form1.Height = 5000 picture
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

CCP503.60 14
Examples on Lines & Shape Controls

Write a program that shows


(ii) line-control changing width and colors and
(iii) 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

2.
False
Image control acts as a container (T/F)_______

3. The property that allows changing the image size in image control
Stretch
is_____________
False
4. The default value of Stretch property is________
Load picture()
5. The method to show a picture in Image control is__________
False
6. The image control allows drawing of graphics on it (T/F)_____

CCP503.60 19
Frequently Asked Questions
1. Explain difference between Picture and Image control
2. 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

You might also like