unigui菜单
Posted usegear
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了unigui菜单相关的知识,希望对你有一定的参考价值。
unigui菜单TuniTreeView
根据数据库表中的内容,显示菜单的处理:
function TMainForm.CreateMenu: Integer; var myMenuPoint : PMyMenuRec; i :Integer; menu_id ,menu_name, menu_url: string; mynodes : TUniTreeNodes; mynode,tmp_node : TUniTreeNode; begin //建立菜单树 MenuTree.Items.Clear; mynodes := MenuTree.Items; MenuTree.BeginUpdate; with UniMainModule do begin //取表中菜单 fdqryBase.Open(‘select* from sm_menu order by menu_id‘); fdqryBase.First; while not fdqryBase.Eof do begin menu_id := fdqryBase.FieldByName(‘menu_id‘).AsString; menu_name := fdqryBase.FieldByName(‘menu_name‘).AsString; if fdqryBase.FieldByName(‘menu_url‘).AsString = ‘‘ then begin //确认是否根菜单 mynode := mynodes.Add(nil,fdqryBase.FieldByName(‘menu_name‘).AsString); end else begin tmp_node := mynodes.add(mynode,menu_name); New(myMenuPoint); myMenuPoint^.menu_id := menu_id; myMenuPoint^.menu_name := menu_name; myMenuPoint^.menu_url := fdqryBase.FieldByName(‘menu_url‘).AsString; tmp_node.Data := myMenuPoint; end; fdqryBase.Next; end; end; MenuTree.EndUpdate; for i := 0 to MenuTree.Items.Count-1 do begin mynode := MenuTree.Items[i]; if mynode.HasChildren then begin mynode.ImageIndex := 0; mynode.SelectedIndex := 0; end else begin mynode.ImageIndex := 2; mynode.SelectedIndex := 3; end; end; MenuTree.FullCollapse; end;
其中item的node有二个属性caption和data。把指针data用起来,在点击时自动调用显示form。
type PMyMenuRec = ^TMyMenuRec; TMyMenuRec = Record menu_id:string; menu_name:string; menu_url:string; end;
点击菜单项的处理
procedure TMainForm.MenuTreeClick(Sender: TObject); begin if Assigned(MenuTree.Selected.data) then begin if PMyMenuRec(MenuTree.Selected.data).menu_url<>‘‘ then ShowFrame(PMyMenuRec(MenuTree.Selected.data).menu_name,PMyMenuRec(MenuTree.Selected.data).menu_url); end; end;
以上是关于unigui菜单的主要内容,如果未能解决你的问题,请参考以下文章
unigui不是单个网页相应的链接,而是整体Web Application,如何把webApp的子功能映射到微信公众号菜单?