Ho provato ad applicare VCLStyle per TLinkLabel.Come si applica a VCLStyle per TLinkLabel
Purtroppo, non riesco a visualizzare sottolineare (sentece di un tag)
TLinkLabel.Caption := 'Sma<a>pl</a>e';
Come ho risolto questo?
Per risolvere questo problema, ma un tag non è apparso probabile che questo "campione"
procedure TgLinkLabelHook.Paint(Canvas: TCanvas);
var
LDetails: TThemedElementDetails;
ParseStr: String;
DrawRect: TRect;
DC: HDC;
TextSize: TSize;
SaveFont: HFont;
ThemeTextColor: TColor;
begin
ParseStr := ParseLinks;
LDetails := StyleServices.GetElementDetails(tbPushButtonPressed);
DC := GetDC(0);
try
SaveFont := SelectObject(DC, TLinkLabel(Control).Font.Handle);
try
GetTextExtentPoint32(DC, PWideChar(ParseStr), Length(ParseStr), TextSize);
finally
SelectObject(DC, SaveFont);
end;
finally
ReleaseDC(0, DC);
end;
Canvas.Font := TLinkLabel(Control).Font;
Canvas.Font.Style := Canvas.Font.Style + [fsUnderline];
Canvas.Font.Size := TLinkLabel(Control).Font.Size;
if StyleServices.GetElementColor(LDetails, ecBodyTextColor, ThemeTextColor) then
Canvas.Font.Color := ThemeTextColor;
// DrawRect := Rect(0, 0, TextSize.cx, TextSize.cy);
DrawRect := Control.ClientRect;
DrawControlText(Canvas, LDetails, ParseStr, DrawRect, DT_VCENTER or DT_CENTER);
end;
procedure TForm8.FormCreate(Sender: TObject);
begin
TStyleManager.Engine.RegisterStyleHook(TLinkLabel, TgLinkLabelHook);
end;
Il carattere di testo predefinito viene utilizzato perché si chiama 'DrawControlText' che utilizza il carattere predefinito del controllo per il rendering. Questo è ciò che sovrascrive le impostazioni del tuo carattere canvas. Un'altra cosa è che non puoi cambiare i colori dei link in qualcosa di diverso dai colori di sistema (come COLOR_HIGHLIGHT) o il colore predefinito del font dell'etichetta, quindi il tuo tentativo sembra essere inutile, se ho ragione tu vuoi usare il link personalizzato colori. Si veda ad esempio ['here'] (http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/bd54bd30-e21f-4dc7-a77f-88de02c63f72/). – TLama
Puoi chiamare 'StyleServices.DrawText' invece di' DrawControlText', ma nulla cambia sul fatto che i link da 'TLinkLabel' ([' SysLink'] (http://msdn.microsoft.com/en-us/library/ windows/desktop/bb760706 (v = vs.85) .aspx) control) sono renderizzati dal sistema usando i colori di sistema e se vuoi renderli da soli dovrai analizzare di nuovo il testo e renderizzare ogni parte dal tuo proprio, ciò che rende l'uso della 'TLinkLabel' inutile. – TLama
@TLama, hai ragione, perché non pubblicare il tuo commento come risposta? – RRUZ