CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 1999
    Posts
    1

    Read/write CTreeView to a file?

    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/ser..._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


  2. #2
    Join Date
    Jun 1999
    Location
    Earth
    Posts
    124

    Re: Read/write CTreeView to a file?

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured