AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein EllipsisCharacter funktioniert nicht
Thema durchsuchen
Ansicht
Themen-Optionen

EllipsisCharacter funktioniert nicht

Ein Thema von EWeiss · begonnen am 14. Feb 2017 · letzter Beitrag vom 22. Feb 2017
Antwort Antwort
EWeiss
(Gast)

n/a Beiträge
 
#1

EllipsisCharacter funktioniert nicht

  Alt 14. Feb 2017, 21:10
Mein Code

Delphi-Quellcode:
      else if UseStrFormat = StringFormatFlagsNoWrap then
      begin
        if GdipCreateStringFormat(0, 0, strFormat) = OK then
        begin
          GdipSetStringFormatFlags(strFormat, UseStrFormat);
          GdipSetStringFormatLineAlign(strFormat, StringAlignmentFar);
          GdipSetStringFormatTrimming(strFormat, StringTrimmingEllipsisCharacter);
        end;
        GdipDrawString(Graphics, sTxt, length(sTxt), curFont, @rcLayout, strFormat, brush)
      end
Wenn ich nun die Column in meiner Anwendung verschiebe so das sie über den zu langen Text steht
sollte dieser eigentlich abgeschnitten werden und Ellipsis (...) addiert werden.
Nur leider funktioniert das nicht, keine Ahnung warum.

am Code kann es nicht liegen es sei denn ich habe noch etwas vergessen.

EDIT:
Es geht grundsätzlich schon aber nur von Hand also eigener Code
was mir da nur nicht gefällt sind die unterschiedlichen Abstände da ich die einzelnen Chars in der Weite nicht gegenprüfe.
Das ist der Grund warum ich diese API verwenden möchte.

gruss

Geändert von EWeiss (11. Jul 2019 um 15:45 Uhr)
  Mit Zitat antworten Zitat
hoika

Registriert seit: 5. Jul 2006
Ort: Magdeburg
8.270 Beiträge
 
Delphi 10.4 Sydney
 
#2

AW: EllipsisCharacter funktioniert nicht

  Alt 15. Feb 2017, 04:23
Hallo,
was ist denn das für eine Komponente,
die das property Column besitzt?
Heiko
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#3

AW: EllipsisCharacter funktioniert nicht

  Alt 15. Feb 2017, 16:07
Hallo,
was ist denn das für eine Komponente,
die das property Column besitzt?
Sehe nicht das da irgendwas von property steht nur was von ListView.
Damit aber die blinden hier das auch verstehen..

Wenn ich die Spaltenbreite in der Anwendung verändere.. bla, bla.
Aber schlauer bist du deshalb auch nicht so das du helfen könntest oder?

gruss

Geändert von EWeiss (16. Feb 2017 um 02:17 Uhr)
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#4

AW: EllipsisCharacter funktioniert nicht

  Alt 18. Feb 2017, 19:14
Thema hat sich erledigt funktioniert nun.
Es war nicht die API selbst sondern die Zuweisung eines nicht Korrekten Rect.

Delphi-Quellcode:
procedure TSkinListView.DrawEllipsisText(DC: HDC; UseText: WideString; rec: TRect;
  ColrARGB: COLORREF; UseFont: WideString; UseSize: single; FontStyle: TFontStyle;
  ShadowOffset: single; UseStrFormat: integer; WordWrap: Bool = False);
var
  Width: Integer;
  Fam: GpFontFamily;
  TempFont: GpFont;
  Graphics: Cardinal;
  rectF: TGPRectF;
  Rect, rc, rc2: Trect;
  strFormat: Pointer;
begin

  Graphics := 0;
  strFormat := nil;
  TempFont := nil;
  Fam := nil;
  if GdipCreateFromHDC(DC, Graphics) = Ok then
  begin
    GdipCreateFontFamilyFromName(UseFont, nil, Fam);
    if Assigned(Fam) then
    begin
      GdipCreateFont(Fam, UseSize, FontStyle, 2, TempFont);
      if Assigned(TempFont) then
      begin
        GdipCreateStringFormat(0, 0, strFormat);
        GdipMeasureString(Graphics, UseText, length(UseText), TempFont, @layoutRect, strFormat,
          @boundingBox, nil, nil);

        GetWindowRect(HeaderHandle, rc);
        GetWindowRect(Handle, rc2);

        Width := (rec.Right - rec.Left) + (rc.Left - rc2.Left);
        if boundingBox.Width > Width then
        begin
          rectF := MakeRect(rec.Left, rec.Top, Width, rec.Bottom);
          Rect.Left := round(rectF.X);
          Rect.Top := round(rectF.Y);
          Rect.Bottom := round(rectF.Height);
          Rect.Right := round(rectF.Width);

          UseStrFormat := ZD_Ellipsis;
          DrawTextToDC(DC, UseText, Rect, ColrARGB, UseFont, UseSize, FontStyle, ShadowOffset,
            UseStrFormat, True);

          GdipDeleteGraphics(Graphics); // Lösche das Graphics Object
          GdipDeleteFont(TempFont); // Lösche das Font Object
          GdipDeleteFontFamily(Fam); // Lösche das Font Family Object
          GdipDeleteStringFormat(strFormat); // Lösche das StringFormat
          exit;
        end else
        DrawTextToDC(DC, UseText, rec, ColrARGB, UseFont, UseSize, FontStyle, ShadowOffset,
          UseStrFormat, WordWrap);
      end;
    end;
  end;
  GdipDeleteGraphics(Graphics);
  GdipDeleteFont(TempFont);
  GdipDeleteFontFamily(Fam);
  GdipDeleteStringFormat(strFormat);
end;
coole Musik. Oder? LOL

gruss

Geändert von EWeiss (11. Jul 2019 um 15:46 Uhr)
  Mit Zitat antworten Zitat
freimatz

Registriert seit: 20. Mai 2010
1.386 Beiträge
 
Delphi 11 Alexandria
 
#5

AW: EllipsisCharacter funktioniert nicht

  Alt 21. Feb 2017, 15:47
BTW: schon mal try finally end in Erwägung gezogen?
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#6

AW: EllipsisCharacter funktioniert nicht

  Alt 21. Feb 2017, 18:03
BTW: schon mal try finally end in Erwägung gezogen?
Nö.. will ich nicht.
Brauch ich nicht. Uninteressant, Müllt meinen Code zu.

if GdipCreateFromHDC(DC, Graphics) = Ok then

Ist für mich try, finally genug.
Abgesehen von Delphi hab ich noch keine Sprache verwendet die ein so Sinnloses Konstrukt nötig hätte.
Schon gar nicht mit der Win32API.
try.. except OK! Dann hört es aber auch schon auf.

gruss

Geändert von EWeiss (21. Feb 2017 um 18:28 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:27 Uhr.
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