Código
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, Mask, uEditCuper;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Label1: TLabel;
GroupBox1: TGroupBox;
btnMenu: TButton;
GroupBox2: TGroupBox;
Label4: TLabel;
Button2: TButton;
Edit3: TEditCuper;
MainMenu: TMainMenu;
Relatorio1: TMenuItem;
Vendas1: TMenuItem;
Produtos1: TMenuItem;
procedure btnMenuClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
Menus: array [0..50] of TMenuItem;
procedure Menu;
procedure subMenu;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Math;
{$R *.dfm}
{ TForm1 }
procedure TForm1.Menu;
var
I: Integer;
CaptionMenu: String;
begin
for I := 0 to 50 do
begin
if Assigned(Menus[I]) then
begin
if Copy(Menus[I].Caption,1,1) = '&' then
CaptionMenu := Trim(Copy(Menus[I].Caption,2,100))
else
CaptionMenu := Trim(Menus[I].Caption);
if CaptionMenu = Trim(ListBox1.Items.Strings[ListBox1.ItemIndex]) then
begin
ShowMessage('JÁ EXISTE!!');
Break;
end;
end
else
begin
Menus[I] := TMenuItem.Create(MainMenu);
Menus[I].Caption := ListBox1.Items.Strings[ListBox1.ItemIndex];
Relatorio1.Add(Menus[I]);
Break;
end;
end;
end;
procedure TForm1.subMenu;
var
I: Integer;
CaptionMenu: String;
begin
for I := 0 to 50 do
begin
if Assigned(Menus[I]) then
begin
if Copy(Menus[I].Caption,1,1) = '&' then
CaptionMenu := Trim(Copy(Menus[I].Caption,2,100))
else
CaptionMenu := Trim(Menus[I].Caption);
if CaptionMenu = Trim(ListBox1.Items.Strings[ListBox1.ItemIndex]) then
begin
ShowMessage('JÁ EXISTE!!');
Break;
end;
end
else
begin
Menus[I] := TMenuItem.Create(MainMenu);
Menus[I].Caption := ListBox1.Items.Strings[ListBox1.ItemIndex];
MainMenu.Items[0].Items[StrToInt(Edit3.Text)].Add(Menus[I]);
Break;
end;
end;
end;
procedure TForm1.btnMenuClick(Sender: TObject);
begin
Menu;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
subMenu;
end;
end.
Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009