Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - How to force "Update" of CommandBar Ctrl
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to force "Update" of CommandBar Ctrl

 Post Reply Post Reply
Author
Message
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Topic: How to force "Update" of CommandBar Ctrl
    Posted: 08 June 2004 at 10:01am

I use the 'Update' event of CommandBars to determine when controls should be enabled and set various other properties.  I also use the 'Execute' event for most of my actions.

I came across the need to "trigger" the Execute event for a control that was not necessarily clicked upon.  For instance, I have certain internal shortcut keys that will trigger a command without using KeyBindings (this was done by design since KeyBindings intercepts all shortcut keys).  I created the following routine to trigger the execution of a command based on the ID of the command bar control:

Public Sub ExecuteCommandBarControl(ByRef CommandBars As CommandBars, ByVal ID As Long)
  Dim TempBar As CommandBar, Control As CommandBarControl
  If CommandBars Is Nothing Then Exit Sub
  Set TempBar = CommandBars.Add("Temp", xtpBarPopup)
  Set Control = TempBar.Controls.Add(xtpControlButton, ID, "Temporary")
  Control.Execute
End Sub

This results in the Execute event being fired.  The problem is that this temporary control never gets passed to the 'Update' event because it is never shown.  Is there a way to force the command to update?  If not, would it be possible to add an 'Update' method to the CommandBarControl that would trigger the 'Update' event?  Then would allow me to modify the procedure to only execute the control if the control is enabled (as is set in the Update event).  In other words, this is what I would like to be able to do:

Public Sub ExecuteCommandBarControl(ByRef CommandBars As CommandBars, ByVal ID As Long)
  Dim TempBar As CommandBar, Control As CommandBarControl
  If CommandBars Is Nothing Then Exit Sub
  Set TempBar = CommandBars.Add("Temp", xtpBarPopup)
  Set Control = TempBar.Controls.Add(xtpControlButton, ID, "Temporary")
  Control.Update
  If Control.Enabled Then Control.Execute
End Sub

Thanks in advance.

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: 19 October 2004 at 11:22am
For any new users that might read this post, an Execute method was added that will allow you to execute individual controls.
Back to Top
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Posted: 19 October 2004 at 11:30am

SuperMario,

If you look at the original post, it actually uses the Execute method.  The code snippet was provided so that you could trigger the execution of a control based purely on the ID of the control without having to search for that control in a command bar.  Look closely and it will make more sense.

As you may have noticed, nobody ever responded to my request for an Update method to accompany the Execute method.  Any chance of getting something like this added?

Thanks!

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: 19 October 2004 at 11:35am
I will definetly pass this on to development.  I understand now.
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.