⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 activeradiobutton.pas

📁 含此文档只表示此压缩包来自于DELPHI盒子网站 ------------------------------------------------------------------------
💻 PAS
字号:
////////////////////////////////////////////////////////////////////////////////
//
//
//  FileName    :   ActiveRadioButton.pas
//  Creator     :   Shen Min
//  Date        :   2002-06-26
//  Comment     :
//
//
////////////////////////////////////////////////////////////////////////////////

unit ActiveRadioButton;

interface

uses
  Windows, Messages, SysUtils, Classes, Controls, ExtCtrls, ActiveButton,
  ActiveCheckBox;

type
    TActiveRadioButton = class(TActiveCheckBox)
    private
        FGroupIndex : Integer;

        procedure UnCheckGroup();

    protected
        procedure SetChecked(const Value: Boolean); override;
        procedure Click(); override;
        procedure DblClick(); override;

    published
        property GroupIndex : Integer read FGroupIndex write FGroupIndex default 0;

    end;

procedure Register;

implementation

procedure Register;
begin
    RegisterComponents('Sunisoft', [TActiveRadioButton]);
end;

procedure TActiveRadioButton.Click;
begin
    inherited;

    Checked := true;
end;

procedure TActiveRadioButton.DblClick;
begin
    inherited;

    Checked := true;
end;

procedure TActiveRadioButton.SetChecked(const Value: Boolean);
begin
    if Value and (not Checked) then
        UnCheckGroup();

    inherited;
end;

procedure TActiveRadioButton.UnCheckGroup;
var
    i : Integer;
begin
    if Parent = nil then
        Exit;

    for i := 0 to Parent.ControlCount - 1 do
    begin
        if not (Parent.Controls[i] is TActiveRadioButton) then
            continue;
        if Parent.Controls[i] = self then
            continue;
        if (Parent.Controls[i] as TActiveRadioButton).GroupIndex <> GroupIndex then
            continue;
        (Parent.Controls[i] as TActiveRadioButton).Checked := false;
    end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -