|
Technical answers from the trenches |
|
Minimizing Directory Names
| ||||
Posted: 4 December 2000 |
||||
  |
Applies to: All Versions |
|||
  |
Audience: Intermediate |
|||
Question: Is there a convenient way to shorten a long directory name and display it to the user?Answer: Yes, using the same code called by the TDirectoryListBox control on the Win3.x tab of the component palette. TDirectoryListBox is implemented in the FILECTRL unit. If you read this file, you'll notice that the TDirectoryListBox's DirLabel property calls a function called MinimizeName, which shortens a directory name to fit within the canvas of the associated TLabel. You can call this function yourself by adding FILECTRL to an appropriate Uses block and using code along these lines: procedure TForm1.dlbFoldersChange(Sender: TObject);
var
strLongPath : String;
begin
strLongPath := dlbFolders.Directory;
with staticText1 do
Caption := MinimizeName( strLongPath, Canvas, Width );
end;
A demonstration sample is available in our Download section. |
|||
|
||||||||
|
Copyright © 2000-2004, techtricks.com; All Rights Reserved. Acknowledgements, Disclaimers, Terms and Conditions. |
||||||||
|
Article last updated on 31 May 2003
|
||
|
|
||
|
[- End -]
|