Mega Code Archive

 
Categories / Delphi / Files
 

Fit path+filename on the caption of a label

Title: Fit path+filename on the caption of a label. Question: Fit path+filename on the caption of a label by inserting ... instead of directory names. The routine also hides the extention. It returns a string that will fit "exactly" on the label caption. Answer: { Returns a path string that fits on the caption of TxtLabel E.J.Molendijk } uses FileCtrl; {...} function FitOnCanvas(FName : String; TxtLabel : TLabel) : String; Var ExtL : Integer; begin ExtL := Length(ExtractFileExt(FName)); Delete(FName,Length(FName)-ExtL+1,ExtL); Result:=MinimizeName(FName, TxtLabel.Canvas, TxtLabel.Width); end;