How to truncate a long directory path (Views: 100)
I want to draw a directory path on a canvas, but then I have a fixed width for the canvas. So I would like to truncate long directory names to fit in the canvas like
"C:\Directory1\Directory2\Directory3\Directory4\Aaahhh\Finally" should be truncated to "C:\...\Aaahhh\Finally" or "C:\...\Finally" depending on width available.
procedure DrawPath(ACanvas: TCanvas; const Path: string; Rect: TRect);
DrawText(ACanvas.Handle, PChar(Path), -1, Rect, DT_PATH_ELLIPSIS);
<< Back to main page