Professional Documents
Culture Documents
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
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
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
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
CCP503.58 12
Quiz – Objective Type
1. Graphics
The Picture control helps in drawing___________
Pictures
and showing________
CCP503.58 15