You are on page 1of 15

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name : K.SRINIVAS
Designation : SL/CCP
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 – Picture
Control
Teaching Aids used : PPT, Animations,
Window outputs
CCP503.58 1
Objectives
On completion of this period, you would be
able to:
 Know Picture control & Image control

 Draw graphics on Picture control

 List properties of Picture control to show


pictures
 Draw pictures on Picture control

 Control pictures on Picture control


programmatically

CCP503.58 2
Recap on methods

 Shape control
 Properties of Shape control
 Using Shape property
 Using Fillstyle property
 Using Other properties

CCP503.58 3
Introduction to Picture & Image controls
Definition:
VB offers Picture and Image controls to show pictures
on forms.
Picture control also has methods to draw graphics on
it like a Form.

CCP503.58 4
Example

 The following pictures show Picture control with pictures


and graphics

Picture Control with Picture Picture Control with Graphics

CCP503.58 5
Using Picture Control to draw pictures
Explanation:
Like Form, Picture control also has
Pset(),Line(),Circle() methods.
These methods can be used to draw graphics
on Picture controls. But the coordinates of the points
for using the above methods should be within the
height and width pixels of the Picture Control.

CCP503.58 6
Picture Control’s Properties to show
Pictures
Explanation:
 Picture Control can also be used as a container
for showing pictures of different formats with
extensions like .jpg(.jpeg), .ico, .bmp etc.
 The following properties help in showing picture at
design time or runtime

CCP503.58 7
 Picture property – at design time shows Open
dialog box and user should select the file containing
the picture. At runtime, picture should be loaded
with Picture control’s Loadpicture() method
 Autosize property – When its property is set to
True, the control size changes to the size of the
picture and shows entire picture. Its default value is
False. So, by default Picture control shows only as
much of the picture as is the size of the control set
at design time

CCP503.58 8
Using Picture Control to show pictures
at design time-I
Drawing Pictures at Design Time:
-- Select Picture control from Toolbox and draw it on the
form
-- Attach a picture to the Picture control with Picture
property
--Set the Autosize property of the Picture control to
“True”
At runtime, the picture appears on the picture control

CCP503.58 9
Using Picture Control to show picture
at runtime-II
Drawing Pictures at Runtime
-- Select Picture control from Toolbox and draw it
on the form
-- Write the following code to a command button and
click it at runtime to get the picture

Private Sub Command2_Click()


Picture1.AutoSize = True
Form1.WindowState = 2
Picture1.Picture =
LoadPicture("D:\elesson\Sunset.jpg")
End Sub
(The file address may change in your case”)

CCP503.58 10
Using Picture Control programmatically
Explanation:
Normally, at runtime picture appears only the same size
as the picture control. If the control’s Autosize property
is TRUE, then at runtime, the control grows or shrinks to
contain full size of the picture. But it remains so. To set
it back, write the following code:
Write following in General section:
Dim H as integer, W as integer
In Form Load event, write the following
H=Picture1.height
W=Picture1.width
Type the following on Click event of the Picture:
Form1.Windowstate = 0
Picture1.height=H CCP503.58 11

Picture1.height=W
Summary
 Picture and Image controls

 Using Picture control to draw graphics

 Properties of Picture control to draw


pictures

 Using Picture control to show pictures at


design time and run time

 Using Picture control programmatically

CCP503.58 12
Quiz – Objective Type
1. Graphics
The Picture control helps in drawing___________
Pictures
and showing________

2. The property of Picture control to show a picture


Picture
is___________

3. The property that resizes Picture control to the size


Autosize
of picture is_____________

4. The coordinate values for drawing graphics need


not be within the height and width values of the
False
Picture control _______
CCP503.58 13
Quiz – Objective Type
1. The method to attach a picture to Picture
control at runtime is
a) GetPicture()
b) Picture
c) Loadpicture()
d) None of the above
2. To draw graphics on Picture Control, you
should use
a) Properties
b) Form’s methods
c) Methods of the control
d) All of the above
CCP503.58 14
Frequently asked questions

1. Explain the usage of picture and image control


2. Explain how to draw graphics on picture control
3. List important properties of picture control to
show pictures

CCP503.58 15

You might also like