Click here to Skip to main content
13,550,059 members
Click here to Skip to main content
Add your own
alternative version


38 bookmarked
Posted 21 Jun 2001

Restore Class View Add-In

, 21 Jun 2001
Rate this:
Please Sign up or sign in to vote.
An add-in to restore class view information for a workspace.
<!-- Download Links --> <!-- Article image -->

Sample Image - classview.jpg


While working on a fairly large MFC project with a large number of classes, I started using the folders feature in the ClassView tab available in DevStudio to group classes in folders. This is a very good feature in DevStudio which makes navigating through all the classes very easy. Unfortunately, from time to time, ClassView would 'forget' which classes it had put in what folders and all my folders would end up empty or no folders altogether! This got really annoying after the second time I had re-arranged my classes. I had to look for a solution!


After a bit of detective work, I found out that the class view information was stored in the xxx.opt (where xxx - is the workspace name). Before I go on, I must stress that the solution employs undocumented techniques, so please don't hold me responsible for DevStudio crashing and/or your ClassView not appearing properly. So, how did I know that the class view information is stored in the .opt file? The .opt file is a Structured Storage File. That means, you can open the file with the DocFile Viewer (\Common\Tools\dfview.exe). Go ahead give it a try! Under the root Storage folder are a bunch of interesting streams. Ever wonder how your debugger remembers what variables you had in the watch window in your previous debugging session? Or DevStudio remembered the number of breakpoints set from session to session? Have a look at the Debugger stream by double clicking on the stream name. All streams have data and obviously the storage format is undocumented. The stream I was interested in is called the ClassView Window. While I don't know what else is stored (probably only the Class View information) in the stream, I was convinced that buried somewhere in the stream data was the ClassView information. To confirm my suspicion I wrote a little program to copy the ClassView Window stream from an old .opt file into the one that DevStudio uses when a workspace is opened. The code (see snippet below) is pretty simple. First I delete the stream from the destination file (the .opt file that DevStudio reads from when opening a workspace) and then copy the one from the source into the destination and then re-open the workspace and lo and behold my ClassView as it was in my old file re-appeared!

// spDestinationStorage and spSourceStorage are IStorage pointers opened earlier.
// snippet does not include error handling.
CComBSTR strClassViewWindow("ClassView Window");
// Delete the stream 
hr = spDestinationStorage->DestroyElement(strClassViewWindow); 
// Copy from the source to the destination 
hr = spSourceStorage->MoveElementTo(strClassViewWindow,spDestinationStorage,strClassViewWindow,

Whilst the app worked perfectly, everytime I wanted to restore my ClassView i'd have to close the workspace, start the app, enter two files (the old opt file that had the ClassView just as I wanted it and the new one), restore the classview and re-open the workspace. Again, this became quite frustrating after using it twice. So I decided to convert the application into an add-in. The add-in is generated using and Nick Hodapp's excellent add-in appwizard. The add-in also uses some of his undocumented 'stupid' tricks as he calls them. I am not going to go into the details of explaining how add-ins can be written since there is extensive documentation in the MSDN.


Using the add-in is pretty simple. First and foremost, install the add-in. See this page for installation instructions if you don't already know how to install add-ins. After installing it, the add-in is now ready for use. Invoking the Add-In will present you with a dialog as shown below.

Add In Screen Shot

You have a choice of saving your current Class layout or restoring it from a previously saved layout. Obviously the first time you'll be saving the layout to a .clv file (you can specify your own extensions if you really want). Saving first saves your workspace, this forces DevStudio to update the .opt file and then the add-in copies the ClassView layout information into the specified file. When DevStudio craps your ClassView layout, invoke the add-in and browse to your saved .clv file (you can even drag and drop a file from explorer into the edit control). Clicking restore will, close the workspace, restore the Class View information and re-open the workspace. Obviously you'll have to update your 'old' .clv file from time to time when you add new classes or change the layout. The add-in remembers the old .clv file used the next time you invoke it for a particular workspace. I could extend the add-in to automatically save ClassView information every time the user closes the workspace (at least provide such an option) but since I am hard pressed for time, either one of the readers will be kind enough to do it, or just wait until I get the time. Until then, I hope some people file this useful - I know I have. Use with caution, please don't blame me, if you restore your big projects' ClassView with some other projects' ClassView.

I haven't tested this thoroughly i.e. on all kinds of configurations. I am pretty confident it'll work on Windows 95, 98, Me, NT, 2000, XP etc.. with DevStudio 6.0. I haven't tried this with DevStudio 5.0.

Thanks to

Oh, by the way check out this other add-in i've written.

PS: I hope I don't get into too much trouble with you know who, I really needed my ClassView to work all the time! ;) If you like it drop me a line.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Jignesh Patel
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

Generalthank you very much Pin
lao10004-Aug-06 19:05
memberlao10004-Aug-06 19:05 
GeneralThank you! Pin
dswigger12-May-04 6:51
memberdswigger12-May-04 6:51 
GeneralExcelent Pin
Ilan Shapira24-Mar-04 7:42
memberIlan Shapira24-Mar-04 7:42 
GeneralA small remark Pin
YaronNir15-Dec-03 2:43
memberYaronNir15-Dec-03 2:43 
GeneralYou are the best!!!!!! Pin
Ibiel28-May-03 17:46
memberIbiel28-May-03 17:46 
GeneralRe: You are the best!!!!!! Pin
Xib-X3-Nov-05 8:50
memberXib-X3-Nov-05 8:50 
GeneralA bug , may be! Pin
bhrar5-Apr-03 16:27
memberbhrar5-Apr-03 16:27 
GeneralExcellent!!! I have just a little improvement for using with VSS… Pin
mireks23-Jan-03 2:16
membermireks23-Jan-03 2:16 
GeneralVery good tool, but I found a bug: Pin
C++ Hacker11-Oct-02 1:10
memberC++ Hacker11-Oct-02 1:10 
GeneralRe: Very good tool, but I found a bug: Pin
Jignesh I. Patel11-Oct-02 3:53
memberJignesh I. Patel11-Oct-02 3:53 
Generalsimple & very useful Pin
TomM26-Mar-02 10:20
memberTomM26-Mar-02 10:20 
QuestionVS.NET Support? Pin
Uwe Keim12-Mar-02 5:34
memberUwe Keim12-Mar-02 5:34 
AnswerRe: VS.NET Support? Pin
Jignesh Patel12-Mar-02 8:09
memberJignesh Patel12-Mar-02 8:09 
GeneralStoring CLV as a text-file Pin
Uwe Keim27-Nov-01 21:40
memberUwe Keim27-Nov-01 21:40 
GeneralRe: Storing CLV as a text-file Pin
Jignesh I. Patel28-Nov-01 7:53
memberJignesh I. Patel28-Nov-01 7:53 
GeneralRe: Storing CLV as a text-file Pin
Paolo Messina3-Feb-02 12:00
memberPaolo Messina3-Feb-02 12:00 
GeneralRe: Storing CLV as a text-file Pin
Uwe Keim6-Feb-02 5:04
memberUwe Keim6-Feb-02 5:04 
GeneralThank You Pin
Chris Bruce2-Oct-01 11:58
memberChris Bruce2-Oct-01 11:58 
GeneralRestore Class View saved my bacon Pin
sysop@HAL9K.com28-Aug-01 2:44
membersysop@HAL9K.com28-Aug-01 2:44 
GeneralThanks Pin
John M. Drescher22-Aug-01 5:41
memberJohn M. Drescher22-Aug-01 5:41 
GeneralSuperb! :) Pin
anonymous21-Aug-01 6:35
memberanonymous21-Aug-01 6:35 
GeneralVery good! Very helpful for me! Pin
norther9912-Jul-01 2:28
membernorther9912-Jul-01 2:28 
GeneralThere is a workaround Pin
Jörgen Sigvardsson27-Jun-01 9:41
memberJörgen Sigvardsson27-Jun-01 9:41 
GeneralFolders !! Pin
David Gallagher26-Jun-01 5:56
memberDavid Gallagher26-Jun-01 5:56 
I didn't know about folders, thanks for the infoSmile | :)
Shows that you sometimes should read the manual!
GeneralExcellent Work Pin
Ian Hart23-Jun-01 19:40
memberIan Hart23-Jun-01 19:40 

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
Web03 | 2.8.180515.1 | Last Updated 22 Jun 2001
Article Copyright 2001 by Jignesh Patel
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid