Object Oriented Programming

advertisement
Object Oriented Programming
Dr. Ennis-Cole
CECS 5100
Object Oriented Programming
Steps:
1.) Visual Design
2.) Code Writing
Object Oriented Programming
Controls toolbar, P. 23
OOP - Visual C++
MFC
Microsoft Foundation Class
* Wizards to develop applications
* MFC AppWizard (dll) generates source files and
resource files
OOP - Visual C++
MFC
MFC AppWizard (exe) - larger exe files
MFC Active X Control Wizard - creates
starter files for plug-ins
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++
Developer Studio - integrated tools for
creating, testing, and refining
applications.
Complete development environment
Popularity of Visual C++
A. Code Reusability
B. Application Wizards (dlls, Active X,
Atl Com Objects)
C. Integrated development environment
D. Components and Controls Gallery
(reusable components & controls)
Popularity of Visual C++
E. Support for MFC Library
F. Portability
G. Cross Platform support
H. Availability in other languages
I. Supports latest C++ features
OOP - Visual C++
 Day
1:
 Directory, Project, MFC AppWizard
 Used pushbutton controls in a dialog box
 Attached the (BN_CLICKED) event to the
pushbutton
 Classes Created: CHelloApp & CHelloDlg
 Prefixes: Functions ON_WM; Messages
WM_; Objects IDC_; Dialog Boxes IDD_
Object Oriented Programming
 OOP -
a programming technique that relies
on reusable software components that can
be applied to different types of problems
and applications. The programmer makes
the machine work in terms of concepts
closer to the user’s every day world.
 Principle
unit - An Object
Objects
 Separate
Components :
• Say Hello
• Exit
• Each had its own Caption & ID (IDC_…)
 Belonged
to the CHelloDlg Class
 An instance of CHelloDlg Class
 Created within the Visual Environment
Objects
 Private
data ( )
 Procedures that could access that data
• written in the CHelloDlg Class
• Member functions:
– OnSayhelloButton( )
– OnExitButton( )
 A program
of objects
can be thought of as a collection
Objects
 Messages
• BN_CLICKED
• BN_DOUBLECLICKED
 Respond
to predefined external stimuli
• Mouse Click
 Communication
• Represent the events to which an object can
respond
Structure of a Function
void reference,
Class name ::,
function name, ( ), {,
Comments, Attached
Code, Comments, }
Classes
 Case
sensitivity
 Properties Tables, P. 43
 Group Box, P. 52, Properties Table, P. 59
 Variables - storage containers:
• Memory Location
• Amount of Memory
• m_TestEdit = “ ”;
Num1
20
FFFA, 2 bytes
Variables - Changeable Quantities
 An
actual representation of a data type
• Value
• CSTRING
• BOOL
 Other
Integer
Character
Double, Float
Functions:
• MessageBox(“ ”);
• UpdateData(False); - updates screen w/new
values
New Windows Controls
Edit Box, Check Box, Static, Group
Box
Right Click on on your mouse for
property Settings
Use P. 59 for your object’s properties
Introduction of Keyboard Shortcuts
Windows Programs
 Calculator
 Paint
 Invoked
via entries in the the Edit
Box ab| (Calculator or Paint)
Events
 Linked
with messages
 After communication between
objects, some action takes place.
This action has the code in it to
perform a set task - initialize a
dialog box, paint, execute a system
command.
The End
 “That’s
all folks.”
Download