Part II Document/View Architecture. Chapter 9 Documents, Views, and the Single Document Interface.

Slides:



Advertisements
Similar presentations
CPIT 102 CPIT 102 CHAPTER 1 COLLABORATING on DOCUMENTS.
Advertisements

MFC Workshop: Intro to the Document/View Architecture.
Foundation Level Course
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Introduction to MFC. Motivation Abstract the Windows API Provides additional GUI options Insert Open Inventor into existing MFC application Document /
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Introduction to Microsoft Windows MFC Programming: the Application/Window Approach Lecture 4.
This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation. All.
XP Using Common Features of Microsoft Office Tutorial 1.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Using Microsoft Outlook: Basics. Objectives Guided Tour of Outlook –Identification –Views Basics –Contacts –Folders –Web Access Q&A.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Microsoft Office Illustrated Fundamentals Unit B: Understanding File Management.
1 ADVANCED MICROSOFT WORD Lesson 15 – Creating Forms and Working with Web Documents Microsoft Office 2003: Advanced.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
CIS—100 Chapter 13--Outlook 1. Using Your Mail to Take Action 2 Outlooks allows you to take several actions to organize, categorize, and respond to your.
I Can… Define basic file management and related terms Identify levels of a file system Identify and explain ways to view files in Windows OS Explain the.
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.
CST-092 © Delta College CST FacultyIntroduction to Windows Operating System Lecture 2.
XP New Perspectives on Introducing Microsoft Office XP Tutorial 1 1 Introducing Microsoft Office XP Tutorial 1.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
IV.Creating & Editing a Video/Movie. Editing Techniques To open a project On the File menu, click Open Project. In the File name box, locate the saved.
Microsoft Office 2003 Illustrated Brief Document Creating a.
Building an MFC Application Using the Wizard. Terms Solution – A container for related projects – An executable or DLL – May be constructed from multiple.
Visual C++ Lecture 11 Friday, 29 Aug Windows Graphic User Interface l Event driven programming environment l Windows graphic libraries (X11 on Unix,
1 2 Lab 2: Organizing Your Work. 2 Competencies 3 After completing this lab, you will know how to: 1. Use Explorer to manage files. 2. Copy files. 3.
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.
XP New Perspectives on Integrating Microsoft Office XP Tutorial 2 1 Integrating Microsoft Office XP Tutorial 2 – Integrating Word, Excel, and Access.
1 Kyung Hee University Diagram Editor : Implementation View Spring 2001.
MFC Windows Programming: Document/View Approach More detailed notes at: 360/notes-html/class15.htm.
Productivity Programs Common Features and Commands.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
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.
Create a Simple MFC Application Automatically How to use the application wizard.
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.
Key Applications Module Lesson 21 — Access Essentials
Fourth R Inc. 1 WELCOME TO MICROSOFT OFFICE OUTLOOK 2003 INTRODUCTORY COURSE.
BZUPAGES.COM Visual Programming Lecture – 6- 7 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Chapter Two Creating a First Project in Visual Basic.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
The Advantage Series © 2004 The McGraw-Hill Companies, Inc. All rights reserved CHAPTER 1 Integrating Office Word and Office Excel.
Unit 5, Lesson 1 Working with Databases. Objectives Identify the parts of the Access screen. Identify the parts of the Access screen. Understand the purpose.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 7 – Creating and Using Templates in a Web.
Chapter2: Drawing a Window. Review: Introducing MFC.
Chapter 8 Dialog Boxes and Property Sheet
Microsoft Office 2013 Try It! Chapter 4 Storing Data in Access.
Overview of Previous Lesson(s) Over View 3 Program.
Chapter 6: FILE I/O and Serialize CFile class. FILE I/O Serialization and the CArchive Class.
1 Visual C Multiple Document Interface Application.
Overview of Previous Lesson(s) Over View  Windows Programming  WinMain()  Where execution of the program begins and basic program initialization is.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Fundamentals of Windows Mouse n 4 Basic Operations: –Pointing –Clicking –Double Clicking –Dragging.
Chapter 14 Windows Programming with the Microsoft Foundation Classes
Excel Tutorial 8 Developing an Excel Application
MULTIPLE DOCUMENTS AND MULTIPLE VIEWS Prosise - Chapter 11
Document/View Architecture
Message Handling in MFC
Microsoft Foundation Classes MFC
Steps to Build Frame Window Recipe Application
Practical Office 2007 Chapter 10
Module 1: Getting Started with Windows 95
MFC Document/View programs
WORKING WITH SHARED DOCUMENTS
Microsoft Office Illustrated Fundamentals
Chapter 4 Enhancing the Graphical User Interface
Chapter 12 Windows Programming with the Microsoft Foundation Classes
Chapter 4 Enhancing the Graphical User Interface
Presentation transcript:

Part II Document/View Architecture

Chapter 9 Documents, Views, and the Single Document Interface

3 Document/View Fundamentals Single document/view architecture

4 Document/View Fundamentals Application object: –Provides message loop and send messages to the frame window and the view Frame Window object: –Shows menu, toolbar and status bar View object: –Displays(renders) data –Translates mouse and keyboard input into commands to operates the data Document object: –Stores data –Manipulates data

5 SDI and MDI Single Document Interface vs. Multiple Document Interface –Different in the number of documents to open at once

6 Document Template –Identifies the document class, view class and frame window class. –Stores the resource ID for menu, tool bar and other resources for the frame window MFC Class Hierarchy SDI MDI

7 Document Template Initial Setting for an application: InitInstance() BOOL CExFileApp::InitInstance() {... CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CExFileDoc), RUNTIME_CLASS(CMainFrame), RUNTIME_CLASS(CExFileView)); AddDocTemplate(pDocTemplate);... }

8 Single Document Interface Example (1/4) New Project: –Single Document + Document/View Support

9 Single Document Interface Example (2/4) Change OnDraw function of View Class void CExFileView::OnDraw(CDC* pDC) { CExFileDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); pDC->SetMapMode(MM_LOMETRIC); pDC->Ellipse(100, -100, 600, -600); }

10 Single Document Interface Example (3/4) Result

11 Single Document Interface Example (4/4) 실행 결과 (cont'd)

12 SDI Application A Simple Structure CWinApp CSingleDocTemplateCDocumentCView CFrameWnd

13 SDI Application A structure with two views CWinApp CSingleDocTemplateCDocument CView 1 CFrameWnd CView 2

SDI Application How to refer each other Document Object View Object Frame Window Object GetFirstViewPosition & GetNextView GetDocument GetActiveDocumentGetActiveView Application Object AfxGetMainWnd AfxGetApp m_pMainWnd GetParentFrame Document Template GetFirstDocTemplatePosition & GetNextDocTemplate GetDocTemplate GetFirstDocPosition & GetNextDoc

15 SDI Application Key Functions –CWinApp* AfxGetApp ( ); Return the pointer to the application object –CWnd* AfxGetMainWnd ( ); Return the pointer to the frame window object –CView* CFrameWnd::GetActiveView ( ); Return the pointer to the view object –CDocument* CView::GetDocument ( ); Return the pointer to the document object –POSITION CDocument::GetFirstViewPosition ( ); CView* CDocument::GetNextView (POSITION& rPosition); Access to the view object(s) Document Object m_viewList View #1View #2View #3 NULL

Document/View in detail Create a new application as a SDI –Edit the document template string

17 Document/View in detail Document template string ExSDI\n\nExSDI\nExSDI 파일 (*.sdi)\n.sdi\nExSDI.Document ① ② ③ ④ ⑤ ⑥ \nExSDI Document ⑦ No.Description 1Title shown on the title bar 2A initial name of the document. If skipped, “untitled” will be given 3Brief name of the document 4Brief name of the document in file dialog box 5Default extension name 6Document ID used in the windows registry 7Document name used in the windows registry

Document Class Key CDocument operations FunctionDescription GetFirstViewPositionReturns a POSITION value that can be passed to GetNextView to begin en umerating the views associated with this document GetNextViewReturns a CView pointer to the next view in the list of views associated with this document GetPathNameRetrieves the document's file name and path—for example, "C:\Documents \Personal\MyFile.doc"; returns an empty string if the document hasn't been named GetTitleRetrieves the document's title—for example, "MyFile"; returns an empty stri ng if the document hasn't been named IsModifiedReturns a nonzero value if the document contains unsaved data or 0 if it do esn't SetModifiedFlagSets or clears the document's modified flag, which indicates whether the do cument contains unsaved data UpdateAllViewsUpdates all views associated with the document by calling each view's OnUpdate function

19 Document Class Key CDocument Overrides FunctionDescription OnNewDocumentCalled by the framework when a new document is created. Over ride to apply specific initializations to the document object each ti me a new document is created. OnOpenDocumentCalled by the framework when a document is loaded from disk. Override to apply specific initializations to the document object e ach time a document is loaded. DeleteContentsCalled by the framework to delete the document's contents. Ove rride to free memory and other resources allocated to the docum ent before it is closed. SerializeCalled by the framework to serialize the document to or from dis k. Override to provide document-specific serialization code so th at documents can be loaded and saved.

20 Document class What happens when: –[FILE]->[New] –[FILE]->[Open...] –[FILE]->[Save] or [File]->[Save as...] DeleteContents()  OnNewDocument() DeleteContents()  Serialize()  OnOpenDocument() Serialize()

21 View Class Key CView Overrides FunctionDescription OnDrawCalled to draw the document's data. Override to paint views of a document. OnInitialUpdateCalled when a view is first attached to a document. Override to initialize the view object each time a document is created or loaded. OnUpdateCalled when the document's data has changed and the view nee ds to be updated. Override to implement "smart" update behavior that redraws only the part of the view that needs redrawing rather than the entire view.

Coding practice Using Document/View architecture, make an application which draws circles and save/load it Things to change CView:: OnDraw() CDocument:: OnNewDocument() Serialize() Things to change CView:: OnDraw() CDocument:: OnNewDocument() Serialize()

Splitter Window

24 Splitter Window Dynamic Splitter window –Showing Multiple views by using a Single View Class –In total, 4 views (pane) are supported

25 Dynamic Splitter Window Application setting for the splitter window

Key Member Functions Find out the location of the current pane: 1.Get the current row and col number 2.Implement each pane according to the location bool CSpliterWnd::IsChildPane ( CWnd * wnd, int * row, int * col ) if (col == 0) { … } Else if (col == 1) { …, } if (col == 0) { … } Else if (col == 1) { …, }

27 Static Splitter Window –Each pane can use different view class 서로 다른 뷰 클 –256 panes can be created in maximum

28 Static Splitter Window Implementation: BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext) { m_wndSplitter.CreateStatic(this, 2, 1); m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CFirstView), CSize(300, 200), pContext); m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CSecondView), CSize(300, 200), pContext); return TRUE; }

Various View Classes

View Classes There are many view classes

How to select? At application wizard:

Example: FormView A View Class similar to a Dialog Box

Conclusion: we have learned.. MFC Structures Draw using MFC Mouse and Keyboard CList Timer Menu and tool bar FILE Input/Output Controls Dialog Box Document/View Architecture (SDI and Splitter WIndow)

Thank you for your effort Final Exam: June 21 st (Thursday) Final Grade will be available from: June 21 st 18:00 (Our Homepage) Any questions about grade? Visit my office June 22 nd (14:00~17:00) June 25 th (14:00~17:00)

Programming Assignment #5 Don’t need to submit Try to make it during vacation for reviewing everything we have learned