Événement OnClick d'un sous-menu
Bonjour,
je crée dynamiquement des sous-menus auquels je n'arrive pas à assigner un événement onclick
je déclare dans "type" (mais si je le fais en "public" c'est pareil)
Code:
procedure m9Click(Sender: TObject);
j'écris la procédure
Code:
1 2 3 4
| procedure TForm1.m9Click(Sender: TObject);
begin
caption:= inttostr(tmainmenu(sender).tag); //juste pour essai
end; |
je crée les sous-menus (l'erreur est ligne 30)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| procedure TForm1.charger_messiers;
var
a:integer;
men :TMenuItem;
begin
men := TMenuItem.Create(self);
men.Name := 'sousmenu1';
men.Caption := '1..25';
m9.Add(men);
men := TMenuItem.Create(self);
men.Name := 'sousmenu2';
men.Caption := '26..50';
m9.Add(men);
men := TMenuItem.Create(self);
men.Name := 'sousmenu3';
men.Caption := '51..75';
m9.Add(men);
men := TMenuItem.Create(self);
men.Name := 'sousmenu4';
men.Caption := '76..110';
m9.Add(men);
for a:=1 to 25 do begin
men := TMenuItem.Create(self);
men.Name := 'menu'+ inttostr(a);
men.Caption := inttostr(a);
men.Tag:=a;
men.OnClick:=m9Click; // c'est là que ça plante
m9.Items[0].Add(men);
end;
for a:=26 to 50 do begin
men := TMenuItem.Create(self);
men.Name := 'menu'+ inttostr(a);
men.Caption := inttostr(a);
men.Tag:=a;
m9.Items[1].Add(men);
end;
for a:=51 to 75 do begin
men := TMenuItem.Create(self);
men.Name := 'menu'+ inttostr(a);
men.Caption := inttostr(a);
men.Tag:=a;
m9.Items[2].Add(men);
end;
for a:=76 to 110 do begin
men := TMenuItem.Create(self);
men.Name := 'menu'+ inttostr(a);
men.Caption := inttostr(a);
men.Tag:=a;
m9.Items[3].Add(men);
end;
end; |
l'erreur est
Code:
mot.pas(213,25) Error: Wrong number of parameters specified for call to "m9Click"
où me trompe-je????