value:=TListBox.Create(Self);
value.parent:=self;
value.OnMouseDown:=(procedure name)

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type  TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
        procedure MyDefineListBox1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}function Sum(x,y:byte):word;
    begin
      result:=x+y;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      x:TListBox;
    begin
      x:=TListBox.Create(self) ;
      x.Parent:=Form1;
      x.Items.Add('OK?');
      x.OnClick:=MyDefineListBox1Click;
    end;procedure TForm1.MyDefineListBox1Click(Sender: TObject);
    begin
      ShowMessage('OK!');
    end;end.