Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - CommandBars.Controls Collection (9.5.1.0)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CommandBars.Controls Collection (9.5.1.0)

 Post Reply Post Reply
Author
Message
Anite.DRC View Drop Down
Newbie
Newbie


Joined: 12 November 2004
Location: United Kingdom
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Anite.DRC Quote  Post ReplyReply Direct Link To This Post Topic: CommandBars.Controls Collection (9.5.1.0)
    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
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post 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.

Edited by SuperMario
Back to Top
Anite.DRC View Drop Down
Newbie
Newbie


Joined: 12 November 2004
Location: United Kingdom
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Anite.DRC Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Gutauckis View Drop Down
Newbie
Newbie


Joined: 06 December 2004
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gutauckis Quote  Post ReplyReply Direct Link To This Post 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.



Edited by Gutauckis
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Gutauckis View Drop Down
Newbie
Newbie


Joined: 06 December 2004
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gutauckis Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.