Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Pathname kürtzen ohne MinimizeName aus Unit FileCtrl (https://www.delphipraxis.net/138388-pathname-kuertzen-ohne-minimizename-aus-unit-filectrl.html)

jaenicke 9. Aug 2009 17:34

Re: Pathname kürtzen ohne MinimizeName aus Unit FileCtrl
 
Zitat:

Zitat von turboPASCAL
Nur, ich muss halt selber ran. ;)

Die paar Sekunden habe ich dann doch grad mal. :mrgreen:
Delphi-Quellcode:
function MinimizeName(const Filename: string; DC: HDC; MaxLen: Integer): string;
var
  b: array [0..MAX_PATH] of Char;
  R: TRect;
  TextSize: TSize;
begin
  StrCopy(b, PChar(Filename));
  GetTextExtentPoint32(DC, PChar(FileName), Length(FileName), TextSize);
  R := Rect(0, 0, MaxLen, TextSize.cy);
  if DrawText(DC, b, Length(Filename), R,
    DT_SINGLELINE or DT_MODIFYSTRING or DT_PATH_ELLIPSIS or DT_CALCRECT or DT_NOPREFIX) > 0 then
    Result := b
  else
    Result := Filename;
end;
// EDIT:
Wobei man für die Höhe ggf. wie im Beispiel auch nur etwas Kurzes statt des gesamten Dateinamens als schnelleren Ersatz nehmen kann.


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:43 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz