AGB  ·  Datenschutz  ·  Impressum  







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

VirtualStringTree Text with multiColor

Ein Thema von sdean · begonnen am 30. Okt 2013 · letzter Beitrag vom 30. Okt 2013
Antwort Antwort
sdean

Registriert seit: 5. Dez 2009
64 Beiträge
 
#1

VirtualStringTree Text with multiColor

  Alt 30. Okt 2013, 19:45
Hello , please i need all your help in this :

Suppose i have this Text on VirtualStringTree cell :

'HELLO'

how can i give Each character a different Color like this :

HELLO

many thanks
  Mit Zitat antworten Zitat
Aviator

Registriert seit: 3. Jun 2010
1.610 Beiträge
 
Delphi 10.3 Rio
 
#2

AW: VirtualStringTree Text with multiColor

  Alt 30. Okt 2013, 19:56
Maybe you could use the OnDrawText Event of the VST. And I think there you could change the Canvas.Font.Color of the TargetCanvas for each letter.
  Mit Zitat antworten Zitat
sdean

Registriert seit: 5. Dez 2009
64 Beiträge
 
#3

AW: VirtualStringTree Text with multiColor

  Alt 30. Okt 2013, 20:01
Maybe you could use the OnDrawText Event of the VST. And I think there you could change the Canvas.Font.Color of the TargetCanvas for each letter.
many thanks Aviator , i really need a little code ....
  Mit Zitat antworten Zitat
Aviator

Registriert seit: 3. Jun 2010
1.610 Beiträge
 
Delphi 10.3 Rio
 
#4

AW: VirtualStringTree Text with multiColor

  Alt 30. Okt 2013, 20:22
Maybe you could do it like this:

Delphi-Quellcode:
procedure TMainFrm.MainVSTDrawText(Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode;
  Column: TColumnIndex; const Text: string; const CellRect: TRect; var DefaultDraw: Boolean);
var
  i, TotalWidth : Integer;
begin
  DefaultDraw := False;
  if Node.Index = 1 then begin
    TotalWidth := 0;
    for i := 0 to Length(Text) - 1 do begin
      if (i mod 2 = 0) then
        TargetCanvas.Font.Color := clBlue
      else
        TargetCanvas.Font.Color := clRed;

      TargetCanvas.TextOut(CellRect.Left + TotalWidth, CellRect.Top, Text[i]);
      Inc(TotalWidth, TargetCanvas.TextWidth(Text[i]));

    end;
  end else
    DefaultDraw := True;
end;
But I really don't know if this is the right and/or fastest way to do this.

Happy testing.
  Mit Zitat antworten Zitat
Aviator

Registriert seit: 3. Jun 2010
1.610 Beiträge
 
Delphi 10.3 Rio
 
#5

AW: VirtualStringTree Text with multiColor

  Alt 30. Okt 2013, 20:23
Sorry for double posting, but I forgot the sample picture.
Angehängte Grafiken
 
  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 02:43 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