6 Replies Latest reply on Mar 10, 2016 1:57 PM by mjohnson

    How to change the MenuBar in DxDesigner with Automation

    thomas.schmid

      I try to change the menu to our company-requirements, some commands should be removed and some commands (e.g. own automation skripts) should be added.

      My Problem is that at the first Level of the Menu (Type CommandBarSvr.CommandBarControl) there is no .count or .item

      so that i can't get deeper into the Menu-hierarchy to delete or add a control.

       

      Here is my sample code from vb.net:

       

      Dim _dx As CVdApp = Nothing

      Dim menu As CommandBarSvr.CommandBar


      _dx = CType(GetObject(, "ViewDraw.Application"), CVdApp)

      menu = _dx.CommandBars().Item("Sheet Menu Bar")


      Dim CommandBar As CommandBarSvr.CommandBarControls = menu.Controls

      Dim MainMenu As CommandBarSvr.CommandBarControl

       

      For i As Integer = 1 To CommandBar.Count Step 1

           MainMenu = CommandBar.Item(i)

           Debug.Print(MainMenu.Caption)

      Next

       

       

      I hope someone could tell me more about the DxDesigner Menu-Automation, in Expedition it works fine with Automation.

       

      Thanks

      Thomas Schmid

        • 1. Re: How to change the MenuBar in DxDesigner with Automation
          john_dube

          Hi Thomas,

           

          Use the Controls property to get the elements of a popup menu:

           

          For i As Integer = 1 To CommandBar.Controls.Count Step 1

               MainMenu = CommandBar.Controls.Item(i)

               Debug.Print(MainMenu.Caption)

          Next

           

           

          John

          • 2. Re: How to change the MenuBar in DxDesigner with Automation
            thomas.schmid

            Thanks John,

             

            that was the trick...

             

            Is there a way to get the ID from a MenuControl, like in Expedition?

             

            Need this when i delete a MenuControl to create a new MenuControl at a other location.

             

            In Expedition we have a Skript that removes unwanted entries for our Users, in case of support

            we create a "Admin-menu" after a Admin-Login Dialog with all the removed entries.

             

            Thomas

            • 3. Re: How to change the MenuBar in DxDesigner with Automation
              thomas.schmid

              Here a short overview what I discovered with the automation of Commandbars.


              The first problem I had was the intelliSense of VisualStudio and vb.net. The Collection of vdapp.CommandBars is from type CommandBars.

              This CommandBars object has no Count, I found no way to get a information what Elements are in this Collection.

              I found in a Example (Example1: Create/Add Menus) that the CommandBar I need is called "Sheet Menu Bar".

              With try and error I found that the other CommandBar I need is called "Main Menu Bar".

              How can I find the Names of the other elements?


              The second Problem was that the object CommandBars.item("Sheet Menu Bar") is from type CommandBar and IntelliSense only

              shows "Controls" as possible objectCollection in CommandBar.

              So far so good, that Controls is a collection with methods add, item and property count.

              The item is from type Control and has only a property Caption and a method delete.

              How can I find Elements deeper in the Menu?

               

              How it works for me:


              First thanks to John Dube for showing me a bit of the right way...


              My Problem is that I found no Documenation what types are used in the CommandBars.

              Searching with intelliSense showed me that there are the types:

              CommandBars
              
              CommandBar
              CommandBarControls
              
              CommandBarControl
              CommandBarButton
              
              CommandBarPopup
              I had to try what type worked with which element.
              I got the right Methods and properties when I Cast the Type to "CommandBarButton" or "CommandBarPopup".

              PLEASE MENTOR GIVE US MORE DOCUMENTATION.

              The third Problem was that I can add or delete entrys in the Menu, but the properties Tooltip and Bitmap does not work properly.
              How can I add a Tooltip and how can I add a Bitmap to my own entrys?

              The last Problem I have at the moment is that I can't get any information of existing entrys.
              I tried to get the Caption, Id, Bitmap, Tooltip etc. from Menu-Controls. Only empty entrys.
              How can I get information from existing controls?

              Greets
              Thomas
              1 of 1 people found this helpful
              • 4. Re: How to change the MenuBar in DxDesigner with Automation
                Patrick.Cashman
                PLEASE MENTOR GIVE US MORE DOCUMENTATION.

                 

                 

                Echo that X 1000.

                 

                And make it correct. And complete.

                 

                I have lost count of the number of times I've encountered documentation that is incomplete or wrong about much of the Automation functionality. There are many functions for which there is no documentation, and there are many kinds of collections that when used as collections, cannot be enumerated or are not even recognized as collections.

                • 5. Re: How to change the MenuBar in DxDesigner with Automation
                  thomas.schmid

                  Hello again,

                   

                  now the new Release VX.1 is out and i have to check if our problems are solved.

                  Has anybody customized the xDxDesigner menu and toolbars yet?

                   

                  Greets

                  Thomas

                  • 6. Re: How to change the MenuBar in DxDesigner with Automation
                    mjohnson

                    Bump. I am still trying to figure out graceful ways of getting through CommandBars. I got the updated VX documentation from Mentor, and it still lacks this information. CommandBars still doesn't support Count, so I can't iterate through the various menus easily.

                     

                    How can I get a list of all the CommandBars in the environment?