Can I add a control in the ribbon bar caption? |
Post Reply |
Author | |
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 886 |
Post Options
Thanks(0)
Posted: 03 December 2021 at 3:43pm |
I see the ribbonsample adds tabs that display in the caption area (context tabs). I have a need to add an edit control to the caption area. I already add some buttons in the tab area by just getting the ribbonbar controls and calling Add. And, I know about AddCaptionButton API on the CXTPRibbonBar and of course the quick access popup (button) etc. I just haven't found a way to add another control type to the caption. Is it possible? I'm thinking of something along the lines of the Visual Studio (and other application) "Search" control that apps are now positioning in the caption area.
|
|
dbrookes
Groupie Joined: 30 August 2019 Location: Australia Status: Offline Points: 70 |
Post Options
Thanks(0)
|
You can do it with a bit of hackery. I have managed to do it. Since the ribbon draws the caption in its client area itself its possible to manually position a control up there yourself by overriding CalcDockingLayout. Similar to how the quick access toolbar buttons or minimize, maximize, close caption buttons are positioned. One challenge of positioning an edit control in the caption title though is that context tab captions and caption text can get in your way. You kind of are forced to dodge your edit control around them. For that reason I would recommend just keeping the edit control in the tab area. You can then actually left align to the tabs. Here is some code that you might be able to adapt. Use at your own peril :)
In our ribbon resource, the ID_COMMAND_SEARCH control is an edit control on the defined on the tab background. This code then finds that control and manually repositions it. There is a minimum and maximum width defined for the search box to allow it to scale a bit for smaller screens. We do have some custom drawing as well to make it fit in the Office 2016 style if that theme is used.
|
|
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 886 |
Post Options
Thanks(0)
|
Actually, by the time I got requirements, we wanted a logo in the caption area and the edit control under it. I made a couple of CJ virtual methods. One to create the caption buttons and one to create the caption button control (so I could subclass the caption button control) so I could paint it. CJ only supports a few caption buttons - minimize,maximize,resize and close. I had their code call the virtual methods. I had to use xtpAlignRight as the paint code ended up adding the size of the control to the spacing between the system (tab) button and the first ribbon tab and my control is just to the left of the system buttons CJ adds. I also implemented my own auto-complete as CJ only supported system supplied behavior (folders ...) and my auto-complete is for finding stuff like command (controls) on the ribbon.
|
|
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 |