zoukankan      html  css  js  c++  java
  • 给动态创建的TREE和MAINMENU关联点击事件

    使用递归方法遍历MAINMENU的所有菜单项

    procedure   TFormMain.BLMenu;
        procedure   GetItems(AItem:TMenuItem);
        var
            I:integer;
        begin
            AItem.OnClick := MenuTreeClick;      //菜单项关联点击事件
            for   I:=0   to   AItem.Count-1   do   begin
                GEtItems(AItem.Items[I]);
            end;
        end;
    var
        I:integer;
    begin
        for   I:=0   to   MainMenu1.Items.Count-1   do   begin
            GetItems(MainMenu1.Items.Items[I]);
        end;
    end;

    公用的点击事件处理方法

    procedure TFormMain.MenuTreeClick(Sender: TObject);
    begin
      if Sender is TTreeView then     // 通过SENDER来判断是点击了菜单项还是树的节点
        todo(TTreeView(Sender).Selected.Text)
      else if Sender is TMenuItem then
        todo(StripHotkey(TMenuItem(Sender).Caption));
    end;

    公用打开子窗体方法

    procedure TFormMain.openForm(AFormClass: TFormClass; var aForm: TForm;
      aOwner: TWinControl);
    begin
      if aOwner = nil then Exit;
      if aForm = nil then
        aForm := AFormClass.Create(aOwner);
      with aForm do
      begin
        ManualDock(aOwner);
        WindowState := wsMaximized;
        Align := alClient;
        Show;
      end;
    end;

    点击事件的处理方法

    procedure TFormMain.todo(const aCaption: string);
    begin
      if Pos('数据字典', acaption) <> 0 then begin
        if ActiveExistTabsheet('数据字典') then Exit;
        openForm(TformDictionary, tform(formdictionary), GetTabSheet('数据字典'));
      end else if Pos('系统菜单', aCaption) <> 0 then begin
        if ActiveExistTabsheet('系统菜单') then Exit;
        openForm(Tformmenu, tform(formMenu), GetTabSheet('系统菜单'));
      end else if Pos('货品类别管理', aCaption) <> 0 then begin
        if ActiveExistTabsheet('货品类别管理') then Exit;
        openForm(TformCategory, tform(formCategory), GetTabSheet('货品类别管理'));
      end else if Pos('操作员管理', aCaption) <> 0 then begin
        if ActiveExistTabsheet('操作员管理') then Exit;
        openForm(TFormOperator, tform(FormOperator), GetTabSheet('操作员管理'));
      end;                     
    end;

  • 相关阅读:
    Effective.Java第67-77条(异常相关)
    淘宝店的图片哪里来的
    SEO高手在扯蛋?
    多少人,没能熬过那最初的三厘米!
    网站要提高权重要总结三点
    真正的干货是什么?
    google打不开怎么办?谷歌打不开的解决方法
    StatCounter
    教你如何抢注一个快过期的域名
    正确识别希捷Backup Plus新睿品1TB正品,杜绝奸商猖獗
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940683.html
Copyright © 2011-2022 走看看