【发布时间】:2016-02-23 13:51:19
【问题描述】:
我正在寻找一个简单的示例来使用 TDirect2DCanvas 为所有者绘制列表框的每个项目。谷歌搜索 DirectWrite 将结果提供给示例示例以在表单上呈现文本。作为一名学生,我的 Delphi 技能无法正确掌握教程。一个简单的例子或在画布上绘制文本的参考对我来说是一个很好的开始。
这是代码(旧的经典方法),我正在尝试使用 DirectWrite 来实现:
procedure TForm2.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
LB: TListBox;
begin
LB := TListBox(Control);
if odSelected in State then begin
LB.Canvas.Brush.Color := clPurple;
end;
LB.Canvas.FillRect(Rect);
LB.Canvas.TextOut(Rect.Left + 10, Rect.Top + 5, LB.Items[Index]);
end;
【问题讨论】:
-
您似乎希望我们为您翻译您的代码。如果您无法理解教程和文档,那么您将无法生成任何代码。你考虑过聘请程序员吗?为什么你还是要停止使用 GDI?
-
预计 D2D 不会比 GDI 慢,如果不慢的话
标签: delphi canvas vcl delphi-xe8 directwrite