Posted 18 years ago by Bill Jacquot
Avatar
What is the mechanism in BarCommand that asks it to update its Enabled state? I'm accustomed to MFC like mechanisms where the commands are told to update their Enabled state during AppIdle. In my particular case, each command needs to make a call into unmanaged code to determine whether or not the command should be enabled. I'm subclassing BarButtonCommand and I thought I could override Enabled but it isn't virtual. Is there a way to hook in custom logic to determine the Enabled state? And how do you tickle the command (or BarManager) to get the Enabled state updated every so often?

Comments (6)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Bill,

I would recommend caching the Enabled property value at least a little bit since the drawing code hits it so if you are doing lengthy checks each time it is drawing, it MIGHT slow down your UI.

We do have a mechanism for updating the command state though. Check out the BarManager.CommandUpdateEventDelay property and the BarManager.CommandUpdate event.


Actipro Software Support

Posted 18 years ago by Bill Jacquot
Avatar
That works but if I wanted to update command state from AppIdle is there a way to get BarManager to fire the CommandUpdate event? BTW it would help encapsulation I think if BarCommand had an UpdateCommandState virtual method that BarManager would just call on each command in the Commands collection. Perhaps for a future release? :-)
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Bill,

So ideally, would you like the BarCommand.UpdateCommandStatement method added and then whenever the BarManager.CommandUpdate event fired, we could call that method for the related command as well? Would that handle what you are looking for?


Actipro Software Support

Posted 18 years ago by Bill Jacquot
Avatar
Yes that's correct. That would encapsulate the updating of the command state into BarCommand subclasses. Right now I'm catching the CommandUpdate event of BarManager and walking the command collection looking for instances of my BarCommand derived class to call the method "UpdateState".
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ok, BarCommand.UpdateState is added for the next maintenance release.


Actipro Software Support

Posted 18 years ago by Bill Jacquot
Avatar
That sounds good. This will allow us to update both the enabled and check state directly in our derived class.
The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.