cxCheckBox不显示焦点矩形虚线框

在cxCheckBox.pas文件中找到 procedure(存储过程)CalculateCustomCheckBoxViewInfo,将FocusRect属性修改为cxEmptyRect


procedure CalculateCustomCheckBoxViewInfo(AViewData: TcxCustomCheckBoxViewData;
  AViewInfo: TcxCustomCheckBoxViewInfo);

  procedure CheckFocusRectBounds;
  var
    AMaxRect: TRect;
  begin
    with AViewInfo do
      begin
        if Alignment = taCenter then
          AMaxRect := Rect(FocusRect.Left, ClientRect.Top, FocusRect.Right, ClientRect.Bottom)
        else
          begin
            AMaxRect := Rect(TextRect.Left - 1, TextRect.Top - 1 + 2 * Integer(IsInplace),
              TextRect.Right + 1, TextRect.Bottom + 1 - 2 * Integer(IsInplace));
            if AMaxRect.Right > BorderRect.Right - 1 then
              AMaxRect.Right := BorderRect.Right - 1;
          end;

        if FocusRect.Left < AMaxRect.Left then
          FocusRect.Left := AMaxRect.Left;
        if FocusRect.Top < AMaxRect.Top then
          FocusRect.Top := AMaxRect.Top;
        if FocusRect.Right > AMaxRect.Right then
          FocusRect.Right := AMaxRect.Right;
        if FocusRect.Bottom > AMaxRect.Bottom then
          FocusRect.Bottom := AMaxRect.Bottom;
      end;
  end;

begin
  with AViewInfo do
    begin
      BackgroundColor := AViewData.Style.Color;

      if
        (Focused and ((not IsInplace or AViewData.Properties.IsEmbeddedEdit) and (Alignment <> taCenter) or
        IsInplace and (Alignment = taCenter) and (epoShowFocusRectWhenInplace in PaintOptions))) then
        begin
          if Alignment = taCenter then
            begin
//            FocusRect := ClientRect; 原版FocusRect属性
              FocusRect := cxEmptyRect;//将FocusRect属性修改为cxEmptyRect
              InflateRect(FocusRect, -1, -1);
            end
          else if Length(Text) <> 0 then
            begin
//            FocusRect := TextRect; 原版FocusRect属性
              FocusRect := cxEmptyRect; //将FocusRect属性修改为cxEmptyRect
//              if not AViewData.Properties.FullFocusRect then 如果不注释此if代码,需要手动对checkbox的FullFocusRect属性设置为True
//                begin
//                  cxScreenCanvas.Font := Font;
//                  cxScreenCanvas.TextExtent(Text, FocusRect, DrawTextFlags);
//                  cxScreenCanvas.Dormant;
//                end;
              InflateRect(FocusRect, 1, 1);
              Inc(FocusRect.Bottom);
            end
          else
            FocusRect := cxEmptyRect;
        end
      else
        FocusRect := cxEmptyRect;
      if not IsRectEmpty(FocusRect) then
        CheckFocusRectBounds;
    end;
end;



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值