unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TMyRadioButton =
class(TRadioButton)
private
Fchecked: Boolean;
protected
function GetChecked: Boolean;
override;
procedure SetChecked(Value: Boolean);
override;
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
published
end;
TForm1 =
class(TForm)
RadioButton1: TRadioButton;
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TMyRadioButton }
{ TMyRadioButton }
constructor TMyRadioButton.Create(AOwner: TComponent);
begin
inherited;
end;
destructor TMyRadioButton.Destroy;
begin
inherited;
end;
function TMyRadioButton.GetChecked: Boolean;
// HIER KLEMMT ES
begin
inherited;
Result := Fchecked;
end;
procedure TMyRadioButton.SetChecked(Value: Boolean);
begin
begin
FChecked :=
not Fchecked;
begin
SendMessage(
Handle, BM_SETCHECK, Integer(FChecked), 0);
if Value
then
begin
inherited Changed;
if not ClicksDisabled
then Click;
end;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
I: Integer;
MyRadioButton: TMyRadioButton;
begin
for I := 1
to 10
do
begin
MyRadioButton := TMyRadioButton.Create(Self);
MyRadioButton.Top := 20 * I;
MyRadioButton.Left := 20;
MyRadioButton.Caption := '
MyRadioButton ' + IntToStr(I);
MyRadioButton.Parent := Self;
MyRadioButton.Checked := True;
// XXX wird auf Wahr gesetzt
end;
end;
end.