how to change the default drawing behavior of an owner-drawn gallery button
-
Friday, April 06, 2012 7:57 PM
A while back I got some good advice on drawing ribbon gallery buttons. See the 'how to change default drawing of gallery button' thread. I ended the thread by saying that I didn't want to change the default drawing behavior of the gallery button. But guess what, the customer has spoken and I can hit another home run if I do. They were much impressed with the capability of sweeping over 60 or so gallery buttons and watching the data change in the form tables which gives the researchers instant overview of 10s of thousands of pieces of data. So if I can tweak the colors and make the hover button emphasis "sticky", that would be good for their users.
Here is my default draw button behavior today. All my app does is add the color sweep icon and superimpose the text. The borders are canned gallery button behavior:
As was pointed out in the cited thread, I have the device context, the icon index and access to the default gallery button code. I am posting this in the slim chance that someone else has tried something like this and can warn me of any gotchas. My task is to make the last button hovered over sticky and persist the hover-over border behavior. Also, I need to change the default colors of the borders to something stronger. By the way, I am using VS11 so my work on this will tell me if any of the ribbon functionality has gotten easier to use and the ribbon documentation improved with this version.
RT
All Replies
-
Saturday, April 07, 2012 8:15 PM
I got off easy. I just added the following border-drawing code:
void CMyMFCRibbonGallery::OnDrawPaletteIcon( CDC * pDC, CRect rectIcon, int nIconIndex, CMFCRibbonGalleryIcon * pIcon, COLORREF clrText ) { if( lastIconIndex == nIconIndex ) { CBrush brush( RGB( 0xFF, 0xA5, 0x00/*orange*/ ) ); CBrush* brushOld = pDC->SelectObject( &brush ); pDC->FillRect( &rectIcon, &brush ); pDC->SelectObject( brushOld ); } ...which makes the gallery button look like this:
RT
- Marked As Answer by rtischer8277 Saturday, April 07, 2012 8:15 PM
-
Tuesday, April 10, 2012 5:40 AMModerator
Thanks for sharing the solution.
Best regards,
Jesse
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us

