Search code examples
c++windowstreeviewatltreeviewitem

C++ Tree View Controls, Get Full path of selected item


Currently I have a tree view control and I'm handling the TVN_ITEMEXPANDING command which is fine, however I can't seem to find a way to get an absolute path from the tree view control. i.e

- C:\\
  - Documents
    - Test.txt

Lets say I double click Documents I would like to get the full path which would be

'C:\Documents'

and if I double clicked on Test.txt I would like to get the full path which would be

'C:\Documents\Test.txt'

Is this possible?


Solution

  • The "corresponding" .net control has a property called FullPath. You can take a look at the c# implementation at TreeNode.cs@GetFullPath(). You can (and have to) do pretty much the same in your code as well. (it doesn't have to be recursion, but it can be ;-))