//pas
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, CheckLst;type
  TForm1 = class(TForm)
    CheckListBox1: TCheckListBox;
    BitBtnAllSelect: TBitBtn;
    BitBtnBack: TBitBtn;
    BitBtnAllCancel: TBitBtn;
    BitBtnOk: TBitBtn;
    procedure BitBtnAllSelectClick(Sender: TObject);
    procedure BitBtnOkClick(Sender: TObject);
    procedure CheckListBox1DblClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.BitBtnAllSelectClick(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to Pred(CheckListBox1.Items.Count) do
    if CheckListBox1.ItemEnabled[I] then
      case TWinControl(Sender).Tag of
        -1: CheckListBox1.Checked[I] := False;
        00: CheckListBox1.Checked[I] := not CheckListBox1.Checked[I];
        +1: CheckListBox1.Checked[I] := True;
      end;
end;procedure TForm1.BitBtnOkClick(Sender: TObject);
var
  I: Integer;
  S: string;
begin
  S := '';
  for I := 0 to CheckListBox1.Items.Count - 1 do
    if CheckListBox1.Checked[I] then
      S := S + CheckListBox1.Items[I] + #13#10;
  ShowMessage(S);
end;procedure TForm1.CheckListBox1DblClick(Sender: TObject);
begin
  if TCheckListBox(Sender).ItemIndex < 0 then Exit;
  TCheckListBox(Sender).ItemEnabled[TCheckListBox(Sender).ItemIndex] :=
    not TCheckListBox(Sender).ItemEnabled[TCheckListBox(Sender).ItemIndex];
end;procedure TForm1.FormCreate(Sender: TObject);
begin
  BitBtnAllSelect.Tag := 1;
  BitBtnBack.Tag := 0;
  BitBtnAllCancel.Tag := -1;
end;end.//dfm
object Form1: TForm1
  Left = 192
  Top = 103
  Width = 544
  Height = 375
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object CheckListBox1: TCheckListBox
    Left = 0
    Top = 0
    Width = 536
    Height = 121
    ItemHeight = 13
    Items.Strings = (
      '1'
      '2'
      '3'
      '4'
      '5'
      '6'
      '7')
    TabOrder = 0
    OnDblClick = CheckListBox1DblClick
  end
  object BitBtnAllSelect: TBitBtn
    Tag = 1
    Left = 119
    Top = 232
    Width = 75
    Height = 25
    Caption = '全选(&A)'
    TabOrder = 1
    OnClick = BitBtnAllSelectClick
  end
  object BitBtnBack: TBitBtn
    Left = 191
    Top = 232
    Width = 75
    Height = 25
    Caption = '反选(&B)'
    TabOrder = 2
    OnClick = BitBtnAllSelectClick
  end
  object BitBtnAllCancel: TBitBtn
    Tag = -1
    Left = 253
    Top = 232
    Width = 75
    Height = 25
    Caption = '全消(&L)'
    TabOrder = 3
    OnClick = BitBtnAllSelectClick
  end
  object BitBtnOk: TBitBtn
    Left = 313
    Top = 232
    Width = 75
    Height = 25
    Caption = '确定(&Y)'
    TabOrder = 4
    OnClick = BitBtnOkClick
  end
end