秋·风

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

修复lazarus linux(ubuntu/银河麒麟)Object Inspector、使用combobox、colorbox等控件style为csOwnerDraw*时下拉列表文字不显示的问题(在树莓派正常),这类问题大概率是ubuntu/银河麒麟引起的,如果使用中也遇到同样的问题可参照以下方法处理。
打开lazarus/lcl/include/customcombobox.inc,(第109行)定位TCustomComboBox.DrawItem(Index: Integer; ARect: TRect; State: TOwnerDrawState);
添加红字1行,重绘背景,重新编译应用程序就可以解决Object Inspector、combobox和colorbox列表的不显示item的问题,这方法不一定是最佳的,但能解决我遇到的问题
修复前:


修复后:

 

procedure TCustomComboBox.DrawItem(Index: Integer; ARect: TRect;
  State: TOwnerDrawState);
begin
  //TControlCanvas(FCanvas).UpdateTextFlags;
  //2022.05.28 LBZ
  {$ifdef linux}
  FCanvas.FillRect(ARect);
  {$endif}
  //2022.05.28 LBZ
  if Assigned(FOnDrawItem) then
    FOnDrawItem(Self, Index, ARect, State)
  else
  begin
    if not (odBackgroundPainted in State) then
      FCanvas.FillRect(ARect)
    else
      InternalDrawItem(Self, FCanvas, ARect, Items[Index]);
  end;
end;

 

posted on 2022-05-29 06:11  秋·风  阅读(469)  评论(0编辑  收藏  举报