How to save the structure of a tree view?
-
Hi, I am nearing the completion of my app (and a big thank you to everyone here who has helped me so far - I've received a lot of help and do really appreciate it). I am currently working on saving project files, but there is one aspect of my app I have no idea how to go about saving, and would be very grateful for some advice. Part of my app works a little like Windows Explorer. On the left there is a folder tree and on the right a file list. The user can create a file tree containing a number of files, and upon hitting a "Build" button, the folder tree he or she has defined is created on disk, and the specified files copied into these folders (you may wonder what the advantage of this method is over just letting my user do all this in Windows Explorer, but trust me that this makes sense in the context of the rest of my app - for instance, the paths of the folders are stored as command-line parameters etc). So far, so good. However, when my user goes to save a project, the project must save the directory tree that he has created, and it is this that I do not know how to achieve. The directory tree is just a tree view - ie. a sequence of HTREEITEMs. On saving a project, the app needs to look at the tree view and save the structure, which can of course consist of an unlimited number of HTREEITEMS organised in any order with various properties. Upon loading a project, the app needs to be able to reconstruct this tree view just as it has been saved. I thought of using a string array to hold the paths of the folders and try to reconstruct them from the paths, and using a number array to hold the properties, but this seems a very long-winded way of doing it. Can anybody suggest a good method of dealing with this? I'm using the straight Windows API with _no_ MFC, but that shouldn't make too much difference as I'm not asking for code so much as for ideas about how one goes about storing information about something as complex and arbitrary as a customisable tree view. Many thanks for any help, KB
-
Hi, I am nearing the completion of my app (and a big thank you to everyone here who has helped me so far - I've received a lot of help and do really appreciate it). I am currently working on saving project files, but there is one aspect of my app I have no idea how to go about saving, and would be very grateful for some advice. Part of my app works a little like Windows Explorer. On the left there is a folder tree and on the right a file list. The user can create a file tree containing a number of files, and upon hitting a "Build" button, the folder tree he or she has defined is created on disk, and the specified files copied into these folders (you may wonder what the advantage of this method is over just letting my user do all this in Windows Explorer, but trust me that this makes sense in the context of the rest of my app - for instance, the paths of the folders are stored as command-line parameters etc). So far, so good. However, when my user goes to save a project, the project must save the directory tree that he has created, and it is this that I do not know how to achieve. The directory tree is just a tree view - ie. a sequence of HTREEITEMs. On saving a project, the app needs to look at the tree view and save the structure, which can of course consist of an unlimited number of HTREEITEMS organised in any order with various properties. Upon loading a project, the app needs to be able to reconstruct this tree view just as it has been saved. I thought of using a string array to hold the paths of the folders and try to reconstruct them from the paths, and using a number array to hold the properties, but this seems a very long-winded way of doing it. Can anybody suggest a good method of dealing with this? I'm using the straight Windows API with _no_ MFC, but that shouldn't make too much difference as I'm not asking for code so much as for ideas about how one goes about storing information about something as complex and arbitrary as a customisable tree view. Many thanks for any help, KB
i would think u have to save the path names of the selected files along with the hierarchy info ... the tree view is only holding refs to those things in effect anyways u should consider saving to an xml file as it is designed to represent hierarchical data after all :)