You should be able to work it out from how I work with the Designer menus in this code:
procedure TnxRBDesignerEngine.InitializeDesignerMenus; var lMenuBar : TppMenuBar; lFileMenu : TppTBCustomItem; lDesignerMenu : TppDesignerMenu; lDataFileMenu : TdaDataFileMenu; lCodeFileMenu : TraCodeManagerMenu; begin
// each notebook page can have a menu bar, this returns the menu bar for the // active notebook page lMenuBar := Designer.Form.MainMenu;
case Designer.Form.Notebook.ActivePageIndex of 0 : begin
lFileMenu := lMenuBar.Items[0];
if (lFileMenu is TdaDataFileMenu) then begin lDataFileMenu := TdaDataFileMenu(lFileMenu); // lDataFileMenu.Close.Visible := DebugHook <> 0; lDataFileMenu.Close.Caption := 'Refresh Data Fields'; lDataFileMenu.Close.OnClick := DoDataModuleFieldsRefresh; end; end;
1 : if (lMenuBar is TraCodeManagerMenu) then begin lCodeFileMenu := TraCodeManagerMenu(lMenuBar); lCodeFileMenu.FileMenu.Close.Visible := False; end;
2 : if (lMenuBar is TppDesignerMenu) then begin lDesignerMenu := TppDesignerMenu(lMenuBar); lDesignerMenu.FileMenu.Close.Visible := False; Designer.AllowSaveToFile := False; // lDesignerMenu.FileMenu.SaveToFile.Visible := False; // lDesignerMenu.FileMenu.LoadFromFile.Visible := False; lDesignerMenu.HelpMenu.visible := False; end;
The SaveToFile and LoadFromFile options are initialized right when the file menu is clicked which is why your alterations are having no effect.
You can hide/show these options using the Designer.AllowSaveToFile property.
If you would like to alter the captions, I suggest using the language translation application as all captions are loaded from our language resource files. See more information in the \RBuilder\Language\.. directory.
Comments
menus in this code:
procedure TnxRBDesignerEngine.InitializeDesignerMenus;
var
lMenuBar : TppMenuBar;
lFileMenu : TppTBCustomItem;
lDesignerMenu : TppDesignerMenu;
lDataFileMenu : TdaDataFileMenu;
lCodeFileMenu : TraCodeManagerMenu;
begin
// each notebook page can have a menu bar, this returns the menu bar
for the
// active notebook page
lMenuBar := Designer.Form.MainMenu;
case Designer.Form.Notebook.ActivePageIndex of
0 :
begin
lFileMenu := lMenuBar.Items[0];
if (lFileMenu is TdaDataFileMenu) then
begin
lDataFileMenu := TdaDataFileMenu(lFileMenu);
// lDataFileMenu.Close.Visible := DebugHook <> 0;
lDataFileMenu.Close.Caption := 'Refresh Data Fields';
lDataFileMenu.Close.OnClick := DoDataModuleFieldsRefresh;
end;
end;
1 : if (lMenuBar is TraCodeManagerMenu) then
begin
lCodeFileMenu := TraCodeManagerMenu(lMenuBar);
lCodeFileMenu.FileMenu.Close.Visible := False;
end;
2 : if (lMenuBar is TppDesignerMenu) then
begin
lDesignerMenu := TppDesignerMenu(lMenuBar);
lDesignerMenu.FileMenu.Close.Visible := False;
Designer.AllowSaveToFile := False;
// lDesignerMenu.FileMenu.SaveToFile.Visible := False;
// lDesignerMenu.FileMenu.LoadFromFile.Visible := False;
lDesignerMenu.HelpMenu.visible := False;
end;
end;
end;
In addition to Paul's code, the following article/example will also help
you customize the Designer menu.
http://www.digital-metaphors.com/rbWiki/End-User/Designer/How_To...Customize_Designer_Menu_and_Toolbars
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
before they are made :-)
Nico Cizik (Digital Metaphors) schrieb am 24.09.2015 :
except for
- lDesignerMenu.FileMenu.SaveToFile
- lDesignerMenu.FileMenu.LoadFromFile
Neither setting visible nor changing caption works.
Any ideas why?
I make my changes in Form.OnCreate where a TppDesigner is placed within
the form.
Any known issues?
Am 24.09.2015, Nico Cizik (Digital Metaphors) vermutete :
The SaveToFile and LoadFromFile options are initialized right when the
file menu is clicked which is why your alterations are having no effect.
You can hide/show these options using the Designer.AllowSaveToFile property.
If you would like to alter the captions, I suggest using the language
translation application as all captions are loaded from our language
resource files. See more information in the \RBuilder\Language\..
directory.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com