lazarus在银河麒麟国产操作系统linux下,使用TListView 使用图标样式 BUG完善
lazarus在银河麒麟国产操作系统linux下,使用TListView 使用TListView vsIcon 样式,文本长了会是这样效果
尝试设置 OwnerDraw 属性为 True
自己定义方法 DrawItem 不起效果
也尝试修改 TCustomListView 源代码也不起效果,
搞了半天,后发现坑了,没仔细看帮助
When set to True, the OnDrawItem event handler is signalled to draw list items when the control is using the Report view style (ViewStyle = vsReport). The handler is signalled (when assigned) from the DrawItem method, and occurs when the CN_DRAWITEM control notification message is handled for the control. It should handle all aspects of drawing the list item to the control Canvas. If OnDrawItem has not been assigned, a basic default drawing routine is used.
只有ViewStyle = vsReport 也可调用 DrawItem
vsIcon 是调系统gtk自己画的
本质还是系统问题不是 lazarus 问题
后面不折腾了,自己程序代码完善一下
function MinimizeText(const Text: string; Canvas: TCanvas; MaxWidth: Integer): string;
var
I: Integer;
begin
Result := Text;
I := 1;
while (I <= Length(Text)) and (Canvas.TextWidth(Result) > MaxWidth) do
begin
Inc(I);
Result := Copy(Text, 1, Max(0, Length(Text) - I)) + '...';
end;
end;
长的文本加...
vLI := ListView1.Items.Add;
vLI .Caption := MinimizeText(AQry.FieldByName('sfilename').AsString, ListView1.Canvas ,100);
vLI .SubItems.Add(AQry.FieldByName('iid').AsString);
vLI .SubItems.Add(AQry.FieldByName('sfilename').AsString);
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· 地球OL攻略 —— 某应届生求职总结