如题
解决方案 »
- 在fastreport中的报表设计事件中如何改变memo框的内容?
- 如何得到一个文件的完整路径。
- 有谁做过IC卡的驱动啊
- 有没有在深圳混的兄弟,帮忙找份delphi的工作!我现在重庆,因为感情的困扰希望换个环境!谢了!qq:233018
- 怎样才能成为一位优秀的程序员?
- Delphi XE 的菜单tools-options 打不开,请高手指教
- 我想是查询日期字段中的年数为2002的所有记录。。
- 哪位有修改好的modlink for xe5 啊?
- 读文件问题!!!!!!!!!!!!!!
- 时间怎么相减?急!急!急!
- 这里有很多书!大家看一下噢up有分!
- 如何在DELPHI5下编写基于netbios会话的收发数据包的程序?
1:创建一个菜单项对象
TMEnuItem.create(nil)
2:然后通过数据库,设置这个菜单项对象的性性。比如:caption,onClick事件的处理程序
3:然后
menu1.items.add(你创建的对象)
4:完成了。。
var
act: TAction;
mnu,mnuP: TMenuItem;
obh: TmxOutlookBarHeader;
ob: TOutlookButton;
tb: TToolButton;
i: Integer;
str: string;
begin
try
ToolBar.ShowCaptions:=False;
ToolBar.AutoSize:=False;
ToolBar.ButtonHeight:=38;
ToolBar.ButtonWidth:=39;
Str:='';
for i:=0 to 127 do Str:=Str+'1';//处理超级用户 with MainDataModule.FuncDefDataSet do
begin
RemoteServer:=MainDataModule.CurConnection;
Open;
First;
while not Eof do
begin
mnu:=TMenuItem.Create(Self);
mnu.Name:=Format('TMenuItem%d',[FieldByName('ID').AsInteger]);
mnu.Tag:=FieldByName('ID').AsInteger;
if FieldByName('iParentID').AsInteger>0 then
begin
act:=TAction.Create(Self);
act.Name:=Format('TAction%d',[FieldByName('ID').AsInteger]);
act.Caption:=FieldByName('sCaption').AsString;
act.Category:=FieldByName('sCategory').AsString;
act.Hint:=FieldByName('sHint').AsString;
act.ImageIndex:=FieldByName('iImageIndex').AsInteger;
act.Visible:=(FieldByName('bVisible').AsInteger=1) and (FieldByName('bSuppermanVisible').AsInteger=0);
if FunctionStr=Str then act.Visible:=True;
act.Tag:=FieldByName('ID').AsInteger;
if act.Caption='帮助' then
act.OnExecute:=SysHelpExecute
else if act.Caption='注销登录' then
act.OnExecute:=LogoutMgrExecute
else if act.Caption='退出系统' then
act.OnExecute:=CloseSystemMgrExecute
else
act.OnExecute:=ExecuteMdiForm;
act.ActionList:=ActionList;
mnu.Action:=act;
//mnuP:=MainMenu.Items.Find(FieldByName('sCategory').AsString);
mnuP:=self.FindComponent(Format('TMenuItem%d',[FieldByName('iParentID').AsInteger])) as TMenuItem;
if act.Visible then
if FieldByName('iInOutlook').AsInteger>0 then
begin
obh:=self.FindComponent(Format('TmxOutlookBarHeader%d',[FieldByName('iParentID').AsInteger])) as TmxOutlookBarHeader;
ob:=TOutlookButton.Create(Self);
ob.Action:=act;
ob.LargeImages:=FunImageList;
ob.SmallImages:=FunImageList;
ob.ImageIndex:=act.ImageIndex;
ob.Caption:=FieldByName('sOutlookCaption').AsString;
obh.AddButton(ob);
end;
if act.Visible then
if FieldByName('bInToolbar').AsInteger=1 then
begin
tb:=TToolButton.Create(ToolBar);
tb.Name:=Format('TToolButton%d',[FieldByName('ID').AsInteger]);
tb.AutoSize:=False;
//tb.Parent:=ToolBar;
tb.Action:=act;
//tb.:=tbIndex;
end;
end
else begin
mnu.Caption:=FieldByName('sCaption').AsString;
mnuP:=MainMenu.Items;
if FieldByName('iInOutlook').AsInteger=0 then
begin
obh:=TmxOutlookBarHeader.Create(Self);
obh.Name:=Format('TmxOutlookBarHeader%d',[FieldByName('ID').AsInteger]);
obh.Caption:=FieldByName('sOutlookCaption').AsString;
obh.Color:=15002091;
OutlookBar.AddHeader(obh);
end;
end;
mnuP.Add(mnu);
if (FieldByName('bHasLine').AsInteger=1) and mnu.Visible then
begin
mnu:=TMenuItem.Create(Self);
mnu.Caption:='-';
mnuP.Add(mnu);
end;
//ActionManager.AddCategory()
Next;
end;
for i:=ToolBar.ComponentCount-1 downto 0 do
(ToolBar.Components[i] as TToolButton).Parent:=ToolBar;
end;
finally
ToolBar.ShowCaptions:=False;
ToolBar.AutoSize:=False;
ToolBar.ButtonHeight:=38;
ToolBar.ButtonWidth:=39;
OutlookBar.ActiveHeader:=OutlookBar.GetHeaderByIndex(0);
end;end;