Unit-1 GUI Introduction

17
Visual Basic Visual Basic Prepared Prepared By:- By:- Monika Monika Kukreja Kukreja

Transcript of Unit-1 GUI Introduction

Page 1: Unit-1 GUI Introduction

Visual BasicVisual Basic

Prepared By:-Prepared By:-

Monika KukrejaMonika Kukreja

Page 2: Unit-1 GUI Introduction

Unit IUnit IIntroduction to GUI and Windows ProgrammingIntroduction to GUI and Windows Programming GUI Concept & ToolsGUI Concept & Tools

The Title BarThe Title Bar Menu System, Menus and the Menu BarMenu System, Menus and the Menu Bar The Size BoxThe Size Box System Menu BoxSystem Menu Box IconsIcons CursorsCursors Scroll BarsScroll Bars Tool BarTool Bar Client AreaClient Area

Page 3: Unit-1 GUI Introduction

GUI Concept & ToolsGUI Concept & Tools A A graphical user interface (GUI)graphical user interface (GUI) is a user interface that is a user interface that

allows interaction with a computer on its graphical allows interaction with a computer on its graphical components like window, text box, command buttons components like window, text box, command buttons etc.etc.

The GUI includes:The GUI includes: The title barThe title bar Menu system, menus and the menu boxMenu system, menus and the menu box The size boxThe size box System menu boxSystem menu box IconsIcons CursorsCursors Scroll barsScroll bars Tool barTool bar Client areaClient area

Page 4: Unit-1 GUI Introduction
Page 5: Unit-1 GUI Introduction

Title BarTitle Bar: The Title Bar shows the title of the window at : The Title Bar shows the title of the window at the top of the application as horizontal bar. The name of the top of the application as horizontal bar. The name of the application and the name of the project you are the application and the name of the project you are working on.working on.

Menu system, menus and the menu box:Menu system, menus and the menu box: The user The user friendly applications use menu system. This is a system friendly applications use menu system. This is a system that provides a list of commands or options. The menus that provides a list of commands or options. The menus are of two typesare of two types Contact sensitivity menuContact sensitivity menu:: are sensitive to the contact are sensitive to the contact

of mouse pointer. Eg submenu etc of mouse pointer. Eg submenu etc Context sensitivity menuContext sensitivity menu:: are sensitive to the context are sensitive to the context

of your work. Eg in run mode some options are of your work. Eg in run mode some options are available available

The Size Box:The Size Box: The size box is the box placed at the right The size box is the box placed at the right hand corner of the title bar. It is used to minimized, hand corner of the title bar. It is used to minimized, maximized, and close the window.maximized, and close the window.

Page 6: Unit-1 GUI Introduction

System Menu BoxSystem Menu Box: System menu box or the control box : System menu box or the control box is placed at the top left corner of the title bar of the is placed at the top left corner of the title bar of the window. It is needed to minimized, maximized, to window. It is needed to minimized, maximized, to restore, to close it, to move the window.restore, to close it, to move the window.

Icons:Icons: Icons are graphical depictions of various objects Icons are graphical depictions of various objects in Microsoft window. The objects can be programs, files, in Microsoft window. The objects can be programs, files, folders etc.folders etc.

Cursors:Cursors: A cursor is a moving marker or pointer that A cursor is a moving marker or pointer that indicates a position. It changes shapes according the indicates a position. It changes shapes according the area of visibility.area of visibility.

Scroll BarsScroll Bars: A scroll bar is graphical object through which : A scroll bar is graphical object through which continuous text, picture or any other object can be continuous text, picture or any other object can be viewed, if it doesn’t fit into the space of the monitor.viewed, if it doesn’t fit into the space of the monitor.

Tool BarTool Bar: It contains tools or controls that can be : It contains tools or controls that can be inserted in the project. For example text box, labels, inserted in the project. For example text box, labels, check boxes, command buttons. Etccheck boxes, command buttons. Etc

Client AreaClient Area: This area of the window is the working area : This area of the window is the working area or usable area. or usable area.

Page 7: Unit-1 GUI Introduction

Windows ProgrammingWindows Programming Windows includes all sorts of built-in functions and data Windows includes all sorts of built-in functions and data

eg to draw text in different sizes & styles using font data. eg to draw text in different sizes & styles using font data. Windows application programs make use of these built in Windows application programs make use of these built in functions and do not need to supply the program logic to functions and do not need to supply the program logic to do these tasks. Each program logic has its own do these tasks. Each program logic has its own Application Programming Interface (API) and set of Application Programming Interface (API) and set of design rules.design rules.

An interface defines the communication boundary An interface defines the communication boundary between two entities such as piece of software, a between two entities such as piece of software, a hardware device or a user. There are software interfaces hardware device or a user. There are software interfaces that are used for windows programming. They exists that are used for windows programming. They exists between separate software components and provide a between separate software components and provide a programmatic mechanism by which these component programmatic mechanism by which these component can communicate. These can include data types, types can communicate. These can include data types, types of procedures, exception, specifications and method of procedures, exception, specifications and method signatures. signatures.

Page 8: Unit-1 GUI Introduction

What is visual basic?What is visual basic? Visual basic is a very powerful programming system that Visual basic is a very powerful programming system that

helps to develop sophisticated, graphical application that helps to develop sophisticated, graphical application that can be run on Microsoft Windows environment. Visual can be run on Microsoft Windows environment. Visual basic consist of two parts viz. “Visual” and “Basic”. The basic consist of two parts viz. “Visual” and “Basic”. The “Visual” part refers to the method used to create the “Visual” part refers to the method used to create the graphical user interface (GUI). The “Basic” part refers to graphical user interface (GUI). The “Basic” part refers to the BASIC language since visual basic is the descendent the BASIC language since visual basic is the descendent of BASIC (Beginners All Purpose Symbolic Instruction of BASIC (Beginners All Purpose Symbolic Instruction Code) which was often the first language used to learn Code) which was often the first language used to learn programming basics. programming basics.

Visual basic support event driven programming. A Visual basic support event driven programming. A program in general can be developed in three ways in program in general can be developed in three ways in modular programming style or in object oriented modular programming style or in object oriented programming style and event driven programming style. programming style and event driven programming style.

Page 9: Unit-1 GUI Introduction

Features of Visual BasicFeatures of Visual Basic VB is not just a language, but is an Integrated VB is not just a language, but is an Integrated

Development Environment (IDE). VB environment is Development Environment (IDE). VB environment is very friendly which helps to create forms, add controls very friendly which helps to create forms, add controls to form and write code behind the form very quickly to form and write code behind the form very quickly and easily. It has many other features also.and easily. It has many other features also.

It is successor of BASIC languageIt is successor of BASIC language VB supports event driven programming. Every time the VB supports event driven programming. Every time the

user clicks a command button or presses the mouse, user clicks a command button or presses the mouse, an event stream is generated and code that has been an event stream is generated and code that has been written behind the event is executed. After execution of written behind the event is executed. After execution of the code the control again comes back to the user.the code the control again comes back to the user.

Common programming Platform: VB provides a Common programming Platform: VB provides a common programming platform across all MS-Office common programming platform across all MS-Office applications.applications.

Page 10: Unit-1 GUI Introduction

Internet based application. VB can be used to write Internet based application. VB can be used to write internet programs. VB can be extended to other internet programs. VB can be extended to other environment, it means objects developed in visual basic environment, it means objects developed in visual basic can be used in other applications by the use of Active X can be used in other applications by the use of Active X Controls Controls

Quick error detection/correction.Quick error detection/correction. ActiveX support.ActiveX support. VB can create executable files, Active X controls, DLL VB can create executable files, Active X controls, DLL

files but is primarily used to develop Windows files but is primarily used to develop Windows applications and to inter web database systems.applications and to inter web database systems.

Dialog boxes with less functionality can be used to Dialog boxes with less functionality can be used to provide pop-up capabilities.provide pop-up capabilities.

Controls have attributes and event handlers associated Controls have attributes and event handlers associated with them, default values are provided when the control with them, default values are provided when the control is created, but may be changed by the programmer.is created, but may be changed by the programmer.

VB follows some of the object oriented concepts, every VB follows some of the object oriented concepts, every thing in VB is an object. As the objects can be developed thing in VB is an object. As the objects can be developed separately, they can also be tested independently.separately, they can also be tested independently.

Page 11: Unit-1 GUI Introduction

Visual Basic EnvironmentVisual Basic Environment There are certain steps to be followed while There are certain steps to be followed while

developing a program in VB such as design, developing a program in VB such as design, editing, compiling and debugging within a editing, compiling and debugging within a common environment.common environment.

Click at Start buttonClick at Start button Click at Programs->Microsoft Visual Studio-Click at Programs->Microsoft Visual Studio-

>Microsoft Visual Basic>Microsoft Visual Basic Select New Project dialog. Select New Project dialog.

project in VB is a collection of several different project in VB is a collection of several different types of files that make up application.types of files that make up application.

Page 12: Unit-1 GUI Introduction

Various types of projects are available VB as followsVarious types of projects are available VB as follows Standard EXEStandard EXE ActiveX EXEActiveX EXE ActiveX DLLActiveX DLL ActiveX ControlsActiveX Controls ActiveX Document EXEActiveX Document EXE ActiveX Document DLLActiveX Document DLL VB Application WizardVB Application Wizard VB Wizard ManagerVB Wizard Manager Data ProjectData Project DHTML ApplicationDHTML Application Add inAdd in VB Enterprise Edition ControlsVB Enterprise Edition Controls

Page 13: Unit-1 GUI Introduction

Visual Basic Integrated Visual Basic Integrated Development Environment (IDE)Development Environment (IDE)

Tool BoxTool Box Form DesignerForm Designer Project Explorer WindowProject Explorer Window Properties WindowProperties Window Menu Bar and Pull-down MenusMenu Bar and Pull-down Menus Code Editor WindowCode Editor Window Standard Tool BarStandard Tool Bar

Docking the window in the IDE:- Docking the window in the IDE:- The windows in the VB The windows in the VB environment can be re-positioned or moved from its original environment can be re-positioned or moved from its original position to the position as required by the user. The new position to the position as required by the user. The new position is not permanent. The movement of window is called position is not permanent. The movement of window is called docking.docking.

Visual Basic Application ModesVisual Basic Application ModesVisual Basic application works in three modesVisual Basic application works in three modesDesign mode, run mode and break/suspended mode Design mode, run mode and break/suspended mode

Page 14: Unit-1 GUI Introduction

Important File Extensions…Important File Extensions…

.vbg- Group project file which contains a list of .vbg- Group project file which contains a list of all projects in one groupall projects in one group

.vbp- Project file which has a list of all files and .vbp- Project file which has a list of all files and components related to the projectcomponents related to the project

.frm- Forms modules file which contains the .frm- Forms modules file which contains the textual information about the form, its controls & textual information about the form, its controls & their property settingtheir property setting

.frx- Form data file which is a binary data file for .frx- Form data file which is a binary data file for the form. It contains the information about the the form. It contains the information about the pictures and icons.pictures and icons.

.bas- Standard module file which contains the .bas- Standard module file which contains the sub-procedures & function procedures.sub-procedures & function procedures.

Page 15: Unit-1 GUI Introduction

Important File Extensions…Important File Extensions…

..ocx- ActiveX control file which is used for ocx- ActiveX control file which is used for addition to the standard controls that can be addition to the standard controls that can be added to the toolbox.added to the toolbox.

.cls- Class module file which contains the class .cls- Class module file which contains the class definition, its method and its procedures.definition, its method and its procedures.

.exe- ActiveX exe file or an out of process .exe- ActiveX exe file or an out of process component file, that provides reusable code.component file, that provides reusable code.

.dll- ActiveX dll file or an in process component .dll- ActiveX dll file or an in process component file that provide reusable codes.file that provide reusable codes.

Page 16: Unit-1 GUI Introduction

VB Building BlocksVB Building Blocks

The VB toolbox contains the tools that you can to draw The VB toolbox contains the tools that you can to draw controls on your forms. The controls that are always controls on your forms. The controls that are always included in toolbox are integral part of Standard Exe included in toolbox are integral part of Standard Exe projects are known as intrinsic controls.projects are known as intrinsic controls.

ObjectObject PropertiesProperties EventsEvents Forms Forms ControlsControls ModulesModules MethodsMethods Event proceduresEvent procedures General proceduresGeneral procedures

Page 17: Unit-1 GUI Introduction

Container Controls:Container Controls: A container is a control that can hold A container is a control that can hold other controls within it. Eg. A frame or a picture box or other controls within it. Eg. A frame or a picture box or simply your form. Controls inside a container are known simply your form. Controls inside a container are known as child controls.as child controls.

Object:-Object:- A object can be said to be a programmable A object can be said to be a programmable entity, containing both code and data. This entity can entity, containing both code and data. This entity can be treated & controlled as a unit.. Eg Text Box controls, be treated & controlled as a unit.. Eg Text Box controls, Frame controls, List Box controls etc. whenever the Frame controls, List Box controls etc. whenever the object is used it must have name. object is used it must have name. A controls name is one of its most important attribute. A controls name is one of its most important attribute. While naming controls you need to take care of these While naming controls you need to take care of these rules:rules:

Must begin with a letterMust begin with a letter Must contain only letters, numbers, and the Must contain only letters, numbers, and the

underscore; punctuation characters & spaces are underscore; punctuation characters & spaces are not allowed.not allowed.

Must be no longer than 40 charactersMust be no longer than 40 characters