Document/View Architecture

Slides:



Advertisements
Similar presentations
Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
Advertisements

MFC Workshop: Intro to the Document/View Architecture.
CSE 1302 Lecture 8 Inheritance Richard Gesick Figures from Deitel, “Visual C#”, Pearson.
(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
Advanced Object-Oriented Programming Features
Hands-On Microsoft Windows Server 2003 Administration Chapter 5 Administering File Resources.
ASP.NET Programming with C# and SQL Server First Edition
Chapter 13: Object-Oriented Programming
INTRODUCTION TO VC++ As the Microsoft Windows 3.X and then 5.5 operating system was becoming popular, many programmers were interested in creating graphical.
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
Chapter 8 More Object Concepts
An Object-Oriented Approach to Programming Logic and Design
Visual C++ Lecture 11 Friday, 29 Aug Windows Graphic User Interface l Event driven programming environment l Windows graphic libraries (X11 on Unix,
C++ MFCs CS 123/CS 231. MFC: Writing Applications for Windows zClasses in MFC make up an application framework zFramework defines the skeleton of an application.
BZUPAGES.COM Visual Programming Lecture – 5 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
ICONICS ActiveX ToolWorX V 6.1.
Programming Pillars Introduction to Object- Oriented Programming.
MFC Windows Programming: Document/View Approach More detailed notes at: 360/notes-html/class15.htm.
Overview of Previous Lesson(s) Over View  Microsoft Foundation Classes (MFC)  A set of predefined classes upon which Windows programming with Visual.
OBJECTIVE  After completing this Lab, students will upgrade their knowledge in the field of VC++.  Students will also get the clear view about the concepts.
Microsoft Foundation Classes. What is MFC? Set of C++ classes written by MS Simplifies writing complex programs Covers many areas: – GUI – I/O – O/S interfaces.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
Understanding Desktop Applications Lesson 5. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Windows Forms Applications Understand.
CITA 342 Section 1 Object Oriented Programming (OOP)
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
Chapter 8 Dialog Boxes and Property Sheet
Overview of Previous Lesson(s) Over View 3 Program.
Understanding Desktop Applications Lesson 5. Understanding Windows Forms Applications Windows Forms applications are smart client applications consisting.
Microsoft Foundation Classes
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Overview of Previous Lesson(s) Over View  Windows Programming  WinMain()  Where execution of the program begins and basic program initialization is.
Part II Document/View Architecture. Chapter 9 Documents, Views, and the Single Document Interface.
Java Programming Fifth Edition Chapter 9 Introduction to Inheritance.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 Event-Driven Programming and Basic GUI Objects.
School’s Name Teacher’s Name Date
Chapter 14 Windows Programming with the Microsoft Foundation Classes
Introduction to Windows Programming
MULTIPLE DOCUMENTS AND MULTIPLE VIEWS Prosise - Chapter 11
Multiple document interface (MDI)
SDI & MDI SDI -> Single Document Interface
Microsoft Foundation Classes MFC
Microsoft Office Access 2010 Lab 1
Java FX: Scene Builder.
Visual Basic 2010 How to Program
Programming Logic and Design Seventh Edition
Working in the Forms Developer Environment
Learning the Basics – Lesson 1
Program and Graphical User Interface Design
Instructor’s Guide to Teaching SolidWorks Software Lesson 1
Java Programming: From Problem Analysis to Program Design,
Working with Dialogs and Controls
Using GUI Objects and the Visual Studio IDE
Introduction to Windows Programming with Microsoft Framework Classes (MFC) Jim Fawcett Summer 2004 Syracuse University.
Understand Windows Forms Applications and Console-based Applications
Using Procedures and Exception Handling
Chap 7. Building Java Graphical User Interfaces
Program and Graphical User Interface Design
VISUAL BASIC.
Lecture 22 Inheritance Richard Gesick.
Creating a Windows Forms User Interface
MFC Document/View programs
Object-Oriented Programming: Inheritance and Polymorphism
Fundaments of Game Design
CIS16 Application Development and Programming using Visual Basic.net
How to organize and document your classes
CIS 199 Final Review.
Chapter 12 Windows Programming with the Microsoft Foundation Classes
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
Tutorial 10 Automating Tasks with Macros
Presentation transcript:

Document/View Architecture CITA 342 Section 5 Document/View Architecture

Documents and Views The MFC document/view architecture separates a program’s data from the way that data is displayed and accessed by users.

Documents and Views A program’s data (the document) is managed and stored by a class derived from the CDocument class. How a document-based program’s data is displayed to the user is controlled by one or more classes derived from the CView class.

Documents and Views

Documents and Views The following figure illustrates the concept of multiple CView classes that display and manipulate the data contained in a single CDocument class

Documents and Views

Document Interfaces The single document interface, or SDI, allows users to have only one document open at a time. The multiple document interface, or MDI, allows users to have multiple documents open at the same time. The Multiple top-level document interface, allows user to have multiple individual SDI instances as a single instance of an MDI Application.

SDI Example: Notepad

MDI Example: Word 97

Multiple Top-level Documents Interface Example: Word 2000+

CView You display a window created from a class derived from CView within a frame window. This means the CView window is a child of a frame window. The CView window completely covers the frame window’s client area, but does not cover visual interface elements such as the title bar or scroll bars.

Frame Window and View Window

CView Child Classes The classes that derive from CView are used for creating more specialized view windows:

CView Member Functions A view class is responsible for graphically displaying a document’s data and for handling the manipulation of that data according to user requests. The CView class contains various functions for displaying and manipulating data. The primary CView class member functions that you use to display and manipulate data are as follows: OnDraw() GetDocument() OnUpdate()

CView::GetDocument() The GetDocument() function returns a pointer to the document associated with a view. The GetDocument() function returns a pointer to the m_pDocument data member that you can use anywhere in the view class when you need to access the document’s data.

CView::OnUpdate() Each view class inherits an OnUpdate() function that is called each time the document class changes or whenever the document class executes an UpdateAllViews() function. The OnUpdate() function allows all of the view windows in an application to display the most current data.

CDocument::UpdateAllViews() The UpdateAllViews() function is a member function of CDocument and causes each view window’s OnUpdate() function to execute in order to allow each view to display the most recent data. Passing a single value of NULL to the UpdateAllViews() function informs the system that all views in the program should be updated. Note that you execute the UpdateAllViews() function from a derived CDocument class, not a derived CView class.

CDocument Once the MFC Application Wizard creates your derived document class, you may perform the following tasks: Create data members to temporarily hold the data for the current document. Override the CDocument class’s member functions to customize the creating, loading, and saving mechanisms of the document/view architecture. Override CDocument’s Serialize() member function in order to read the document’s data from and write the document’s data to a file.

CDocument Data Members You create data members in the CDocument class by adding declarations for each data member to the interface file, the same way you create data members in other classes. You can then initialize each data member in the class constructor and use appropriate set and get member functions to manipulate each data member. One of the main differences between CDocument and other types of classes is that you call the set and get member functions from the view class using the GetDocument() function.

CDocument Member Functions Although many of the CDocument member functions are called automatically by the MFC framework, you can override each of the functions to customize how your application creates, loads, and saves documents.

Common CDocument Member Functions

CDocument Member Functions The only functions for which the MFC Application Wizard automatically provides overridden implementations are the OnNewDocument() and Serialize() functions, because the OnNewDocument() function is one of the most commonly overridden functions and the Serialize() function is necessary for reading data from, and writing data to, files.

CDocument Member Functions When a user creates a new document in an SDI application, MFC reuses the same document object. Because the program reuses the same document object, the values contained in the document class’s data members will appear in the fields, unless you reinitialize the data members using the DeleteContents() function.

CDocument Member Functions The SetModifiedFlag() function is used by the MFC framework to determine if a document has been modified since the last time it was saved. When you change a document’s data, you pass to the SetModifiedFlag() function a value of TRUE to indicate that the document needs to be saved.