Click here to Skip to main content
13,004,839 members (64,307 online)
Rate this:
Please Sign up or sign in to vote.
See more:
hi, i'm using vs2010 and have an MFC app with a ribbon bar

i'm using CMFCRibbonSlider but i think this is a general question for any ribbon control

i would like to change the look of the slider. i'm using it as a volume control slide and want the slider part to look like a stretched out triangle (like vlc's volume control) and the zoom buttons to look like small speaker and big speaker

normally i would make a derived class from CMFCRibbonSlider and override OnDrawRibbonSliderZoomButton for example but all the controls in my app are created like this

from the resources so i have no way that i can think of to change any of the behavior of the control.

do you think there is a way to somehow add your own customs controls to the ribbon and still use the ribbon designer vs. creating the ribbon programmatically?

for example, suppose i get the crate do its job but after creating i somehow override CMFCRibbonSlider::OnDraw(CDC* pDC) and point it to my own version of CMFCRibbonSlider::OnDraw(CDC* pDC)where i can do whatever i want.

it this legitimate c++ programming? how would one override a class at runtime?

P.S. i tried simply writing my own On Draw function
void CMFCRibbonSlider::OnDraw(CDC* pDC)
    TRACE("this is my CMFCRibbonSlider::OnDraw\n");

which compiles (strangely) but does not get called

[edit: moved form answer]
The question is: How to get the ribbon designer to recognize the new class?
[/end of edit]
Posted 26-May-11 19:38pm
Updated 28-Aug-12 5:37am
Maciej Los254.6K
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to create your own class derived from the CMFCRibbonSlider and override the functions that you want to handle.
losmac 28-Aug-12 11:36am
Cooment from OP:
i know i can do that but the question is how to get the ribbon designer to recognize the new class?
i don't want to have to code the ribbon layout in c code, i like the ribbon designer GUI
Richard MacCutchan 28-Aug-12 13:33pm
I don't know of any way to change the designer as it is part of Visual Studio and not easily customisable. You could always try looking at the VCProjectEngine namespace to see if it's possible.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

I had the exact same problem and got the answer by asking on an MSDN forum. Like you, I could not figure out how use a to derived a ribbon control class, especially when using the ribbon designer, since the ribbon controls are instantiated deep within MFC. The solution was easy once pointed out to me: After the ribbon has been created, enumerate the child windows to find the up-down control(s), then subclass them and intercept the UDN_DELTAPOS. You can see the full answer by searching on the MSDN forums for my forum name, johnsssl. Oh, after getting the up-down control's window, you get its parent window, and subclass the parent, since the control notifications go to the parent.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170627.1 | Last Updated 28 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100