Print Page | Close Window

How to force "Update" of CommandBar Ctrl

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=814
Printed Date: 06 June 2024 at 11:21pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to force "Update" of CommandBar Ctrl
Posted By: Boyd
Subject: How to force "Update" of CommandBar Ctrl
Date 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.




Replies:
Posted By: SuperMario
Date 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.


Posted By: Boyd
Date 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!



Posted By: SuperMario
Date Posted: 19 October 2004 at 11:35am
I will definetly pass this on to development.  I understand now.



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