An Introduction toAn Introduction toWindows ProgrammingWindows Programming
(MFC)(MFC)Ku-Yaw ChangKu-Yaw Chang
[email protected]@mail.dyu.edu.twAssistant Professor, Department of Assistant Professor, Department of
Computer Science and Information EngineeringComputer Science and Information EngineeringDa-Yeh UniversityDa-Yeh University
222004/03/082004/03/08 Windows ProgrammingWindows Programming
OutlineOutline
BackgroundBackground Key ConceptsKey Concepts MFCMFC PatternsPatterns
Model-View-ControllerModel-View-ControllerDocument-ViewDocument-View
First Windows programFirst Windows program CompilerCompiler ProjectProject WizardWizard ExampleExample
332004/03/082004/03/08 Windows ProgrammingWindows Programming
Key ConceptsKey Concepts
InstanceInstance ProgramProgram ProcessProcess
442004/03/082004/03/08 Windows ProgrammingWindows Programming
Key ConceptsKey Concepts
A program consists ofA program consists of Algorithm + DataAlgorithm + Data Dialog component + Computation componentDialog component + Computation component
552004/03/082004/03/08 Windows ProgrammingWindows Programming
Key ConceptsKey Concepts
A Windows ProgramA Windows Program ResourcesResources
Dialog boxesDialog boxes
MenusMenus
Device Context (DC)Device Context (DC)
EventsEventsKeyboardKeyboard
MouseMouse
TimerTimer Call-back functionCall-back function
662004/03/082004/03/08 Windows ProgrammingWindows Programming
MFCMFC
Microsoft Foundation ClassMicrosoft Foundation Class C++ class libraryC++ class library Framework for Windows programmingFramework for Windows programming
772004/03/082004/03/08 Windows ProgrammingWindows Programming
PatternsPatterns
Each pattern describes Each pattern describes a problema problem which which occurs over and over again in our occurs over and over again in our environment, and then describes the core environment, and then describes the core of of the solutionthe solution to that problem, in such a to that problem, in such a way that you can use this solution a million way that you can use this solution a million times over, without ever doing it the same times over, without ever doing it the same way twice.way twice. Christopher AlexanderChristopher Alexander
882004/03/082004/03/08 Windows ProgrammingWindows Programming
Interactive SystemInteractive System
A high degree of user interactionA high degree of user interaction
Graphical user interfacesGraphical user interfaces
ChallengesChallenges Keep the functional core independent of the Keep the functional core independent of the
user interfaceuser interface
992004/03/082004/03/08 Windows ProgrammingWindows Programming
Model-View-Controller (MVC)Model-View-Controller (MVC)
Dividing an interactive application into Dividing an interactive application into three componentsthree components Model: contain core functionality and dataModel: contain core functionality and data View: display informationView: display information Controller: handle user inputController: handle user input
Views and controllers comprise the user Views and controllers comprise the user interface.interface.
10102004/03/082004/03/08 Windows ProgrammingWindows Programming
Model-View-Controller (MVC)Model-View-Controller (MVC)
0%
10%
20%
30%
40%
50%
Black Red Blue Green Others
1數列
Black
Red
Blue
Green
Others
0%
10%
20%
30%
40%
50%
Black Red Blue Green Others
1數列
11112004/03/082004/03/08 Windows ProgrammingWindows Programming
Document-ViewDocument-View
In several GUI platforms, window display In several GUI platforms, window display and event handling are closely interwoven.and event handling are closely interwoven.
A variant of MVCA variant of MVC Relaxing the separation of view and controllerRelaxing the separation of view and controller
Supported by MFCSupported by MFC CDocumentCDocument CViewCView
12122004/03/082004/03/08 Windows ProgrammingWindows Programming
CompilerCompiler
Microsoft Visual Studio .Net 2002 Microsoft Visual Studio .Net 2002 中文版中文版 Visual Studio 6.0 … Visual Studio 6.0 …
13132004/03/082004/03/08 Windows ProgrammingWindows Programming
CompilerCompiler
14142004/03/082004/03/08 Windows ProgrammingWindows Programming
ProjectProject
A moduleA module A basic unit (logical coherence)A basic unit (logical coherence) *.c/*.h or *.cpp/*.h*.c/*.h or *.cpp/*.h
A projectA project A program A program Consisting of many modulesConsisting of many modules Adding/removing modulesAdding/removing modules
15152004/03/082004/03/08 Windows ProgrammingWindows Programming
WizardWizard
Help building an application by asking Help building an application by asking questionsquestions Step by stepStep by step Available default settingsAvailable default settings
16162004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample
17172004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample
1
2
3
4
18182004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample
19192004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample
20202004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample
21212004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample
22222004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample
23232004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample
24242004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample
25252004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample
26262004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample
27272004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample
28282004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample
29292004/03/082004/03/08 Windows ProgrammingWindows Programming
ExampleExample