在MEMO中动态生成数目较多组件,并设置二个BUTTON,希望能够产生PAGEUP和PAGEDOWN的功能,程序如下,可没反应,望大佬赐教
unit Unit3;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,ExtCtrls, DB, DBTables,Dateutils;type
  TForm3 = class(TForm)
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    GroupBox4: TGroupBox;
    Label1: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Table1: TTable;
    Table2: TTable;
    Button1: TButton;
    Query1: TQuery;
    Memo1: TMemo;
    Button2: TButton;
    Button3: TButton;
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
   procedure OnClick(   Sender:   TObject   );
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form3: TForm3;implementationuses Unit2;
var
 f3_bt1:tpanel;
 f3_bt:tbutton;
 f3_i:integer;
 f3_ds1:string;
{$R *.dfm}
 procedure tform3.OnClick(   Sender:   TObject   );
 var
 f3_di2,f3_di3,f3_di4,f3_di5,f3_di6:integer; begin
      f3_ds1:=tbutton(sender).Caption;     query1.Close;
     query1.SQL.Clear;
     query1.SQL.Add('select * from dalei where lei_bi='''+f3_ds1+'''');
     query1.Open;
     //edit2.Text:=query1.fieldbyname('chdh').AsString
     f3_ds1:=query1.fieldbyname('bi_hao').AsString;
     f3_ds1:='sp'+trim(f3_ds1);     //table2.Database:='chaoshi';
     table2.TableName:=f3_ds1;
    table2.Open;
    table2.First ;
    f3_di2:=table2.RecordCount ;
    f3_di4:=0;
    f3_di3:=0;
    f3_di5:=1;
    for f3_di2:=1 to table2.RecordCount do
    begin
         f3_bt1:=tpanel.Create(self);
         f3_bt1.Parent:=memo1;
         f3_bt1.Top:=20+f3_di5;
         //f3_bt1.Top:=0+110*f3_di4;
         f3_bt1.Left:=15+f3_di3*110;
          //f3_bt1.Left:=15+f3_di6;
          if f3_bt1.Left>=440 then
          begin
           f3_di3:=-1;
           f3_di4:=f3_di4+1;
           f3_di5:=10*f3_di4+f3_di4*100;
           f3_di6:=10*f3_di3+f3_di4*100;
           end;
         f3_bt1.Height:=100;
         f3_bt1.Width:=100;
         f3_bt1.Caption:=table2.fieldbyname('sp_name').AsString ;
         f3_bt1.Show ;
         table2.Next;
          f3_di3:=f3_di3+1;        end;
        table2.Close;
end ;procedure TForm3.FormShow(Sender: TObject);
var
//year,month,day:word;
f3_i1 :integer;
f3_s1:string;
begin
//decodedate(now,year,month,day);
edit1.Text:=form2.edit1.Text;
edit2.Text :=datetostr(date());
//edit2.Text:=inttostr(year)+'/'+inttostr(month)+'/'+inttostr(day)+' '+inttostr(Hourof(time))+':'+inttostr(minuteof(time))+':'+inttostr(secondof(time))+'';
table1.Active :=true;  //存放商品大类
 table1.Open;
 f3_i1:=table1.RecordCount ;
 table1.First;
 for f3_i1:=1 to f3_i1 do
 begin f3_bt:=tbutton.Create(self);
 f3_bt.Parent:=groupbox2;
 f3_bt.top:=10;
 f3_bt.left:=120+75*f3_i1;
f3_bt.height:=75;
f3_bt.width:=75;
f3_s1:= form3.Table1.fieldbyname('lei_bi').asstring;
f3_bt.caption:=f3_s1;
f3_bt.show;
table1.Next;
 f3_bt.onclick:=onclick;
end;
table1.active:=false;
 table1.Close;       //大类按键放置完成
 end;
procedure TForm3.Button1Click(Sender: TObject);
begin
form3.Close;
application.Terminate ;
end;procedure TForm3.Button2Click(Sender: TObject);
begin
 sendmessage(memo1.handle,wm_vscroll,SB_PAGEDOWN,0);
end;procedure TForm3.Button3Click(Sender: TObject);
begin
 sendmessage(memo1.handle,wm_vscroll,SB_PAGEup,0);
end;end.