procedure TVisualFontProperty.PropDrawValue( Canvas: TCanvas; const Rect: TRect; Selected: Boolean); var Font: TFont; begin Font := TFont(GetOrdValue); if Font <> nilthenbegin if ColorToRGB(Font.Color) <> ColorToRGB(clBtnFace) then Canvas.Font.Color := Font.Color; Canvas.Font.Name := Font.Name; Canvas.Font.Style := Font.Style; end; inherited; end;
另外我们重载GetValue方法来提供更多的信息,比如字体名和大小。
function TVisualFontProperty.GetValue: string; var Font: TFont; begin Font := TFont(GetOrdValue); if Font = nilthen Result := inherited GetValue else Result := Format(''''%s, %d'''', [Font.Name, Font.Size]); end;