Intro To MFC What Is MFC?: Course Given at Stanford by Patrick Young
Intro To MFC What Is MFC?: Course Given at Stanford by Patrick Young
– application programmer controls when input and output • Means your program cannot block to wait for input (a la
can happen scanf or cin >> )
– only get input or send output via events
• GUI program model: the user is in control
Intro to MFC [Bono] 3 Intro to MFC [Bono] 4
1
GUI Libraries
Application Frameworks
• GUI programs involve a lot of code.
• But for many different applications much of the • Sometimes called software architectures
code is the same. • Reusable software for a particular domain of
• The common code is part of the library. E.g.: applications
– getting and dispatching events • Contrast with class library:
– telling you when user has resized windows, redisplayed
windows, etc. your code
Framework
– code for GUI components (e.g. look and feel of buttons,
menus, dialog boxes, etc.)
• But the library is upside-down: library code calls
your code. Library your code
– this is called an application framework
Intro to MFC [Bono] 7 Intro to MFC [Bono] 8
2
MFC vs. other libraries (cont.)
Empty MFC application • Advantages to application framework:
– less code for you to write:
• application gets built faster
• including less low-level tedious code
– more reuse of code between applications:
• we can focus on what’s different about our application
– uniform look and feel to applications produced
• less frustration for users/customers
• Disadvantages to application framework
– larger learning curve
– may produce a slower application
– may be harder to do exactly what you want
(only part of the window shown) • e.g., you want a different look-and feel, or you want a new
component
change change
Controller Make Make
deposit withdrawal
change
update update
View View change
Current balance update Plot of balance
update
Model view over last month
Bank
getData getData account
getData getData
model view controller
maintains displays current user manipulates
data state to user data in a model
or how view displayed
3
Document-view architecture SDI and MDI
• MFC has two flavors of applications
• In MFC version of Model-View-Controller:
– SDI = Single document interface
– Models are called Document objects
– MDI = Multiple document interface
– Views and Controllers are called View objects
• Examples
• Example: in Microsoft Word
– Word uses MDI
– Views: • can have multiple documents open simultaneously
• multiple windows open displaying same document
• may see multiple smaller windows in the larger window
• different types of views (normal, page layout, outline views)
– Notepad uses SDI
– Document: • only can have one document open at a time
• same data regardless of the view above
• view fills up frame of window
• contains text/formatting of Word document
• We’ll focus on SDI
Intro to MFC [Bono] 19 Intro to MFC [Bono] 20