SlideShare a Scribd company logo
1 of 18
Unit 4
VB OBJECTS & GRAPHICS
1
R. BHUVANESWARI
ASST.PROFESSOR
DEPT OF COMPUTER SCIENCE AND APPLICATION
DKM COLLEGE FOR WOMEN
(AUTONOMOUS)
VELLORE
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 2
Menus
 Windows applications provide groups of related commands in Menus.
These commands depends on the application
 Open and Save are frequently found in applications.
 Menus are also known as controls but, menus behave differently from
other controls.
 Visual Basic provides an easy way to create menus with the Menu
Editor dialog.
 An picture of menu editor is given below:
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 3
Creating Menus
 you invoke this tool from the Menu Editor button on the standard
toolbar or by pressing the Ctrl+E shortcut key or choosing Menu Editor
command in the Tools menu.
 The Menu Editor is a Visual Basic dialog box that manages menus in
your programs. With the Menu Editor, you can:
Add new menus
Modify and reorder existing menus
Delete old menus
Add special effects to your menus, such as access keys, check marks, and keyboard Shortcut
How to create a list of menu commands on a form
1. Click the form itself
2. On the Visual Basic toolbar, click the Menu Editor icon, or select Menu Editor from the Tools menu.
3. In the Caption text box, type the menu caption (the name that will appear on the menu bar), and then press
TAB.
4. In the Name text box, type the menu name (the name the menu has in the program code). By convention,
programmers use the mnu object name prefix to identify both menus and menu commands.
5. To add the menu to your program menu bar, click Next. The Menu Editor clears the dialog box for the next
menu item. As you build your menus, the structure of the menus and commands appear at the bottom of the
dialog box.
6. In the Caption text box, type the caption of your first menu command.
7. Press tab, and then type the object name of the command in the Name text box.
8. With this first command highlighted in the menu list box, click the right arrow button in the
Menu Editor. In the Menu list box, the command moves one indent (four spaces) to the right. Click the right
arrow button in the Menu Editor dialog box to move items to the right, and click the left arrow button to move
items to the left.
9. Click Next, and then continue to add commands to your menu.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 4
adding more menus and procedures
To add more menus
1. When you’re ready to add another menu, click the left arrow button to
make the menu flush left in the Menu list box.
2. To add another menu and menu commands, repeat Steps 3 through 9 in
the preceding procedure.
3. When you’re finished entering menus and commands, click OK to close
the Menu Editor.
The Menu Editor closes, and your form appears in the programming
environment with the menus you created.
Adding Event Procedures
 after you add menus to your form, you can use event procedures to
process the menu commands.
 Clicking a menu command on the form in the programming environment
displays the event procedure that runs when the menu command is
chosen.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 5
Mouse Events
 Visual Basic responds to various mouse events, which are recognized by
most of the controls
 The main mouse events are
 MouseDown
 MouseUp
 MouseMove.
 Click
 Dblclick
 MouseDown occurs when the user presses any mouse button
MouseUp occurs when the user releases any mouse button
 MouseMove occurs when the user moves mouse from one place to
another into the screen
 Click When user presses and releases a mouse button.
 Dblclick When user presses and releases and again presses and releases
a mouse button.
 These events use the arguments button, Shift, X, Y and they contain
information about the mouse's condition when the button is clicked.
MDI
 The Multiple Document Interface (MDI) was designed
to simplify the exchange of information among
documents, all under the same roof.
 With the main application, you can maintain multiple
open windows, but not multiple copies of the
application.
 Data exchange is easier when you can view and
compare many documents simultaneously.
 OPEN multiple documents at the same time and allow
the user to switch among them with a mouse-click
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 6
 Each document is displayed in its own window, and all document
windows have the same behaviour.
 The main Form, or MDI Form, isn't duplicated, but it acts as a
container for all the windows,
 it is called the parent window.
 The windows in which the individual documents are displayed are
called Child windows.
 An MDI application must have at least two Form, the parent
Form and one or more child Forms.
 Each of these Forms has certain properties.
 There can be many child forms contained within the parent
Form, but there can be only one parent Form
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 7
HOW TO CREATE MDI FORM
 To create an MDI application, follow these steps:
 Start a new project and then choose Project >>> Add MDI Form to
add the parent Form.
 Set the Form's caption to MDI Window
 Choose Project >>> Add Form to add a SDI Form.
 Make this Form as child of MDI Form by setting the MDI Child
property of the SDI Form to True. Set the caption property to
MDI Child window.
 Visual Basic automatically associates this new Form with the
parent Form. This child Form can't exist outside the parent Form;
in the words, it can only be opened within the parent Form.

Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 8
Parent and Child Menus
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 9
MDI Form cannot contain objects other than child Forms,
but MDI Forms can have their own menus.
Dialog Boxes
 it is simply a form in a program that contains input controls
designed to receive information
 To make your programming faster, Visual Basic includes an
ActiveX control, called CommonDialog.
 There are 6 common dialog controls such as open,save,..
 If the dialog box you want to use is not included in this ready-
made collection of objects, you can create a new one
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 10
working with graphics
 Working with graphics is easy in Visual Basic 6.
 VB6 gives you the flexibility and power to make graphical
applications in easy steps.
 It is rich in graphics related features.
 The built-in methods, properties and events allow you to use these
features most effectively.
 Graphic methods
 The graphic methods allow you to draw on the form and the
PictureBox control.
 In Visual Basic 6, graphic methods are only supported by the form
object and the PictureBox control.
 common graphic methods are
1. Print 5. PSet
2. Cls 6. Circle
3. Point 7. PaintPicture
4. Refresh 8. TextHeight & width
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 11
Graphics Methods
 Print: Print is the simplest graphic method in Visual Basic 6. It
prints some text on the form or on the PictureBox control. It
displays texts.
 Cls: The Cls method is another simple graphic method that is used
to clear the surface of the form or the PictureBox control. If some
texts are present, you can use the Cls method to remove the texts.
It clears any drawing created by the graphic methods.
 Point: The Point method returns the color value from an image for
a pixel at a particular point. This method is generally used to
retrieve color values from bitmaps.
 Refresh: The refresh method redraws a control or object.
Generally, controls are refreshed automatically most of the times.
But in some cases, you need to refresh a control’s appearance
manually by explicitly invoking the Refresh method.
 PSet: The PSet method sets the color of a single pixel on the
form. This method is used to draw points.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 12
Graphic properties
 Line: The Line method draws a line. Using the Line method, you can
also draw other geometric shapes such as rectangle, triangle etc.
 Circle: The Circle method draws a circle. Using the Circle method,
you can also draw other geometric shapes such ellipses, arcs etc.
 PaintPicture: The PaintPicture method displays an image on the
form at run-time.
 TextHeight: The TextHeight method returns the height of a
string on the form at run-time.
 TextWidth: The TextWidth method returns the width of a string
on the form at run-time.
Graphic properties
 The graphic properties are useful while working with the graphic
methods.
 the following are the graphic properties:
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 13
Graphic properties
 DrawMode: The DrawMode property sets the mode of drawing for the appearance of
output from the graphic methods. In the DrawMode property, you can choose from a
variety of values.
 DrawStyle: The DrawStyle property sets the line style of any drawing from any
graphic methods. It allows you to draw shapes of different line styles such as solid,
dotted, dashed shapes etc.
 DrawWidth: The DrawWidth property sets the line width of any drawing from any
graphic methods. While drawing shapes, you can control the thickness of the lines
using this property.
 FillColor: The FillColor property is used to fill any shapes with a color. You may use the
symbolic color constants to fill your shapes. You may also use the color codes as well as
the RGB function.
 FillStyle: The FillStyle property lets you fill shapes in a particular filling style.
 ForeColor: The ForeColor property is used to set or return the foreground color.
 AutoRedraw: Set the AutoRedraw property to True to get a persistent graphics when
you’re calling the graphic methods from any event, but not from the Paint event.
 ClipControls: Set the ClipControls property to True to make the graphic methods
repaint an object.
 Picture: The Picture property is used to set a picture. Pictures can be set both at
design time and run-time.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 14
Graphic example
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 15
Drawing lines
 The Line method lets you draw lines in Visual Basic 6.
 You need to specify the starting point and the finishing point
of the line in the argument.
 You may also specify the color of the line. This is optional,
though.
Example:
 The following code example shows how to draw a simple
line using the Line method in Visual Basic 6.
private Sub cmdShow_Click()
DrawWidth = 5
Line (0, 0)-(2000, 2000), vbBlue
End Sub
A line with drawing styles: example
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 16
 A line with drawing styles
Form’s DrawStyle property is used to draw lines using a particular style.
 The constant values of the DrawStyle property are 0 (vbSolid), 1 (vbDash), 2
(vbDot), 3 (vbDashDot, 4 (vbDashDotDot), 5 (vbTransparent) and 6
(vbInsideSolid). The default value is 0, vbSolid.
 You may use the numeric constant or the symbolic constant such as vbSolid,
vbDash etc to change drawing styles in your code.
Example :
DrawWidth = 1
DrawStyle = 1
Line (0, 0)-(2000, 2000), vbBlue
DrawStyle = vbDash
Dot Line (100, 900)-(2800, 2800), vbRed
Drawing circles
Copyright 1999 Prentice-Hall, Inc. 17
 You can draw a circle using the Circle method in Visual Basic 6.
 You may also use the Circle method to draw different geometric shapes such as
ellipses, arcs etc.
 You need to specify the circle’s center and radius values to draw a circle using
the Circle method.
Example:
Private Sub cmdShow_Click()
DrawWidth = 3
Circle (1800, 1800), 1000, vbRed
End Sub
In the above code, (1800, 1800) is the circle’s center, and the radius value is 1000.
The color constant ‘vbRed’ is an optional argument.
If you want to fill some color on circle you can use following code:
Private Sub cmdShow_Click()
FillStyle = vbSolid
FillColor = &H80C0FF
DrawWidth = 3
Circle (1800, 1800), 1000, vbRed
End Sub
For more example on graphics visit:
https://www.go4expert.com/articles/graphics-visual-basic-6-t30202/
Using the Common Dialog Control
 Before you can use the CommonDialog control, you need to verify that it is
in your toolbox. If you don’t see the CommonDialog icon, follow this
procedure to add it to the toolbox.
 To add the CommonDialog control to the toolbox
1. From the Project menu, click Components.
2. Click the Controls tab.
3. Ensure that the Selected Items Only box is not checked.
4. Place a check mark next to Microsoft Common Dialog Control, and then click
OK.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 18

More Related Content

Similar to VB6_OBJECTS AND GRAPHICS.ppt

Software engineering modeling lab lectures
Software engineering modeling lab lecturesSoftware engineering modeling lab lectures
Software engineering modeling lab lecturesmarwaeng
 
Cis 407 i lab 2 of 7
Cis 407 i lab 2 of 7Cis 407 i lab 2 of 7
Cis 407 i lab 2 of 7helpido9
 
Adobe photoshop cs6
Adobe photoshop cs6Adobe photoshop cs6
Adobe photoshop cs6Ila Azmil
 
Adobe photoshop cs6
Adobe photoshop cs6Adobe photoshop cs6
Adobe photoshop cs6ilaazmil2
 
Adobe photoshop cs6 tutorial
Adobe photoshop cs6 tutorialAdobe photoshop cs6 tutorial
Adobe photoshop cs6 tutorialAgung Yuwono
 
Learning Illustrator CS6 with 100 practical exercises
Learning Illustrator CS6 with 100 practical exercisesLearning Illustrator CS6 with 100 practical exercises
Learning Illustrator CS6 with 100 practical exercisesMCB Press
 
Future Scope in Application Developement of Visual Basic
Future Scope in Application Developement of Visual BasicFuture Scope in Application Developement of Visual Basic
Future Scope in Application Developement of Visual Basicijtsrd
 
2D CAD Module by gonzalochris
2D CAD Module by gonzalochris2D CAD Module by gonzalochris
2D CAD Module by gonzalochrisChris Gonzalo
 
Office productivity tools (part ii) (2.74 mb)
Office productivity tools (part ii) (2.74 mb)Office productivity tools (part ii) (2.74 mb)
Office productivity tools (part ii) (2.74 mb)IMRAN KHAN
 
Photoshop pdf
Photoshop pdfPhotoshop pdf
Photoshop pdfKim B
 
Visual studio ide componects dot net framwork
Visual studio ide componects dot net framworkVisual studio ide componects dot net framwork
Visual studio ide componects dot net framworkDipen Parmar
 
Adobe Photoshop CS6 tutorial 2013
Adobe Photoshop CS6 tutorial 2013Adobe Photoshop CS6 tutorial 2013
Adobe Photoshop CS6 tutorial 2013Jessie Doan
 
Microsoft office power_point_2007_tutorial
Microsoft office power_point_2007_tutorialMicrosoft office power_point_2007_tutorial
Microsoft office power_point_2007_tutorialMizuhashi Yuki
 
Adobe illustrator cs5 full tutorials
Adobe illustrator cs5  full tutorialsAdobe illustrator cs5  full tutorials
Adobe illustrator cs5 full tutorialsMuhammad Taqi
 
Adobe Illustrator CS5 Part 1 : Introduction to Illustrator
Adobe Illustrator CS5 Part 1 : Introduction to IllustratorAdobe Illustrator CS5 Part 1 : Introduction to Illustrator
Adobe Illustrator CS5 Part 1 : Introduction to Illustratorcsula its training
 

Similar to VB6_OBJECTS AND GRAPHICS.ppt (20)

Software engineering modeling lab lectures
Software engineering modeling lab lecturesSoftware engineering modeling lab lectures
Software engineering modeling lab lectures
 
Cis 407 i lab 2 of 7
Cis 407 i lab 2 of 7Cis 407 i lab 2 of 7
Cis 407 i lab 2 of 7
 
Adobe photoshop cs6
Adobe photoshop cs6Adobe photoshop cs6
Adobe photoshop cs6
 
Adobe photoshop cs6
Adobe photoshop cs6Adobe photoshop cs6
Adobe photoshop cs6
 
Adobe photoshop cs6 tutorial
Adobe photoshop cs6 tutorialAdobe photoshop cs6 tutorial
Adobe photoshop cs6 tutorial
 
Learning Illustrator CS6 with 100 practical exercises
Learning Illustrator CS6 with 100 practical exercisesLearning Illustrator CS6 with 100 practical exercises
Learning Illustrator CS6 with 100 practical exercises
 
Future Scope in Application Developement of Visual Basic
Future Scope in Application Developement of Visual BasicFuture Scope in Application Developement of Visual Basic
Future Scope in Application Developement of Visual Basic
 
2D CAD Module by gonzalochris
2D CAD Module by gonzalochris2D CAD Module by gonzalochris
2D CAD Module by gonzalochris
 
Intake 37 9
Intake 37 9Intake 37 9
Intake 37 9
 
Office productivity tools (part ii) (2.74 mb)
Office productivity tools (part ii) (2.74 mb)Office productivity tools (part ii) (2.74 mb)
Office productivity tools (part ii) (2.74 mb)
 
Introduction
IntroductionIntroduction
Introduction
 
Vb%20 tutorial
Vb%20 tutorialVb%20 tutorial
Vb%20 tutorial
 
Photoshop pdf
Photoshop pdfPhotoshop pdf
Photoshop pdf
 
Vb6.0 intro
Vb6.0 introVb6.0 intro
Vb6.0 intro
 
Visual studio ide componects dot net framwork
Visual studio ide componects dot net framworkVisual studio ide componects dot net framwork
Visual studio ide componects dot net framwork
 
Adobe Photoshop CS6 tutorial 2013
Adobe Photoshop CS6 tutorial 2013Adobe Photoshop CS6 tutorial 2013
Adobe Photoshop CS6 tutorial 2013
 
Microsoft office power_point_2007_tutorial
Microsoft office power_point_2007_tutorialMicrosoft office power_point_2007_tutorial
Microsoft office power_point_2007_tutorial
 
Visual basic
Visual basicVisual basic
Visual basic
 
Adobe illustrator cs5 full tutorials
Adobe illustrator cs5  full tutorialsAdobe illustrator cs5  full tutorials
Adobe illustrator cs5 full tutorials
 
Adobe Illustrator CS5 Part 1 : Introduction to Illustrator
Adobe Illustrator CS5 Part 1 : Introduction to IllustratorAdobe Illustrator CS5 Part 1 : Introduction to Illustrator
Adobe Illustrator CS5 Part 1 : Introduction to Illustrator
 

More from BhuvanaR13

CRYPTOGRAPHY (2).pdf
CRYPTOGRAPHY (2).pdfCRYPTOGRAPHY (2).pdf
CRYPTOGRAPHY (2).pdfBhuvanaR13
 
Linux File System.docx
Linux File System.docxLinux File System.docx
Linux File System.docxBhuvanaR13
 
UNIT I LINUX.docx
UNIT I LINUX.docxUNIT I LINUX.docx
UNIT I LINUX.docxBhuvanaR13
 
networktopology-final.pptx
networktopology-final.pptxnetworktopology-final.pptx
networktopology-final.pptxBhuvanaR13
 
UNIT III_DCN.pdf
UNIT III_DCN.pdfUNIT III_DCN.pdf
UNIT III_DCN.pdfBhuvanaR13
 
UNIT 2_DCN-converted.pdf
UNIT 2_DCN-converted.pdfUNIT 2_DCN-converted.pdf
UNIT 2_DCN-converted.pdfBhuvanaR13
 
UNIT I_DCN.pdf
UNIT I_DCN.pdfUNIT I_DCN.pdf
UNIT I_DCN.pdfBhuvanaR13
 
INTRODUCTION TO MOBILE COMPUTING.pptx
INTRODUCTION TO MOBILE COMPUTING.pptxINTRODUCTION TO MOBILE COMPUTING.pptx
INTRODUCTION TO MOBILE COMPUTING.pptxBhuvanaR13
 
VB_ERROR CONTROL_FILE HANDLING.ppt
VB_ERROR CONTROL_FILE HANDLING.pptVB_ERROR CONTROL_FILE HANDLING.ppt
VB_ERROR CONTROL_FILE HANDLING.pptBhuvanaR13
 

More from BhuvanaR13 (9)

CRYPTOGRAPHY (2).pdf
CRYPTOGRAPHY (2).pdfCRYPTOGRAPHY (2).pdf
CRYPTOGRAPHY (2).pdf
 
Linux File System.docx
Linux File System.docxLinux File System.docx
Linux File System.docx
 
UNIT I LINUX.docx
UNIT I LINUX.docxUNIT I LINUX.docx
UNIT I LINUX.docx
 
networktopology-final.pptx
networktopology-final.pptxnetworktopology-final.pptx
networktopology-final.pptx
 
UNIT III_DCN.pdf
UNIT III_DCN.pdfUNIT III_DCN.pdf
UNIT III_DCN.pdf
 
UNIT 2_DCN-converted.pdf
UNIT 2_DCN-converted.pdfUNIT 2_DCN-converted.pdf
UNIT 2_DCN-converted.pdf
 
UNIT I_DCN.pdf
UNIT I_DCN.pdfUNIT I_DCN.pdf
UNIT I_DCN.pdf
 
INTRODUCTION TO MOBILE COMPUTING.pptx
INTRODUCTION TO MOBILE COMPUTING.pptxINTRODUCTION TO MOBILE COMPUTING.pptx
INTRODUCTION TO MOBILE COMPUTING.pptx
 
VB_ERROR CONTROL_FILE HANDLING.ppt
VB_ERROR CONTROL_FILE HANDLING.pptVB_ERROR CONTROL_FILE HANDLING.ppt
VB_ERROR CONTROL_FILE HANDLING.ppt
 

Recently uploaded

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 

VB6_OBJECTS AND GRAPHICS.ppt

  • 1. Unit 4 VB OBJECTS & GRAPHICS 1 R. BHUVANESWARI ASST.PROFESSOR DEPT OF COMPUTER SCIENCE AND APPLICATION DKM COLLEGE FOR WOMEN (AUTONOMOUS) VELLORE
  • 2. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 2 Menus  Windows applications provide groups of related commands in Menus. These commands depends on the application  Open and Save are frequently found in applications.  Menus are also known as controls but, menus behave differently from other controls.  Visual Basic provides an easy way to create menus with the Menu Editor dialog.  An picture of menu editor is given below:
  • 3. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 3 Creating Menus  you invoke this tool from the Menu Editor button on the standard toolbar or by pressing the Ctrl+E shortcut key or choosing Menu Editor command in the Tools menu.  The Menu Editor is a Visual Basic dialog box that manages menus in your programs. With the Menu Editor, you can: Add new menus Modify and reorder existing menus Delete old menus Add special effects to your menus, such as access keys, check marks, and keyboard Shortcut How to create a list of menu commands on a form 1. Click the form itself 2. On the Visual Basic toolbar, click the Menu Editor icon, or select Menu Editor from the Tools menu. 3. In the Caption text box, type the menu caption (the name that will appear on the menu bar), and then press TAB. 4. In the Name text box, type the menu name (the name the menu has in the program code). By convention, programmers use the mnu object name prefix to identify both menus and menu commands. 5. To add the menu to your program menu bar, click Next. The Menu Editor clears the dialog box for the next menu item. As you build your menus, the structure of the menus and commands appear at the bottom of the dialog box. 6. In the Caption text box, type the caption of your first menu command. 7. Press tab, and then type the object name of the command in the Name text box. 8. With this first command highlighted in the menu list box, click the right arrow button in the Menu Editor. In the Menu list box, the command moves one indent (four spaces) to the right. Click the right arrow button in the Menu Editor dialog box to move items to the right, and click the left arrow button to move items to the left. 9. Click Next, and then continue to add commands to your menu.
  • 4. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 4 adding more menus and procedures To add more menus 1. When you’re ready to add another menu, click the left arrow button to make the menu flush left in the Menu list box. 2. To add another menu and menu commands, repeat Steps 3 through 9 in the preceding procedure. 3. When you’re finished entering menus and commands, click OK to close the Menu Editor. The Menu Editor closes, and your form appears in the programming environment with the menus you created. Adding Event Procedures  after you add menus to your form, you can use event procedures to process the menu commands.  Clicking a menu command on the form in the programming environment displays the event procedure that runs when the menu command is chosen.
  • 5. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 5 Mouse Events  Visual Basic responds to various mouse events, which are recognized by most of the controls  The main mouse events are  MouseDown  MouseUp  MouseMove.  Click  Dblclick  MouseDown occurs when the user presses any mouse button MouseUp occurs when the user releases any mouse button  MouseMove occurs when the user moves mouse from one place to another into the screen  Click When user presses and releases a mouse button.  Dblclick When user presses and releases and again presses and releases a mouse button.  These events use the arguments button, Shift, X, Y and they contain information about the mouse's condition when the button is clicked.
  • 6. MDI  The Multiple Document Interface (MDI) was designed to simplify the exchange of information among documents, all under the same roof.  With the main application, you can maintain multiple open windows, but not multiple copies of the application.  Data exchange is easier when you can view and compare many documents simultaneously.  OPEN multiple documents at the same time and allow the user to switch among them with a mouse-click Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 6
  • 7.  Each document is displayed in its own window, and all document windows have the same behaviour.  The main Form, or MDI Form, isn't duplicated, but it acts as a container for all the windows,  it is called the parent window.  The windows in which the individual documents are displayed are called Child windows.  An MDI application must have at least two Form, the parent Form and one or more child Forms.  Each of these Forms has certain properties.  There can be many child forms contained within the parent Form, but there can be only one parent Form Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 7
  • 8. HOW TO CREATE MDI FORM  To create an MDI application, follow these steps:  Start a new project and then choose Project >>> Add MDI Form to add the parent Form.  Set the Form's caption to MDI Window  Choose Project >>> Add Form to add a SDI Form.  Make this Form as child of MDI Form by setting the MDI Child property of the SDI Form to True. Set the caption property to MDI Child window.  Visual Basic automatically associates this new Form with the parent Form. This child Form can't exist outside the parent Form; in the words, it can only be opened within the parent Form.  Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 8
  • 9. Parent and Child Menus Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 9 MDI Form cannot contain objects other than child Forms, but MDI Forms can have their own menus.
  • 10. Dialog Boxes  it is simply a form in a program that contains input controls designed to receive information  To make your programming faster, Visual Basic includes an ActiveX control, called CommonDialog.  There are 6 common dialog controls such as open,save,..  If the dialog box you want to use is not included in this ready- made collection of objects, you can create a new one Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 10
  • 11. working with graphics  Working with graphics is easy in Visual Basic 6.  VB6 gives you the flexibility and power to make graphical applications in easy steps.  It is rich in graphics related features.  The built-in methods, properties and events allow you to use these features most effectively.  Graphic methods  The graphic methods allow you to draw on the form and the PictureBox control.  In Visual Basic 6, graphic methods are only supported by the form object and the PictureBox control.  common graphic methods are 1. Print 5. PSet 2. Cls 6. Circle 3. Point 7. PaintPicture 4. Refresh 8. TextHeight & width Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 11
  • 12. Graphics Methods  Print: Print is the simplest graphic method in Visual Basic 6. It prints some text on the form or on the PictureBox control. It displays texts.  Cls: The Cls method is another simple graphic method that is used to clear the surface of the form or the PictureBox control. If some texts are present, you can use the Cls method to remove the texts. It clears any drawing created by the graphic methods.  Point: The Point method returns the color value from an image for a pixel at a particular point. This method is generally used to retrieve color values from bitmaps.  Refresh: The refresh method redraws a control or object. Generally, controls are refreshed automatically most of the times. But in some cases, you need to refresh a control’s appearance manually by explicitly invoking the Refresh method.  PSet: The PSet method sets the color of a single pixel on the form. This method is used to draw points. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 12
  • 13. Graphic properties  Line: The Line method draws a line. Using the Line method, you can also draw other geometric shapes such as rectangle, triangle etc.  Circle: The Circle method draws a circle. Using the Circle method, you can also draw other geometric shapes such ellipses, arcs etc.  PaintPicture: The PaintPicture method displays an image on the form at run-time.  TextHeight: The TextHeight method returns the height of a string on the form at run-time.  TextWidth: The TextWidth method returns the width of a string on the form at run-time. Graphic properties  The graphic properties are useful while working with the graphic methods.  the following are the graphic properties: Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 13
  • 14. Graphic properties  DrawMode: The DrawMode property sets the mode of drawing for the appearance of output from the graphic methods. In the DrawMode property, you can choose from a variety of values.  DrawStyle: The DrawStyle property sets the line style of any drawing from any graphic methods. It allows you to draw shapes of different line styles such as solid, dotted, dashed shapes etc.  DrawWidth: The DrawWidth property sets the line width of any drawing from any graphic methods. While drawing shapes, you can control the thickness of the lines using this property.  FillColor: The FillColor property is used to fill any shapes with a color. You may use the symbolic color constants to fill your shapes. You may also use the color codes as well as the RGB function.  FillStyle: The FillStyle property lets you fill shapes in a particular filling style.  ForeColor: The ForeColor property is used to set or return the foreground color.  AutoRedraw: Set the AutoRedraw property to True to get a persistent graphics when you’re calling the graphic methods from any event, but not from the Paint event.  ClipControls: Set the ClipControls property to True to make the graphic methods repaint an object.  Picture: The Picture property is used to set a picture. Pictures can be set both at design time and run-time. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 14
  • 15. Graphic example Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 15 Drawing lines  The Line method lets you draw lines in Visual Basic 6.  You need to specify the starting point and the finishing point of the line in the argument.  You may also specify the color of the line. This is optional, though. Example:  The following code example shows how to draw a simple line using the Line method in Visual Basic 6. private Sub cmdShow_Click() DrawWidth = 5 Line (0, 0)-(2000, 2000), vbBlue End Sub
  • 16. A line with drawing styles: example Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 16  A line with drawing styles Form’s DrawStyle property is used to draw lines using a particular style.  The constant values of the DrawStyle property are 0 (vbSolid), 1 (vbDash), 2 (vbDot), 3 (vbDashDot, 4 (vbDashDotDot), 5 (vbTransparent) and 6 (vbInsideSolid). The default value is 0, vbSolid.  You may use the numeric constant or the symbolic constant such as vbSolid, vbDash etc to change drawing styles in your code. Example : DrawWidth = 1 DrawStyle = 1 Line (0, 0)-(2000, 2000), vbBlue DrawStyle = vbDash Dot Line (100, 900)-(2800, 2800), vbRed
  • 17. Drawing circles Copyright 1999 Prentice-Hall, Inc. 17  You can draw a circle using the Circle method in Visual Basic 6.  You may also use the Circle method to draw different geometric shapes such as ellipses, arcs etc.  You need to specify the circle’s center and radius values to draw a circle using the Circle method. Example: Private Sub cmdShow_Click() DrawWidth = 3 Circle (1800, 1800), 1000, vbRed End Sub In the above code, (1800, 1800) is the circle’s center, and the radius value is 1000. The color constant ‘vbRed’ is an optional argument. If you want to fill some color on circle you can use following code: Private Sub cmdShow_Click() FillStyle = vbSolid FillColor = &H80C0FF DrawWidth = 3 Circle (1800, 1800), 1000, vbRed End Sub For more example on graphics visit: https://www.go4expert.com/articles/graphics-visual-basic-6-t30202/
  • 18. Using the Common Dialog Control  Before you can use the CommonDialog control, you need to verify that it is in your toolbox. If you don’t see the CommonDialog icon, follow this procedure to add it to the toolbox.  To add the CommonDialog control to the toolbox 1. From the Project menu, click Components. 2. Click the Controls tab. 3. Ensure that the Selected Items Only box is not checked. 4. Place a check mark next to Microsoft Common Dialog Control, and then click OK. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 18

Editor's Notes

  1. Exploring Microsoft Visual Basic 6.0