I am trying to put a very long filename on a TLabel using the MinimizeName function from Vcl.FileCtrl unit but I can't figure out how to get the MaxLen parameter used by the function If I hardcode a value I can see a valid result. But since the form can be resized I would like it to be dynamic = changing on resize event.
Some of the things I have tried is lblLicenseFile.Width // string is too long lblLicenseFile.Width - 10 //string is too long Trunc(lblLicenseFile.Width / lblLicenseFile.Font.Size) // string is very short
There must be some method of calculating this number of pixels
MinimizeName(const Filename: TFileName; Canvas: TCanvas; MaxLen: Integer): TFileName; MaxLen is the lenght, in pixels, available for drawing the file name on the canvas.
To let the label control automatically shorten path, you can set the
AutoSize
property to False and theEllipsisPosition
property toepPathEllipsis
if you're using a recent version of Delphi.