unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, DB, ADODB;
type
TForm1 = class(TForm)
con1: TADOConnection;
mm1: TMainMenu;
N11: TMenuItem;
N12: TMenuItem;
N31: TMenuItem;
N41: TMenuItem;
N51: TMenuItem;
N61: TMenuItem;
N561: TMenuItem;
N71: TMenuItem;
N72: TMenuItem;
N81: TMenuItem;
N91: TMenuItem;
btn1: TButton;
mmo1: TMemo;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure GetMenu(AIndex: string; Menu: TMenuItem);
procedure SaveMenu(Index: string;Menu: TMenuItem);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.GetMenu(AIndex: string; Menu: TMenuItem);
var i: integer;
begin
for i := 0 to Menu.Count - 1 do
begin
if Menu.Items[i].Count = 0 then
SaveMenu(AIndex + IntToStr(i + 1) ,Menu.Items[i])
else
GetMenu(AIndex + IntToStr(i + 1), Menu.Items[i]);
end;
end;
procedure TForm1.SaveMenu(Index: string;Menu: TMenuItem);
begin
mmo1.Lines.Add('Insert into ZDMenu (MENUID, MENUNAME, C_TAG) values (' + QuotedStr(Index) + ','
+ QuotedStr(Menu.Caption) + ',' + IntToStr(Menu.Tag) + ')');
end;
procedure TForm1.btn1Click(Sender: TObject);
var i: integer;
begin
mmo1.Clear;
for i := 0 to mm1.Items.Count - 1 do
begin
GetMenu(IntToStr(i + 1), mm1.Items[i]);
end;
end;
end.
object Form1: TForm1
Left = 309
Top = 143
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
Menu = mm1
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object btn1: TButton
Left = 32
Top = 120
Width = 75
Height = 25
Caption = 'btn1'
TabOrder = 0
OnClick = btn1Click
end
object mmo1: TMemo
Left = 192
Top = 24
Width = 473
Height = 377
Lines.Strings = (
'mmo1')
TabOrder = 1
end
object con1: TADOConnection
Left = 256
Top = 224
end
object mm1: TMainMenu
Left = 144
Top = 72
object N11: TMenuItem
Caption = '1'
object N12: TMenuItem
Caption = '1'
end
object N31: TMenuItem
Caption = '3'
end
end
object N41: TMenuItem
Caption = '4'
object N51: TMenuItem
Caption = '5'
end
object N61: TMenuItem
Caption = '6'
end
end
object N561: TMenuItem
Caption = '56'
object N71: TMenuItem
Caption = '7'
end
object N72: TMenuItem
Caption = '7'
object N81: TMenuItem
Caption = '8'
end
object N91: TMenuItem
Caption = '9'
end
end
end
end
end