なんと、ボタンが変身してしまうプログラムです。面白いので、ぜひ試してみてください。フォームには、ボタンが張り付いています。
var
iCount: integer; // グローバル変数(押した回数)
procedure TForm1.Button1Click(Sender: TObject);
const
Style: LongInt = WS_CHILD or WS_VISIBLE;
Text : array[0..2] of string =
('CheckBox','RadioButton','PushButton');
var
iCase: integer;
begin
iCase := iCount mod 3; // 3で割った余り
case iCase of
0: SetWindowLong(Button1.Handle, GWL_STYLE, Style or BS_CHECKBOX);
1: SetWindowLong(Button1.Handle, GWL_STYLE, Style or BS_RADIOBUTTON);
2: SetWindowLong(Button1.Handle, GWL_STYLE, Style or BS_PUSHBUTTON);
end;
Button1.Caption := Text[iCase];
Inc(iCount);
end;
ボタンが、RadioButtonやCheckBoxに変身してしまいます!