cxRadioButton不显示焦点矩形虚线框

在cxRadioGroup.pas文件中找到 procedure(存储过程)TcxRadioButton.DrawCaption,将ACanvas.Canvas.DrawFocusRect(R)注释掉就可以了。


procedure TcxRadioButton.DrawCaption(ACanvas: TcxCanvas; ANativeStyle: Boolean);

  function GetDrawTextFlags: Integer;
  begin
    Result := cxAlignLeft or cxAlignVCenter or cxShowPrefix;
    if WordWrap then
      Result := Result or cxDontClip or cxWordBreak
    else
    begin
      Result := Result or cxSingleLine;
      if ShowEndEllipsis then
        Result := Result or cxShowEndEllipsis;
    end;
  end;

  procedure CheckFocusRect(var R: TRect);
  begin
    if IsInplace then
    begin
      R.Top := Max(R.Top, 1);
      R.Bottom := Min(R.Bottom, Height - 1);
      R.Right := Min(R.Right, Width);
    end
    else
    begin
      R.Left := Min(R.Left, 0);
      R.Top := Min(R.Top, 0);
      R.Right := Min(R.Right, Width);
      R.Bottom := Min(R.Bottom, Height);
      if (Alignment = taLeftJustify) then
        R.Right := Min(ButtonRect.Left, R.Right);
    end;
  end;

var
  AFlags: Integer;
  R: TRect;
begin
  AdjustCanvasFontSettings(ACanvas);

  R := TextRect;
  ACanvas.Brush.Style := bsClear;
  AFlags := GetDrawTextFlags;
  if IsNativeBackground then
    ACanvas.Canvas.Refresh;
  ACanvas.DrawText(Caption, R, AFlags, IsDisabledTextColorAssigned or
    Supports(Self, IcxContainerInnerControl) or ANativeStyle or Enabled);
  ACanvas.Brush.Style := bsSolid;
  if Focused and (Caption <> '') then
  begin
    ACanvas.TextExtent(Caption, R, AFlags);
    InflateRect(R, 1, 1);
    Inc(R.Bottom);
    if IsInplace then
      CheckFocusRect(R);
    ACanvas.Brush.Color := Color;
    ACanvas.Font.Color := Font.Color;
    TCanvasAccess(ACanvas.Canvas).RequiredState([csFontValid]);
//    ACanvas.Canvas.DrawFocusRect(R);  取消(点击radiobutton)获取焦点后出现矩形虚线框
  end;
end;


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值