unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, StdCtrls;

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    MainMenu2: TMainMenu;
    aaaa1: TMenuItem;
    bbbb1: TMenuItem;
    cccc1: TMenuItem;
    ddddd1: TMenuItem;
    eeee1: TMenuItem;
    zzzzz1: TMenuItem;
    xxxxx1: TMenuItem;
    yyyyy1: TMenuItem;
    wwwww1: TMenuItem;
    pppppp1: TMenuItem;
    Label1: TLabel;
    Button1: TButton;
    Button2: TButton;
    MainMenu3: TMainMenu;
    Opcja01: TMenuItem;
    Polecenie11: TMenuItem;
    Polecenie21: TMenuItem;
    Polecenie31: TMenuItem;
    Opcja11: TMenuItem;
    Opcja21: TMenuItem;
    Polecenie41: TMenuItem;
    N1: TMenuItem;
    Polecenie51: TMenuItem;
    Polecenie61: TMenuItem;
    Polecenie71: TMenuItem;
    Podmenu11: TMenuItem;
    Podmenu21: TMenuItem;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure bbbb1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.bbbb1Click(Sender: TObject);
begin
  if Sender is TMenuItem then
     Label1.Caption:=(Sender as TMenuItem).Caption;
     //lub inaczej Label1.Caption:=TMenuItem(Sender).Caption;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Menu:=MainMenu3;
end;

procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
//wyświetlenie numerów poleceń dla Opcji0
  label1.Caption:=#13+'Opcja0';
  for i:=0 to Opcja01.Count-1 do
Label1.Caption:=Label1.Caption+#13+IntTostr(Opcja01.Items[i].MenuIndex);

//wyświetlenie numerów poleceń dla Opcji1
   label1.Caption:=label1.Caption+#13+'Opcja1';
   for i:=0 to Opcja11.Count-1 do
Label1.Caption:= Label1.Caption + #13+inttostr(Opcja11.Items[i].MenuIndex);

// Opcja2 nie ma poleceń

//wyświetlenie numerów poleceń podmenu dla Polecenia5
   label1.Caption:=label1.Caption+#13 
                   +'Polecenie5';
   for i:=0 to Polecenie51.Count-1 do
  Label1.Caption:=label1.Caption+#13+IntToStr (Polecenie51.Items[i].MenuIndex);

end;

end.
