Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ! I want to use two ribbon category buttons to switch between two different views, but I found it can't add event handler to the button.

Is there any hint to solve this problem? Better if there is some sample, actually I'm new to MFC.
Posted
Updated 9-Oct-10 5:54am
v2
Comments
Alain Rist 9-Oct-10 11:54am    
Added MFC tag

Hi,

From your question wording I suppose you are using the MFC ribbon. If so you should tag the question as MFC.

Anyhow, what you are asking for is contrary to Microsoft's guidelines. See the first answer at http://stackoverflow.com/questions/549518/using-ribbon-as-tab-control[^].

To achieve what you want add a View 'panel' with as many buttons as your views, and appropriately switch your view on user action.

cheers,
AR

PS: if you are new to MFC you may as well use the system 'Windows Ribbon Framework' control. See my article Relook your Old and New Native Applications with a Ribbon UI under Vista or Windows 7 (WTL)[^].
 
Share this answer
 
Comments
Jörgen Sigvardsson 10-Oct-10 5:50am    
Now that's a seriously well written article! Good work man!
Alain Rist 10-Oct-10 6:48am    
Thanks :)
Yes this can be done, but it is quite involved. It does not go against the Ribbon Guidelines, just take a look at Outlook 2010, there are multiple modes, Mail, Calendar, Journal etc... Each mode has different ribbons, so it is possible to create a View ribbon, which could be used to switch out the ribbons and contents based on the view.

So like MS, you will end up with multiple Home Ribbons, as well as any other repeated per view.

I have done it this myself using VS2008 C++ SP1 Feature Pack and it runs in VS2010 as well, minus one subtle change to the Panel that MS made.

Tom
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900