object oriented programming dr. ennis-cole cecs 5100
Post on 12-Jan-2016
221 Views
Preview:
TRANSCRIPT
Object Oriented Object Oriented ProgrammingProgramming
Dr. Ennis-ColeDr. Ennis-Cole
CECS 5100CECS 5100
Object Oriented Object Oriented ProgrammingProgramming
StepsSteps: :
1.) Visual Design1.) Visual Design
2.) Code Writing2.) Code Writing
Object Oriented Object Oriented Programming Programming
Controls toolbar, P. 23Controls toolbar, P. 23
OOP - Visual OOP - Visual C++ C++
MFCMFC
Microsoft Foundation Class Microsoft Foundation Class
* Wizards to develop applications* Wizards to develop applications
* MFC AppWizard (dll) - * MFC AppWizard (dll) - generates source files and generates source files and
resource files resource files
OOP - Visual C++ OOP - Visual C++
MFCMFC
MFC AppWizard (exe) - larger exe MFC AppWizard (exe) - larger exe files files
MFC Active X Control Wizard - MFC Active X Control Wizard - creates starter files for plug-inscreates starter files for plug-ins
OOP Visual C++ OOP Visual C++
MFC
MFC Active X Control Wizard - multimedia, db, client server applications
MFC ATL Wizard - Active Template Library - objects, controls
OOP - Visual C++OOP - Visual C++
Developer Studio - integrated tools for Developer Studio - integrated tools for creating, testing, and refining creating, testing, and refining applications.applications.
Complete development environmentComplete development environment
Popularity of Visual Popularity of Visual C++ C++
A. Code ReusabilityA. Code Reusability
B. Application Wizards (dlls, Active X, B. Application Wizards (dlls, Active X, Atl Com Objects)Atl Com Objects)
C. Integrated development environmentC. Integrated development environment
D. Components and Controls Gallery D. Components and Controls Gallery
(reusable components & controls)(reusable components & controls)
Popularity of Visual Popularity of Visual C++ C++
E. Support for MFC LibraryE. Support for MFC Library
F. PortabilityF. Portability
G. Cross Platform supportG. Cross Platform support
H. Availability in other languagesH. Availability in other languages
I. Supports latest C++ featuresI. Supports latest C++ features
OOP - Visual C++OOP - Visual C++ Day 1: Day 1: Directory, Project, MFC AppWizardDirectory, Project, MFC AppWizard Used pushbutton controls in a dialog boxUsed pushbutton controls in a dialog box Attached the (BN_CLICKED) event to the Attached the (BN_CLICKED) event to the
pushbuttonpushbutton Classes Created: CHelloApp & CHelloDlgClasses Created: CHelloApp & CHelloDlg Prefixes: Functions ON_WM; Messages Prefixes: Functions ON_WM; Messages
WM_; Objects IDC_; Dialog Boxes IDD_WM_; Objects IDC_; Dialog Boxes IDD_
Object Oriented Object Oriented ProgrammingProgramming
OOP - a programming technique that relies OOP - a programming technique that relies on reusable software components that can on reusable software components that can be applied to different types of problems be applied to different types of problems and applications. The programmer makes and applications. The programmer makes the machine work in terms of concepts the machine work in terms of concepts closer to the user’s every day world. closer to the user’s every day world.
Principle unit - Principle unit - An ObjectAn Object
Objects Objects
Separate Components :Separate Components :• Say HelloSay Hello• ExitExit• Each had its own Caption & ID (IDC_…)Each had its own Caption & ID (IDC_…)
Belonged to the CHelloDlg Class Belonged to the CHelloDlg Class An instance of CHelloDlg ClassAn instance of CHelloDlg Class Created within the Visual EnvironmentCreated within the Visual Environment
ObjectsObjects
Private data ( ) Private data ( ) Procedures that could access that data Procedures that could access that data
• written in the CHelloDlg Classwritten in the CHelloDlg Class• Member functions:Member functions:
– OnSayhelloButton( )OnSayhelloButton( )
– OnExitButton( )OnExitButton( )
A program can be thought of as a collection A program can be thought of as a collection of objectsof objects
ObjectsObjects
MessagesMessages• BN_CLICKEDBN_CLICKED• BN_DOUBLECLICKEDBN_DOUBLECLICKED
Respond to predefined external stimuli Respond to predefined external stimuli • Mouse ClickMouse Click
Communication Communication • Represent the events to which an object can Represent the events to which an object can
respondrespond
Structure of a Structure of a FunctionFunction
void void reference, Class reference, Class name ::, function name ::, function
name, ( ), {, name, ( ), {, Comments, Attached Comments, Attached
Code, Comments, }Code, Comments, }
ClassesClasses
Case sensitivityCase sensitivity Properties Tables, P. 43 Properties Tables, P. 43 Group Box, P. 52, Properties Table, P. 59Group Box, P. 52, Properties Table, P. 59 Variables - storage containers:Variables - storage containers:
• Memory LocationMemory Location• Amount of Memory Amount of Memory • m_TestEdit = “ ”;m_TestEdit = “ ”; 20
FFFA, 2 bytes
Num1
Variables - Changeable Variables - Changeable Quantities Quantities
An actual representation of a data typeAn actual representation of a data type• ValueValue IntegerInteger• CSTRINGCSTRING CharacterCharacter• BOOLBOOL Double, FloatDouble, Float
Other Functions:Other Functions:• MessageBox(“ ”); MessageBox(“ ”); • UpdateData(False); - updates screen w/new UpdateData(False); - updates screen w/new
valuesvalues
New Windows New Windows Controls Controls
Edit Box, Check Box, Static, Group Edit Box, Check Box, Static, Group BoxBox
Right Click on on your mouse for Right Click on on your mouse for property Settingsproperty Settings
Use P. 59 for your object’s propertiesUse P. 59 for your object’s properties
Introduction of Keyboard ShortcutsIntroduction of Keyboard Shortcuts
Windows Windows ProgramsPrograms
CalculatorCalculator Paint Paint Invoked via entries in the the Edit Invoked via entries in the the Edit
Box ab| (Calculator or Paint)Box ab| (Calculator or Paint)
EventsEvents Linked with messagesLinked with messages After communication between After communication between
objects, some action takes place. objects, some action takes place. This action has the code in it to This action has the code in it to perform a set task - initialize a perform a set task - initialize a dialog box, paint, execute a system dialog box, paint, execute a system command.command.
The End The End
““That’s all folks.”That’s all folks.”
top related