an introduction to windows programming (mfc) ku-yaw chang [email protected] assistant...

29
An Introduction to An Introduction to Windows Programming Windows Programming (MFC) (MFC) Ku-Yaw Chang Ku-Yaw Chang [email protected] [email protected] Assistant Professor, Department of Assistant Professor, Department of Computer Science and Information Engineering Computer Science and Information Engineering Da-Yeh University Da-Yeh University

Upload: kyree-crookham

Post on 28-Mar-2015

225 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

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

Page 2: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

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

Page 3: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

332004/03/082004/03/08 Windows ProgrammingWindows Programming

Key ConceptsKey Concepts

InstanceInstance ProgramProgram ProcessProcess

Page 4: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

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

Page 5: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

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

Page 6: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

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

Page 7: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

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

Page 8: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

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

Page 9: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

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.

Page 10: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

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數列

Page 11: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

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

Page 12: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

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 …

Page 13: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

13132004/03/082004/03/08 Windows ProgrammingWindows Programming

CompilerCompiler

Page 14: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

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

Page 15: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

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

Page 16: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

16162004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample

Page 17: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

17172004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample

1

2

3

4

Page 18: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

18182004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample

Page 19: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

19192004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample

Page 20: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

20202004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample

Page 21: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

21212004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample

Page 22: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

22222004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample

Page 23: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

23232004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample

Page 24: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

24242004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample

Page 25: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

25252004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample

Page 26: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

26262004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample

Page 27: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

27272004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample

Page 28: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

28282004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample

Page 29: An Introduction to Windows Programming (MFC) Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering

29292004/03/082004/03/08 Windows ProgrammingWindows Programming

ExampleExample