Is there a way to make TradioButton transparent?

6 answers

I agree with Andreas and Serg that control is transparent when topics are enabled.

Once I tried to make CheckBox transparent if runtime themes were not included in the project parameters, or if the classic theme was selected from the OS; the result was not perfect. Below is the code applied to RadioButton.

, , - , , , , DoubleBuffered. , , () , , , , .

, , :

type
  TMyRadioButton = class(TRadioButton)
  private
    procedure CnCtlColorStatic(var Msg: TWMCtlColorStatic); message CN_CTLCOLORSTATIC;
    procedure WmEraseBkgnd(var Msg: TWMEraseBkgnd); message WM_ERASEBKGND;
    procedure WmPaint(var Msg: TWMNCPaint); message WM_PAINT;
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  end;

implementation

uses
  themes;

procedure TMyRadioButton.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.ExStyle := Params.ExStyle or WS_EX_TRANSPARENT;
end;

procedure TMyRadioButton.WmPaint(var Msg: TWMNCPaint);
begin
  if not (ThemeServices.ThemesEnabled or DoubleBuffered) then
    InvalidateRect(Handle, nil, True);
  inherited;
end;

procedure TMyRadioButton.WmEraseBkgnd(var Msg: TWMEraseBkgnd);
var
  R: TRect;
begin
  if not (ThemeServices.ThemesEnabled or DoubleBuffered)
       and (Parent <> nil) then begin
    R := Rect(Left, Top, Left + Width, Height + Top);
    InvalidateRect(Parent.Handle, @R, True);
    UpdateWindow(Parent.Handle);
    Msg.Result := 1;
  end else
    inherited;
end;

procedure TMyRadioButton.CnCtlColorStatic(var Msg: TWMCtlColorStatic);
begin
  if not (ThemeServices.ThemesEnabled or DoubleBuffered) then begin
    SetBKMode(Msg.ChildDC, TRANSPARENT);
    Msg.Result := GetStockObject(NULL_BRUSH);
  end else
    inherited;
end;
+3

(TeamB):

TLabel - TGraphicControl , , , . TCheckBox TRadioButton, , TWinControl , Win32 API, , , , ( ). https://forums.codegear.com/thread.jspa?threadID=24027&tstart=375

, ...

+2

: , , ; .

, , , . .

WM_CTLCOLOR. , .

+1

VCL TRadioButton Delphi 2009 ( , Delphi 2010 ).

(Project- > Options- > Application- > Enable Runtime Themes), TRadioButton , "" . , TRadioButton , "".

, , VCL TRadioButton ( ) Windows, . , . , ( TCustomControl, Windows-)

+1

- , Raize Components, . , Raize .

0

http://www.torry.net/quicksearchd.php?String=transparent+radiobutton&Title=No can help. None of them are D2010 or D2009, but I believe that the transfer will be possible.

0
source

All Articles