![]() |
Ribbon - some observations/suggestions |
Post Reply ![]() |
Author | ||
ijwelch ![]() Senior Member ![]() Joined: 20 June 2006 Status: Offline Points: 262 |
![]() ![]() ![]() ![]() ![]() Posted: 20 June 2006 at 5:18am |
|
Here's some observations/suggestions for the ribbonbar:
The QuickAccessControls item collection has a 1 based index, as opposed to the rest of the controls which are zero based. As a control can appear >1 times on the ribbonbar object, it's a bit of a pain having to loop through RibbonTabs, followed by RibbonGroups, followed by Items, in order to (for example) set the enabled property for a particular control id. Perhaps we can have a method to retrieve a collection of CommandBarControls that share the same id? Or in this case, a RibbonBar.EnableControlsByID (ID) method? It'd be nice to have a Visible property on the QuickAccessControls object. It'd also be nice to be able to hide tabs (eg if there's only one). By this I don't mean hide the entire tab, but just the bit you click on at the top. Version 10.2 includes the system icon. The only way to get it visible is to use the EnableFrameTheme method. mmm. I want the icon/quick access bar to look like that but I don't want my form skinned. |
||
![]() |
||
ABuenger ![]() Newbie ![]() ![]() Joined: 02 February 2006 Status: Offline Points: 1075 |
![]() ![]() ![]() ![]() ![]() |
|
What's wrong with ON_UPDATE_COMMAND_UI ?
|
||
Codejock support
|
||
![]() |
||
ijwelch ![]() Senior Member ![]() Joined: 20 June 2006 Status: Offline Points: 262 |
![]() ![]() ![]() ![]() ![]() |
|
Not a lot. Although it can lead to a waste of resources, more variables, etc. I like to run code to enable/disable controls when needed, not every 10ms or so.
The enabled property was just an example. Another common task would be to set the checked property. Right now, to do that, I've got to loop through every tab, every group, and every control. A ControlsByID collection seems a pretty obvious requirement anyway considering the hierarchy of the control, and is probably implemented internally anyway. |
||
![]() |
||
ABuenger ![]() Newbie ![]() ![]() Joined: 02 February 2006 Status: Offline Points: 1075 |
![]() ![]() ![]() ![]() ![]() |
|
MFC updates the UI only when it's in idle state, so nothing to worry about.
Call CCmdUi::SetCheck in the ON_UPDATE_COMMAND_UI handler.
P.S.: You can also use FindControl to find a control by id anywhere on the Ribbon. If you have a lot of duplicated commands on the Ribbon you might need to rethink your UI
![]() |
||
Codejock support
|
||
![]() |
||
ijwelch ![]() Senior Member ![]() Joined: 20 June 2006 Status: Offline Points: 262 |
![]() ![]() ![]() ![]() ![]() |
|
"MFC updates the UI only when it's in idle state, so nothing to worry about."
Ok. "P.S.: You can also use FindControl to find a control by id anywhere on the Ribbon. If you have a lot of duplicated commands on the Ribbon you might need to rethink your UI." If the end user can customize the toolbar then it's necessary to be able to find all instances of a tool. |
||
![]() |
||
ABuenger ![]() Newbie ![]() ![]() Joined: 02 February 2006 Status: Offline Points: 1075 |
![]() ![]() ![]() ![]() ![]() |
|
Again, you should update your UI state using ON_UPDATE_COMMAND_UI handlers. That will automatically update all controls with the same id.
You can even update a command range (ON_UPDATE_COMMAND_UI_RANGE) with a single handler.
You should not call Enable/SetCheck methods of the controls because then you are tying your code to the XTP classes without the need of doing this.
It shouldn't matter if a command is a menu item or or button on the Ribbon, the control takes care how to display its current state.
|
||
Codejock support
|
||
![]() |
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 |