VC++ Programming UESTC Part MFoⅤ iew class Chapter 3 Getting Started with App Wizard ● Chapter4 Basic event Handling, Mapping Modes and a Scrolling View Chapter 5 The Graphics device Inter face, Colors and Fonts Chapter 6 The Modal Dialog and Windows Common Controls
VC++ Programming @ UESTC 1 Part II MFC View Class ⚫ Chapter 3 Getting Started with AppWizard ⚫ Chapter 4 Basic Event Handling, Mapping Modes and a Scrolling View ⚫ Chapter 5 The Graphics Device Interface, Colors and Fonts ⚫ Chapter 6 The Modal Dialog and Windows Common Controls
VC++ Programming@UESTC Part MFoⅤ iew class Chapter 7 The Modeless Dialog and Windows Common Dialogs ● Chapter8 Using ActiveX Controls o Chapter 9 Win32 Memory Management Chapter 10 Bitmaps Chapter 11 Windows Message Processing and Multithreaded Programming
VC++ Programming @ UESTC 2 Part II MFC View Class ⚫ Chapter 7 The Modeless Dialog and Windows Common Dialogs ⚫ Chapter 8 Using ActiveX Controls ⚫ Chapter 9 Win32 Memory Management ⚫ Chapter 10 Bitmaps ⚫ Chapter 11 Windows Message Processing and Multithreaded Programming
VC++ Programming UESTC Chapter 3 Getting Started with App wizard o This hands-on chapter shows you how to build a mfc library application working with only the view element o How to use Graphics Device Interface(GDI) How to use resource editor Debug target vs. Release Target Understand Diagnostic Macros o Understand the Precompiled Headers 3
VC++ Programming @ UESTC 3 Chapter 3 Getting Started with AppWizard ⚫ This hands-on chapter shows you how to build a MFC library application working with only the view element. ⚫ How to use Graphics Device Interface (GDI) ⚫ How to use Resource Editor ⚫ Debug Target vs. Release Target ⚫ Understand Diagnostic Macros ⚫ Understand the Precompiled Headers
VC++ Programming@UESTC Chapter 3 Getting Started with App wizard ●What' s a view? From a user 's standpoint a view is a window where the user can play with a mouse and keyboard; From a programmer's perspective, a view is a C++ object of a class derived from a cview class We'll make a single document application(sdi) to show the details
VC++ Programming @ UESTC 4 ⚫ What’s a View? From a user’s standpoint, a view is a window where the user can play with a mouse and keyboard; From a programmer’s perspective, a view is a C++ object of a class derived from a CView class. We’ll make a single document application (SDI) to show the details. Chapter 3 Getting Started with AppWizard
VC++ Programming UESTC Chapter 3 Getting Started with App wizard ● Project Type MFC AppWizard(exe) o Application Type Single document ● Files generated ex03aView. cpp and ex03aView h o Compile and link Test the application Browse the application Source browser
VC++ Programming @ UESTC 5 ⚫ Project Type MFC AppWizard (exe) ⚫ Application Type Single document ⚫ Files Generated ex03aView.cpp and ex03aView.h ⚫ Compile and link ⚫ Test the application ⚫ Browse the application Source Browser Chapter 3 Getting Started with AppWizard
VC++ Programming UESTC Chapter 3 Getting Started with App wizard o Simply drawing inside the view Window Window reaction mechanism Window Changes>Invalidate(>On DrawL o Use Class view to add the on draw function o Add codes inside On drawl to do something
VC++ Programming @ UESTC 6 ⚫ Simply Drawing inside the View Window Window Reaction Mechanism Window Changes → Invalidate() → OnDraw() ⚫ Use ClassView to add the OnDraw function ⚫ Add codes inside OnDraw() to do something Chapter 3 Getting Started with AppWizard
VC++ Programming UESTC Chapter 3 Getting Started with App wizard e Introduce the cdc class Windows communicate with the hardware indirect through an abstraction layer called"device context, which is a C++ object of class CDC For instance, you use CDC member function Textout( to write text on the view
VC++ Programming @ UESTC 7 ⚫ Introduce the CDC class Windows communicate with the hardware indirectly through an abstraction layer called “device context”, which is a C++ object of class CDC. For instance, you use CDC member function TextOut() to write text on the view. Chapter 3 Getting Started with AppWizard
VC++ Programming UESTC Chapter 3 Getting Started with App wizard Void CEx03aView: OnDraw(CDC* pDC i pDC->TextOut(o, 0, Hello, world! prints in default font, size, top left corner pDC->SelectStockObject(GRAY BRUSH) // selects a brush for the circle interior pDC->Ellipse( Crect(o, 20, 100, 120)) // draws a gray circle 100 units in diameter
VC++ Programming @ UESTC 8 Void CEx03aView::OnDraw(CDC* pDC) { pDC->TextOut(0, 0, "Hello, world!"); // prints in default font, size, top left corner pDC->SelectStockObject(GRAY_BRUSH); // selects a brush for the circle interior pDC->Ellipse(CRect(0, 20, 100, 120)); // draws a gray circle 100 units in diameter } Chapter 3 Getting Started with AppWizard
VC++ Programming UESTC Chapter 3 Getting Started with App wizard Contents of the Resource File( ex03arc Accelerator Dialog Icon Menu String Table Toolbar SIon
VC++ Programming @ UESTC 9 ⚫ Contents of the Resource File ( ex03a.rc) Accelerator Dialog Icon Menu String Table Toolbar Version Chapter 3 Getting Started with AppWizard
VC++ Programming UESTC Chapter 3 Getting Started with App wizard e Statements inside ex03arc to be reexamined # include“ afxres.h # include“ afree.rc contains MfC library resource common to all application # include“ resource.h contains special resource in this project 10
VC++ Programming @ UESTC 10 ⚫ Statements inside ex03a.rc to be reexamined #include “afxres.h” #include “afxrec.rc” ---contains MFC library resource common to all application #include “resource.h” --- contains special resource in this project Chapter 3 Getting Started with AppWizard