Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Clip Text in a TTreeview (Continued)
    text
    copied!<p>I have taken the advice, or at least I think I have, that I got in my <a href="https://stackoverflow.com/questions/7451667/how-to-clip-text-in-a-ttreeview">previous question</a>.<br> To summarize, I replaced the THTMLTreeList from TMS with a TTreeList and made two columns in it. I set the first column to 150 pixels and I overrode the AdvancedCustomDrawItem event with this code:</p> <pre><code>procedure TForm1.trXMLAdvancedCustomDrawItem(Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState; Stage: TCustomDrawStage; var PaintImages, DefaultDraw: Boolean); var hContext: HDC; s: PChar; iLength: Integer; uRect: TRect; begin DefaultDraw := False; hContext := trXML.Canvas.Handle; s := PChar(Node.Text); iLength := Length(Node.Text); uRect := Node.DisplayRect(True); DrawText(hContext, s, iLength, uRect, DT_END_ELLIPSIS); end; </code></pre> <p>I got the result I expected, that is, when I draw the tree, the text in the first column is clipped. And when I change the size of the first column, the text is appropriately clipped. But when the TreeList is not wide enough and has a scroll bar on the bottom and I scroll to the right, the text now extends into the second column by the same amount as the scroll bar has been moved. It's like the text is drawn relative to the client area of the TreeList rather than the partially hidden first column so it always extends 150 pixels into the TreeList.</p> <p>It seems to me that I am using the wrong thing for the device context handle or the TRect but I do very little graphic type programming so I don't know what to change. Any help would be appreciated. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload