根据主菜单生成脚本

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

linzhisong

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值