cxRadioButton不显示焦点矩形虚线框

来源:互联网 发布:readfile java 编辑:程序博客网 时间:2024/04/28 06:29

在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