DesignerControls.Find gets single instanc |
Post Reply |
Author | ||
dajv
Groupie Joined: 27 July 2004 Location: Australia Status: Offline Points: 80 |
Post Options
Thanks(0)
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:
and use the Control instance to change properties...
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 |
||
dajv
Groupie Joined: 27 July 2004 Location: Australia Status: Offline Points: 80 |
Post Options
Thanks(0)
|
|
I realised that I can Find() the controls inside the popup menu and set their properties.
|
||
dajv
Groupie Joined: 27 July 2004 Location: Australia Status: Offline Points: 80 |
Post Options
Thanks(0)
|
|
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:
(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. |
||
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
|
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 |
||
dajv
Groupie Joined: 27 July 2004 Location: Australia Status: Offline Points: 80 |
Post Options
Thanks(0)
|
|
CommandBars(2).FindControl(, ID, , True) is just what i needed, thanks alot!
|
||
Jens4
Groupie Joined: 11 June 2004 Location: Denmark Status: Offline Points: 17 |
Post Options
Thanks(0)
|
|
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…. |
||
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
|
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 |
||
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |