Presentation is loading. Please wait.

Presentation is loading. Please wait.

MFC Document/View programs

Similar presentations


Presentation on theme: "MFC Document/View programs"— Presentation transcript:

1 MFC Document/View programs

2 Win32APi vs DocView Win32API Data & display are interrelated
Program "knows" about the data Data elements can be "inside" the window class, but unrelated to window itself i.e.; a window may "provide access to" multiple pieces of unrelated data WndProc must distinguish how to process each piece of data Data "value" is independent of how to display the "value" Often need different ways to "see" the data in different windows Sort, format, arrangement on-screen © DJ Foreman 12/28/2018

3 Doc/View Concepts CDocument (class)
Holds the data Manages actions upon the data CView (class) defines the layout & possible user interactions Manages the display of the data Manages user interactions (NOT changes to the data itself!!!), such as select, zoom, copy, move, etc. Still need to create CFrameWnd and CWinApp classes Minimal code required for them © DJ Foreman 12/28/2018

4 Documents Any kind of data (text, graphics, whatever) 2 kinds of apps:
Single Document Interface (SDI) Multiple Document Interface (MDI) more than 1 doc/window is a possible & likely scenario you will see these abbrev's in function names, #defines, etc.) © DJ Foreman 12/28/2018

5 Programming Approach Similar to Win32API
DocView achieves separation of data & rendering Create a Frame Window which displays the view Multiple views possible for same data A View only contains 1 document © DJ Foreman 12/28/2018

6 Views Document Frame Window
Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal Four score Created equal © DJ Foreman 12/28/2018

7 Coordinates documents, views, and frame windows
MFC Template Classes Coordinates documents, views, and frame windows Application object creates a template Template coordinates display of the data in a view in a frame window CWinApp object is used to create a Document Template The Document Template creates CDocument object CFrameWnd object CFrameWnd object creates a CView object CView object displays the document data 12/28/2018

8 Template/ Document/View/Window
Application Object Doc Template Doc Object Frame Window View View © DJ Foreman 12/28/2018

9 Object creation Created at runtime Dynamic creation macros
Minimum classes needed: CFrameWnd Cdocument Cview CWinApp Usually in separate .h & .cpp files AppWizard does most of the initialization for you 12/28/2018


Download ppt "MFC Document/View programs"

Similar presentations


Ads by Google