AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Falsche Fontfarbe

Ein Thema von EWeiss · begonnen am 8. Okt 2016 · letzter Beitrag vom 8. Okt 2016
 
EWeiss
(Gast)

n/a Beiträge
 
#1

Falsche Fontfarbe

  Alt 8. Okt 2016, 18:04
Meine Checkbox hat die Fontfarbe "clWindowText" sollte in dem fall 0 sein.


Eigentlich sollte es ausreichen den Font zu übergeben und anschließend die Farbe daraus zu ermitteln.
Tut es aber anscheinend nicht.
Deshalb habe ich Jetzt die Farbe mal gesondert übergeben.


Delphi-Quellcode:
CK.Font := Form1.CheckBox1.Font;
CK.FontColor := Form1.CheckBox1.Font.Color;
CK.BackColor := Form1.CheckBox1.Color;
Wenn ich jetzt meinen LogFont erstelle.. und den Text zeichne ist die Farbe falsch.

Delphi-Quellcode:
procedure THookedCheckBox.DrawCaption(WinHandle: HWND; DC: HDC; Size: TRect; Disabled: BOOL);
var
  Brush: HBrush;
  Color: Colorref;
  crFont: HFONT;
  FontOld: HFont;
  Caption: WideString;
  rc: TRect;
  LogFont: TLOGFONT;

begin

  FillChar(LogFont, SizeOf(TLOGFONT), 0);

  Color := BackColor;
  Brush := CreateSolidBrush(TranslateColor(Color));
  FillRect(DC, Size, Brush);
  DeleteObject(Brush);

  StrPCopy(LogFont.lfFaceName, Font.Name);
  LogFont.lfHeight := (Font.Size * -20) div 15;
  LogFont.lfWeight := 500;
  LogFont.lfItalic := IIf(Font.Style = [fsItalic], 1, 0);
  LogFont.lfUnderline := IIf(Font.Style = [fsUnderline], 1, 0);
  LogFont.lfStrikeOut := IIf(Font.Style = [fsStrikeOut], 1, 0);
  LogFont.lfQuality := ANTIALIASED_QUALITY;

  Caption := GetWindowText(CtrlHwnd);
  crFont := CreateFontIndirect(LogFont);
  FontOld := SelectObject(DC, crFont);
  SetBkMode(DC, TRANSPARENT);
  SetTextColor(DC, FontColor);
  CopyRect(rc, Size);
  rc.left := CheckWidth + 4;
  DrawText(DC, Caption, -1, rc, DT_LEFT or DT_VCENTER or DT_SINGLELINE);

  if Disabled then
  begin
    OffsetRect(rc, -1, -1);
    SetTextColor(DC, $CCCCCC);
    DrawText(DC, Caption, -1, rc, DT_LEFT or DT_VCENTER or DT_SINGLELINE);
  end;

  SelectObject(DC, FontOld);
  DeleteObject(crFont);

end;
Die Farbe die übergeben wird (Aus der Form1)
Form1.CheckBox1.Color; = -16777201
Form1.CheckBox1.Font.Color; = -16777208

Warum ? Wenn Form1.CheckBox1.Font.Color eigentlich clWindowText ist.
Sollte eigentlich 0 sein in dem Fall.

Sieht dann aus wie auf dem Bild! Im Anhang siehe Checkboxen.
Wenn da Fehler in der Zuweisung der Fontstyle vorliegen bitte bescheid geben das scheint auch nicht so zu funktionieren wie es soll.
Die 3 Checkbox hat fsUnderline wird aber nicht erkannt.


Funktioniert musste nur alle Checkboxen übergeben nicht nur den Font von einer.
Delphi-Quellcode:
       if TWinControl(Comp.Controls[i]) = Form1.CheckBox1 then
       begin
         CB.Font := Form1.CheckBox1.Font;
         CB.FontColor := Form1.CheckBox1.Font.Color;
         CB.BackColor := Form1.CheckBox1.Color;
         CB.Connect;
       end else if TWinControl(Comp.Controls[i]) = Form1.CheckBox2 then
       begin
         CB.Font := Form1.CheckBox2.Font;
         CB.FontColor := Form1.CheckBox2.Font.Color;
         CB.BackColor := Form1.CheckBox2.Color;
         CB.Connect;
       end else if TWinControl(Comp.Controls[i]) = Form1.CheckBox3 then
       begin
         CB.Font := Form1.CheckBox3.Font;
         CB.FontColor := Form1.CheckBox3.Font.Color;
         CB.BackColor := Form1.CheckBox3.Color;
         CB.Connect;
       end;
Aber die bescheidenen Farben wollen einfach nicht.

gruss

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


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 02:50 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz