Click here to Skip to main content
13,291,748 members (59,306 online)
Click here to Skip to main content
Add your own
alternative version


18 bookmarked
Posted 8 Aug 2005

A WTL DocView framework

, 10 Jan 2006
Rate this:
Please Sign up or sign in to vote.
Implemetation of a simple DocView framework like MFC.

Sample Image - DocView_framework.jpg


This article explains the implementation of a simple Doc View framework in a WTL (version 7.5) MDI application. The sample project included with this article is a wizard-generated MDI application enhanced with my framework classes. I enhanced code from Gabriel Kniznik with a little bit closer to the MFC DocView approach, and there exists only one kind of document template - MDI Document template. This framework was written in a week, so I apologize for mistakes and unfinished solutions :).

In this article is also participating Rodrigo Pinho Pereira de Souza, who made great enhancements to this framework (see the History section).


In the demo project, you can see how to integrate the framework to your own project. You have to make changes to CMainFrame, CChildFrame, CYourView, and create a new class CYourDoc. Do not forget to change the IDR_CHILDFRAME string to the form for MFC -> \nDocument\nDVF\n\n\nDVFSimple.Document\nDVF Document.

Below is a simplified class diagram of the framework:

Framework class diagram - simplified


  • 11 Jan 2006
  • Changes made by Rodrigo Pinho Pereira de Souza:

    • Automatic handling of ID_FILE_NEW
    • Automatic handling of ID_FILE_SAVE
    • Automatic handling of ID_FILE_SAVEAS
    • Implemented Serialization mechanism
    • Changed all declarations of std::vector to the ATL CSimpleArray
    • Created a CFormView class

    Demo application split to VC++ 6.0 and VS.NET 2003.

  • 8 Aug 2005 - Initial version.

Terms of Use

The sample application available with this article is free for any purpose. THIS SOFTWARE IS DISTRIBUTED AS-IS, WITHOUT WARRANTIES OF ANY KIND.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Jozef Bozek
CEO bring-it-together s.r.o.
Slovakia Slovakia
Jozef Božek is currently a software engineer at bring-it-together s.r.o. in area of large scale infomation systems and mobile applications development.
He has been developing in C++ nearly full time since 2000, in Java since 2004 and in Objective-C since 2009. He is programming using Java EE SDK, iOS SDK, COM/DCOM, MFC, ATL, STL and so on Smile | :)

You may also be interested in...

Comments and Discussions

QuestionRelease Build Pin
jsvanwyk8-Apr-13 6:56
memberjsvanwyk8-Apr-13 6:56 
GeneralCString memory exceptions Pin
Jerker Bäck6-Oct-06 18:04
memberJerker Bäck6-Oct-06 18:04 
Sorry, I have to complain a little - hope you don't mind
My env:
Windows 2003 R2, VS 2003 using CRT and ATL3 from Win DDK 2003 SP1 - for "system DLLs"
(means I'm using ATL3 - not ATL7) and WTL8

First, I had to do a rather extensive clean up to get rid of common warnings - since they are generated in the headers - they become massive. Please do a UNICODE compile with warning level 4 and 64bit portabilty check using at least a 7.1 version compiler. You'll see what I mean.

Second, I got a memory exception right away in both debug and release build.
HEAP[DVF.exe]: Heap block at 003D36A0 modified at 003D36EA past requested size of 42<br />
Unhandled exception at 0x7c822583 in DVF.exe: User breakpoint.

This is due to CString class (that will be the WTL implementation) and I guess the use of Ctring for buffer manipulation. My system DEP: /NoExecute=OptIn which is standard. I tried to fix this but soon found out that it's not an easy thing.

My comment:
I think it's a pity you choosed to use CString in your classes. That only makes them less useful in the general case with ATL. For me, CString is OK in MFC but feels odd in ATL - a matter of taste of course - but if you want people to enjoy your work, stick to ATL standard.

Anyway thanks for this since WTL really suffer the lack of a document implementation and a design layout for connection between data and view.
GeneralRe: CString memory exceptions Pin
Jerker Bäck8-Oct-06 1:42
memberJerker Bäck8-Oct-06 1:42 
GeneralRe: CString memory exceptions Pin
rajas12-Jul-08 20:28
memberrajas12-Jul-08 20:28 
QuestionWhat about SaveDocument ? Pin
Rodrigo Pinho Pereira de Souza2-Nov-05 15:38
memberRodrigo Pinho Pereira de Souza2-Nov-05 15:38 
AnswerRe: What about SaveDocument ? Pin
Jozef Božek3-Nov-05 2:23
memberJozef Božek3-Nov-05 2:23 
GeneralRe: What about SaveDocument ? Pin
Rodrigo Pinho Pereira de Souza29-Nov-05 1:33
memberRodrigo Pinho Pereira de Souza29-Nov-05 1:33 
GeneralRe: What about SaveDocument ? Pin
Jozef Božek29-Nov-05 1:55
memberJozef Božek29-Nov-05 1:55 
GeneralRe: What about SaveDocument ? Pin
Rodrigo Pinho Pereira de Souza5-Dec-05 2:38
memberRodrigo Pinho Pereira de Souza5-Dec-05 2:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171207.1 | Last Updated 11 Jan 2006
Article Copyright 2005 by Jozef Bozek
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid