Einzelnen Beitrag anzeigen

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