Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC
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
    m_wndRibbonBar.Create(this);
    m_wndRibbonBar.LoadFromResource(IDR_RIBBON);
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
Edited 28-Aug-12 5:37am
Maciej Los118.9K
v4
Rate this: bad
good
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.
  Permalink  
Comments
losmac at 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 at 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
good
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.
  Permalink  
v2

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 397
1 OriginalGriff 350
2 thatraja 205
3 Emre Ataseven 165
4 Shai Vashdi 150
0 Sergey Alexandrovich Kryukov 8,894
1 OriginalGriff 5,200
2 Peter Leow 3,955
3 Maciej Los 3,535
4 Abhinav S 3,208


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 28 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid