Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - DesignerControls.Find gets single instanc
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

DesignerControls.Find gets single instanc

 Post Reply Post Reply
Author
Message
dajv View Drop Down
Groupie
Groupie


Joined: 27 July 2004
Location: Australia
Status: Offline
Points: 80
Post Options Post Options   Thanks (0) Thanks(0)   Quote dajv Quote  Post ReplyReply Direct Link To This Post Topic: DesignerControls.Find gets single instanc
    Posted: 31 August 2004 at 1:59am
Gday,

I'm using Designer Studio to create my command bars menus, and have used multiple instances of controls. Some controls in the main menu of my application also appear in context menus.

To modify the control i get a control instance as in:

Dim Control as CommandBarControl
Set Control = CommandBars.DesignerControls.find(, MenuItemID, , True)


and use the Control instance to change properties...
Control.Visible = False


When I do this, it only affects one of the instances of the controls with id MenuItemID, so an item that appears in one of the main menus as well as a context menu only gets removed (using visible = false) in the main menu, and the instance in the context menu is not affected.

How do i get a reference to the other instances of the control (the one in the context menu)?

I want to avoid having a seperate control for each context menu item because this will add alot of controls and their operation is exactly the same as the instance in the main menu. When the control is removed from the main menu, i want that control also removed from the context menu (the behaviour i expected initially).

Any advice is appreciated.

Thanks
Back to Top
dajv View Drop Down
Groupie
Groupie


Joined: 27 July 2004
Location: Australia
Status: Offline
Points: 80
Post Options Post Options   Thanks (0) Thanks(0)   Quote dajv Quote  Post ReplyReply Direct Link To This Post Posted: 31 August 2004 at 2:14am
I realised that I can Find() the controls inside the popup menu and set their properties.

Dim Popup As CommandBarPopup

Set Popup = CommandBars.DesignerControls.Find(, ID_CONTEXT_ITEM, , True)
Set Control = Popup.CommandBar.Controls.Find(, MenuItemID, , True)
Back to Top
dajv View Drop Down
Groupie
Groupie


Joined: 27 July 2004
Location: Australia
Status: Offline
Points: 80
Post Options Post Options   Thanks (0) Thanks(0)   Quote dajv Quote  Post ReplyReply Direct Link To This Post Posted: 31 August 2004 at 9:46pm
Further to my above situation, I am having trouble getting a reference to toolbar buttons that also appear in the main menu.

Again, I want to avoid having a seperate control for the instance that will go in the toolbar.

I first tried using the below:
CommandBars.DesignerControls.Find(, IDR_STANDARDTEST, , True)

(where IDR_STANDARDTEST is the id of the toolbar containing the controls) but this doesn't work (and after reading other posts, i discovered that top-level menus (in this case a toolbar) can't be accessed through the find() methods.

I then tried looping through the controls in the CommandBars.DesignerControls collection and couldn't find IDR_STANDARDTEST anywhere, nor could i find the controls that have hte toolbar as their parent, so it appears the method above i used for getting a reference to the controls used in the popup isnt going to work with the toolbar.

I examined the Control.Parent.BarID of the controls in the toolbar (a msgbox in the Execute() event) and noticed that the parent is IDR_STANDARDTEST, so they're there somewhere...

Must I resort to having unique controls for the toolbar?

Any advice is appreciated.
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: 01 September 2004 at 6:41am
Top level controls can be accessed with the find method.  You must manually assign an Id to these controls.  I.E (File, Edit, View, Tools, etc... are generally top level controls that display other menu items when clicked) .

The DesignerControls collection of commands only holds commands that are displayed in the "Commands" tab of the Add\remove buttons customize dialog.  This collection is designed to hold all of your application's controls so the user can add\remove them as needed.   You need to manually add the controls to the collection, and you should do this in the Customization event.  You are looking in the wrong place if you want to find a control in the toolbar or menubar.

No, you do not need unique controls for the toolbar.  Just make sure that you manually assign an Id to any control that is a popup.

When searching, try something like this:

'Searches for the first occurence of Id in all commandbars starting with the menubar
Commandbars.Find(,ID,True) 
'Searches for the first occurence of Id in the activemenubar
CommandBars.ActiveMenuBar(,ID,True)
'or CommandBars(1).Find(,ID,True)
'Searches for the first occurence of Id of a top level control in the activemenubar
CommandBars.ActiveMenuBar(,ID)
'Searches for the first occurence of Id in first toolbar
CommandBars(2).Find(,ID,True)

Hope this helps
Back to Top
dajv View Drop Down
Groupie
Groupie


Joined: 27 July 2004
Location: Australia
Status: Offline
Points: 80
Post Options Post Options   Thanks (0) Thanks(0)   Quote dajv Quote  Post ReplyReply Direct Link To This Post Posted: 01 September 2004 at 5:47pm
CommandBars(2).FindControl(, ID, , True) is just what i needed, thanks alot!

Back to Top
Jens4 View Drop Down
Groupie
Groupie
Avatar

Joined: 11 June 2004
Location: Denmark
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jens4 Quote  Post ReplyReply Direct Link To This Post Posted: 07 December 2004 at 7:37am

I have nearly the same problem, one of my customers has made his own toolbar by the custom-dialog, he has added the same control twice….

 

I have a function that “check” the toolbar button, and in that function I use the FindContol, but I only give me the button……

 

The tow buttons have offcures the same ID, because the user just drags then same control to the same bar.

 

I know it is strange to have the same control on the same bar… but you know users….

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 8:14am
Mabye use a  "For each" to look through ALL your controls in each command bar.  FindControl will only find first occurance no matter what.

But better yet, since the controls will have Id, you can set up a global variable used to indicate when the control should be checked/unchecked, then in the CommandBars_Update event you can use this variable to decide whether to check the control.

'Global variable
Dim bCheckControl as Boolean

Private Sub CommandBars_Update(ByVal Control As XtremeCommandBars.ICommandBarControl)
  
  On Error Resume Next
  Select Case Control.Id
    Case ID_APP_ABOUT: Control.Checked = bCheckControl
    Case ID_FILE_NEW:  Control.Checked = bCheckControl
  End Select
End Sub
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.172 seconds.