2004. november 14., vasárnap

Display a long path as "c:\...\path\myfile.txt"


Problem/Question/Abstract:

Display a long path as "c:\...\path\myfile.txt"

Answer:

To display a (potential) long path shortened in the format shown above, you may use the function MinimizeName from Delphi's unit FileCtrl.

In case you were using a TLabel, you can register the component TPathLabel (declared in the same unit); TPathLabel uses MinimizeName to display the caption.


// \Delphi\Source\Vcl\FileCtrl.pas

unit FileCtrl;

function MinimizeName(const Filename: TFileName; Canvas: TCanvas;
  MaxLen: Integer): TFileName;

type
  TPathLabel = class(TCustomLabel);

Nincsenek megjegyzések:

Megjegyzés küldése