I have a standard Win32 tree view control. I’m putting a file name into the root node. To avoid asking the user to use a horizontal scroll bar I would like to shorten the text using PathCompactPath to fit in the space available on the control.

So, in order to do this I need to measure the distance marked in the screenshot above. I know about TVM_GETITEMRECT but it returns a rect that includes the space taken up by the icon.
So, how can I obtain the metric I need? Is it even possible to do so?
Are you specifying
TRUEorFALSEfor thewParamparameter ofTVM_GETITEMRECT? It should beTRUEto get the node’s text rectangle. Once you have that, you can subtract the rectangles’s left pixel value from the client width of the TreeView to get the width you are looking for.