修复lazarus linux(ubuntu/银河麒麟)使用combobox、colorbox等控件下拉时文字不显示的问题

发布时间:2022-06-20 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了修复lazarus linux(ubuntu/银河麒麟)使用combobox、colorbox等控件下拉时文字不显示的问题脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

修复lazarus linux(ubuntu/银河麒麟)使用combobox、colorbox等控件style为csOwnerDraw*时下拉时文字不显示的问题,这类问题大概率是linux本身引起的,如果使用中也遇到相应的问题可参照以下方法处理。打开lazarus/lcl/StdCtrls.pp,定位procedure InternalDrawItem(Control:TControl; Canvas: TCanvas; ARect:TRect; const Text: string);添加红字一行,重新编译应用程序就可以。修复前:

修复lazarus linux(ubuntu/银河麒麟)使用combobox、colorbox等控件下拉时文字不显示的问题

修复lazarus linux(ubuntu/银河麒麟)使用combobox、colorbox等控件下拉时文字不显示的问题

修复后:

修复lazarus linux(ubuntu/银河麒麟)使用combobox、colorbox等控件下拉时文字不显示的问题

 

procedure InternalDrawItem(Control:TControl; Canvas: TCanvas; ARect:TRect; const Text: string);
var
  OldBrushStyle: TBrushStyle;
  OldTextStyle: TTextStyle;
  NewTextStyle: TTextStyle;
begin
  OldBrushStyle := Canvas.Brush.Style;
  Canvas.Brush.Style := bsClear;

  OldTextStyle := Canvas.TextStyle;
  NewTextStyle := OldTextStyle;
  NewTextStyle.Layout := tlCenter;
  NewTextStyle.RightToLeft := Control.UseRightToLeftReading;
  if Control.UseRightToLeftAlignment then
  begin
    NewTextStyle.Alignment := taRightJustify;
    ARect.Right := ARect.Right - 2;
  end
  else
  begin
    NewTextStyle.Alignment := taLeftJustify;
    ARect.Left := ARect.Left + 2;
  end;

  Canvas.TextStyle := NewTextStyle;

  Canvas.Font.Color:=clHighlightText;//2022.05.26 LBZ 修正银河麒麟linux DrawItem文字颜色与背景颜色一样的Bug

  Canvas.TextRect(ARect, ARect.Left, ARect.Top, Text);
  Canvas.Brush.Style := OldBrushStyle;
  Canvas.TextStyle := OldTextStyle;
end;

 

脚本宝典总结

以上是脚本宝典为你收集整理的修复lazarus linux(ubuntu/银河麒麟)使用combobox、colorbox等控件下拉时文字不显示的问题全部内容,希望文章能够帮你解决修复lazarus linux(ubuntu/银河麒麟)使用combobox、colorbox等控件下拉时文字不显示的问题所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: