Click to See Complete Forum and Search --> : Read/write CTreeView to a file?


E.Schultz
October 15th, 1999, 02:23 PM
For school I need to do a project, and my end goal is to make an email client. (Found a usefull class on this site) anyways. My current problem that I am having so to say, is how can I read/write the CTreeView control to a file?

Or how would I go abouts doing it? I have been trying to think of various ways of going about it but I am stumped. I found something along this lines at

http://www.codeguru.com/treeview/serialize_to_text.shtml

But there is no sample code on how to really use it. Any help is greatly apprciated.

Thanks in advance..

-E.Schultz

aqiruse
October 15th, 1999, 04:23 PM
I have not tested the code from the serialize article, but all you should need to do is insert it then call it from where you wish. for ex, if you want to read/write on InitialUpdateFrame (using a splitter Wnd w/ a treeview) then call Serialize passing it the CArchive paramter it requires. Personally though i would write a new function to call. I would pass it two parameters. One for the file name, the other to tell it to read, write or append the file. Then I would use the GetParent, and ItemHasChildren functions to move through the tree. As I step through the tree, i would call GetItemText to get the text and then use the write, read , append functions which could be doen using CFile, CStdioFile or CArchive.

You may want to try setting CArchive ar(file, mode, buffersize, buffer); and then passing it to the Serialize function for the article by calling Serialize(&ar); to see if that works alright for you.