For example
"C:\Program Files\Delphi\DDrop\TargetDemo\main.pas"
is desired to be seen as
"C:\Program F....Demo\main.pas"
then the following "Mince" function could be used.
~~~~~~~~~~~~~~~~~~~~~~~~~
function Mince
(PathToMince :String; InSpace :Integer): String;
var TotalLength, FLength : Integer;
begin
TotalLength := Length(PathToMince) ;
if TotalLength > InSpace then
begin
FLength := (Inspace Div 2) - 2;
Result := Copy(PathToMince, 0, fLength)
+ '...'
+ Copy(PathToMince,
TotalLength-fLength,
TotalLength) ;
end
else
Result := PathToMince;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
The "InSpace" is an approximate number of charecters the intended space can hold. For example, if i need to fit a long path in a TLabel that can hold 10 charecters 'M' then InSpace is 10. Though it is approximate it does the job 99% of the time. Of course this could be modified to take into account the font width.
For example:
Label1.caption := Mince(Label1.caption, 15) ;
Note: Delphi's MinimizeName function returns a shortened version of a filename (using dots for folders) that fits into some "pixel" length.
Delphi tips navigator:
» The state of the Shift, Ctrl, Alt keys
« Determine the actual size of a Blob field in a Table

