Print Page | Close Window

CommandBars.Controls Collection (9.5.1.0)

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=1400
Printed Date: 12 December 2024 at 4:26am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CommandBars.Controls Collection (9.5.1.0)
Posted By: Anite.DRC
Subject: CommandBars.Controls Collection (9.5.1.0)
Date Posted: 12 November 2004 at 10:04am

Hi all,

I'm currently running the eval version of the AX Suite (9.5.1.0) and have been doing preliminary conversion wirk on one of our aexisting applications. Wondering if you can point me in the direction with the following query.

The Menu (Abstract)

 File
   Open
   Close
   -----------
   Change Item -> Item A
                  Item B
                  Item C
   -----------
   Exit

I am attempting to access the collection of items below the 'Change Item' menu, but I seem to be missing part of my brain.


Dim oCommandBarControl As CommandBarControl
Set oCommandBarControl = Me.CommandBars.FindControl(, ID_CHANGEITEM, , True)

So far so good, this gets me to the 'Change Item' control.  However, by looking at the 'Controls Collection' of this item I am confronted with the following:-

'Open', 'Close', 'Change Item' and 'Exit'.  Logically this is quite incorrect, as collection property of an item should not refer to its own siblings.

What am I missing?

I want to do this:-

Dim oCommandBarControl As CommandBarControl
Set oCommandBarControl = Me.CommandBars.FindControl(, ID_CHANGEITEM, , True)
Call oCommandBarControl.Controls.DeleteAll

Thank you in advance.



-------------
Regards
Dave



Replies:
Posted By: SuperMario
Date Posted: 12 November 2004 at 10:47am
Dim oCommandBarControl As CommandBarPopup
Set oCommandBarControl = Me.CommandBars.FindControl(, ID_CHANGEITEM, , True)
Call oCommandBarControl.CommandBar.Controls.DeleteAll


Collection is the collection of controls the the current control belongs to, so Open, Close, Change Item, and Exit are all in the "File" controls commandbar.controls collection.

So oCommandBarControl.Controls will retreive all the sibling controls to the current control.


Posted By: Anite.DRC
Date Posted: 12 November 2004 at 11:03am

@SuperMario

Thanks for that SM,

I would not have thought to get to the collection via that route, the hierachy of the CommandBars is a little different than existing collection based controls we have in our applications at present. The example has saved me an immense amount of time, I thank you.



-------------
Regards
Dave


Posted By: Gutauckis
Date Posted: 06 December 2004 at 7:46pm
I have tried the above code in my app as i am trying to do the same thing but it does not work.

At app startup I create the following:

    Set ControlEdit = frmMain.CommandBars.ActiveMenuBar.Controls.Add(xtpControl Pop up, 0, "&Edit", -1, False)
    With ControlEdit.CommandBar.Controls
       
        Set Control = .Add(xtpControlPopup, ID_EDIT_MENU_UNDO, "&Undo", -1, False)
         & ;nbs p;  Control.CommandBar.Controls.Add xtpControlButton, ID_EDIT_UNDO, "Nothing to Undo", -1, False
       
        Set Control = .Add(xtpControlPopup, ID_EDIT_MENU_REDO, "&Redo", -1, False)
         & ;nbs p;  Control.CommandBar.Controls.Add xtpControlButton, ID_EDIT_REDO, "Nothing to Redo", -1, False
       
      
        Set Control = .Add(xtpControlButton, ID_EDIT_CUT, "Cu&t", -1, False)
        Control.BeginGroup = True
        .Add xtpControlButton, ID_EDIT_COPY, "&Copy", -1, False
        .Add xtpControlButton, ID_EDIT_PASTE, "&Paste", -1, False
        .Add xtpControlButton, ID_EDIT_PASTENEWIMAGE, "Paste as &New Image", -1, False
    End With

I need to get access to the Undo and Redo popup menu items to add and delete items on the fly.
When I try to:

Dim oCommandBarControl As CommandBarPopup
Set oCommandBarControl = Me.CommandBars.FindControl(,  ID_EDIT_MENU_UNDO, , True)
Call oCommandBarControl.CommandBar.Controls.DeleteAll

The set returns Nothing
I have tried a number of things but nothing is working. I notice when the app is starting up and I am creating the items they do not contain the ID I am assigning them. However my execute code works on all my controls so I am assuming the ID is set later in the startup....

Any help would be appreciated. I am using Xtreme Suite.



Posted By: SuperMario
Date Posted: 07 December 2004 at 6:25am
Manually set the Id for popup controls:

     Set Control = .Add(xtpControlPopup, ID_EDIT_MENU_UNDO, "&Undo", -1, False)
     Control.Id = ID_EDIT_MENU_UNDO
     Control.CommandBar.Controls.Add xtpControlButton, ID_EDIT_UNDO, "Nothing to Undo", -1, False
       
     Set Control = .Add(xtpControlPopup, ID_EDIT_MENU_REDO, "&Redo", -1, False)
     Control.Id = ID_EDIT_MENU_REDO
     Control.CommandBar.Controls.Add xtpControlButton, ID_EDIT_REDO, "Nothing to Redo", -1, False


Posted By: Gutauckis
Date Posted: 07 December 2004 at 7:06am
I am guessing I don't have to tell you how annoying your answer is.  Yes that worked.

Was there something in the documentation that I missed telling me that passing the Id of the control in the .add method does nothing that you have to subsequently set the id after creation?


Posted By: SuperMario
Date Posted: 07 December 2004 at 7:12am
Annoying?  .....Anyway, I believe it is documented in one of the tutorials.  The help documentation is in the process of a major rework over the next few releases.  You must only do this for popup controls.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net