Man, I thought that ActiveX was bad enough when I started
We have a database structure that defines our menus, and I thought that it would be a good idea to try and create the menu using the ultratoolbar.
Yikes.
I was looking at some vb code to try and convert it to 4GL.
given the following VB code:
Dim mainMenuBar As UltraToolbar = Me.ultraToolbarsManager1.Toolbars("MainMenuBar")
I would have thought that the 4GL code would work:
DEF VAR mainMenuBar AS Infragistics.Win.UltraWinToolbars.UltraToolbar NO-UNDO.
mainMenuBar = THIS-OBJECT:ultraToolbarsManager1:ToolBars("mainMenuBar").
however, the ABL complains that it could not locate element "ToolBars" in ultraToolbarsManager1 ....
Help help help
What I am going to try and achieve is to create a class that simplifies the creation of a menu
MyClass:AddMainMenu()
MyClass:AddSubMenu(ParentMenu)
etc etc
allowing us / me to swap out the menubar for another control if I want without having to rewrite all of the menu code in the other windows
I suspect Toolbars is a collection and that you use brackets to get an item.
DEF VAR mainMenuBar AS Infragistics.Win.UltraWinToolbars.UltraToolbar NO-UNDO.
mainMenuBar = THIS-OBJECT:ultraToolbarsManager1:ToolBars["mainMenuBar"].
Thanks! that was the solution.
Harvard is right with his assumption.
That will give you a reference a toolbar. I struggled a bit as well with the UltraToolbarsManager. In order to dynamically add items to the toolbars, you need to create two items (at least) for each tool. One item get's added to the Tools collection of the toolbars manager and the other instance needs to get added to the tools collection of the toolbar/pull down menu.
Both need to share the same key/name. The SharedProps specifies the properties for all occurences of this toolitem - so the common properties when a tool is used in a menu and on a toolbar. The InstanceProps holds private properties for the instance (like FirstInGroup etc.).
Oh, I'm starting to get the hang of this
* jmls dances a jig.
Got to the point where I can create a menu structure from the database
What I am planning on doing is creating a class that simplifies the creation of a basic menu structure. You can then play with it as much as you want.
Okay. here's the first hit. Menuloader simplifies the addition of menus and submenus to a ultratoolbar. It is very basic class so far, and I don't understand why somethings have to work the way that they do.
Any comments or help or enlightenment will help.
To use:
make sure that com.dotr.UltraToolBar is in your propath, with MenuLoader.cls in that directory.
add a Ultramenubar to a form. use the following code to add stuff:
DEF PRIVATE VAR MenuLoader AS CLASS com.dotr.UltraToolBar.MenuLoader NO-UNDO.
MenuLoader = NEW com.dotr.UltraToolBar.MenuLoader(ultraToolbarsManager1).
ASSIGN NewToolbar = MenuLoader:AddToolBar()
NewToolBar:IsMainMenuBar = YES.
ASSIGN NewMenu = MenuLoader:AddMenu(NewToolBar,"&File")
NewButton = MenuLoader:AddMenuItem(NewMenu,"&Save")
NewButton = MenuLoader:AddMenuItem(NewMenu,"&Quit")
NewButton = MenuLoader:AddMenuItem(NewMenu,"|E&xit")
NewMenu = MenuLoader:AddMenu(NewMenu,"|&Bar")
NewMenu = MenuLoader:AddMenu(NewMenu,"&Bar2")
NewMenu = MenuLoader:AddMenu(NewToolBar,"|&OOOOOOO").
MenuLoader:SaveMenu("c:\temp\foo.xml").
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/ObjectExplorerForm.cls.zip:550:0]
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/ObjectExplorerForm.resx.zip:550:0]
Next try.
This example enables you to copy a menu structure from an existing window. Change the trigger code of "run Procedure" to run any window you want persistently.
Pressing the grab menus button loops through all persistent procedures, and if they have a menubar, copies it to a new toolbar.
This does not yet copy toggle box items, nor does it add trigger code. But it is a start
You can save the layout as XML using the SaveMenu method, and you can also reload using the LoadMenu method.
As always, all comments and suggestions are most welcome. Go easy though - my first "real" .net form ....
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/6811.ObjectExplorerForm.cls.zip:550:0]
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/6648.ObjectExplorerForm.resx.zip:550:0]
Urg. Forgot to attach the files
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/MenuExample.cls:550:0]
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/MenuExample.resx:550:0]
[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/MenuLoader.cls:550:0]
Hi Julian,
I'm trying to catch up with everybody on OE10.2b and find the examples posted on this form interesting and helpfull. Unfortunatly I can't get your example to run. The error suggest I haven't referenced the correct assemlies. (Invalid datatype specified: Infragistics.Win.UltraWinToolbars.UltraToolbar. Specify a datatype such as 'character' or the name of a class. (5638)) Would you mind sharing your assemblies.xml file as well? Hopefully I will then discover what I'm missing...
Regards,
Rob.
before I do that, have you checked that the com.dotr directory is in your project's propath, and menuloader.cls is in com.dotr ?
Euh...
Maby I've made a mistake. I created my project (see attached jpg) with a UltraToolBar folder in the com.dotr namespace. This did remove a lot of compile errors. Did I get it all wrong here?
sorry, my fault. you are right.
try adding the toolbar control to the project
I'm sorry, is this what you are talking about? Or do I have to do something else?
everything seems ok. Are you still getting the errors ? In which class ?
I've just tried it at home. Different PC, all steps the same, but I only referenced System.Windows.Forms and Infragistics2.Win.UltraWinToolbars.v8.1. And now it works ok...
This is scaring me a bit. I haven't got a clue why it didn't work earlier. It doesn't sound write to me that referencing more (unused) assemblies could cause the problem.
Ps. I cannot "see" the MenuExample.cls in the visual designer. Should I?
Strange ..
MenuExample.cls should be in the designer - right-mouse click and choose "View Design" (SHIFT-F9)
You also should be in the "OpenEdge visual Designer" view in OEA
Oops, it is probably getting a bit late for me. Right clicking works fine. Up until now selecting the visual designer automatically opend files in the desiger. But I have no problem ordering OEA aroud
thanks for your help!
cool. glad you've got it working. Don't be too hard on me for the code though. Early days