Re-entrancy, shortcuts in a TreeView

  • Thread starter Michael A. Covington
  • Start date
M

Michael A. Covington

I'm extending TreeView to build a file/directory chooser like the one in
NTBACKUP.

I've implemented four-state checkboxes; no problem.

And I know how to explore files and directories and populate the tree
(including populating branches on demand, when the user first expands them,
rather than trying to search the entire computer at the beginning).

What I'm stuck on is re-entrancy, or multiple paths to the same location.
E.g., "My Documents" at the root of the tree is also "c:\documents and
settings\whatever\My Documents". Any shortcut can create the same
situation.

In NTBACKUP, you simply see the same nodes in both places, complete with
checkmark status.

How should I approach this? In a TreeView, can the Nodes list of two nodes
be the same?

This also implies that any recursive tree crawling that I do must be
cycle-proof.

Any ideas, deep thinkers out there?
 
M

mdb

What I'm stuck on is re-entrancy, or multiple paths to the same
location. E.g., "My Documents" at the root of the tree is also
"c:\documents and settings\whatever\My Documents". Any shortcut can
create the same situation.

I'm certianly no expert on what you are asking, but as a second pair of
eyes I have a few questions / thoughts...

1) How are you getting the "My Documents" folder to start with? In other
words, you must either be querying something that returns "My Documents" as
a valid location on disk, or you are simply adding it yourself because you
know it to be there. If then you should be able to query what the "My
Documents" folder location is thru PInvoke to shell32.dll
SHGetSpecialFolderLocation (reference www.pinvoke.net perhaps for
assistance on that.) If you are getting it from some other external call,
then I would think there would be something that is returned telling you
that it is a special folder that you can thus handle in a special fashion
(perhaps as already described.)

2) To handle the multiple paths issue, you could use the physical path
location (which will be unique - MyDocuments = C:\Documents and Settings
\user\...) as a key in a hashtable that holds parameters about that
selection (select entire tree, select subtree, etc.)

3) I'm surprised you suggest that a shortcut would cause a similar
condition - shortcuts are just files that contain information about the
target. I would think you would see the shortcut filename instead of the
contents. If this is not the case then you need to find some way to get
the actual shortcut filename, since that is what you really want to access.

Hope this helps a little...
 
M

Michael A. Covington

What I'm stuck on is re-entrancy, or multiple paths to the same
I'm certianly no expert on what you are asking, but as a second pair of
eyes I have a few questions / thoughts...

1) How are you getting the "My Documents" folder to start with? In other
words, you must either be querying something that returns "My Documents"
as
a valid location on disk, or you are simply adding it yourself because you
know it to be there. If then you should be able to query what the "My
Documents" folder location is thru PInvoke to shell32.dll
SHGetSpecialFolderLocation (reference www.pinvoke.net perhaps for
assistance on that.)

Right; I know how to find out where it is. Have you seen how it's handled
by the file chooser in NTBACKUP?

2) To handle the multiple paths issue, you could use the physical path
location (which will be unique - MyDocuments = C:\Documents and Settings
\user\...) as a key in a hashtable that holds parameters about that
selection (select entire tree, select subtree, etc.)

That smacks of reimplementing entirely too much of TreeView, which is why I
was looking for a shortcut (pardon the pun).

3) I'm surprised you suggest that a shortcut would cause a similar
condition - shortcuts are just files that contain information about the
target. I would think you would see the shortcut filename instead of the
contents. If this is not the case then you need to find some way to get
the actual shortcut filename, since that is what you really want to
access.

Doesn't NTBACKUP follow them and expand them?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top