Re: CMFCRibbonButton constructor with HICON doesn't work properly
I'm not sure what you are seeing. I haven't tried using icons for this.
If it were me, I'd download IconWorks, transfer all my icon images to a
high-color toolbar image with full alpha channel and be done with it.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"[d3m0n]" <[d3m0n]@discussions.microsoft.com> wrote in message
news:F3F0EC11-7D79-4044-A282-B2A5D593FF1F@microsoft.com...
Hi
I'm using VS2008 and the MFC Feature Pack. I am trying to add 5 buttons A,
B, C, D and E to the ribbon. Each button has an image which I want to
appear
next to the text.
I managed to get the first constructor of CMFCRibbonButton (the one with 2
ints and a BOOL) to work fine. The items are added to the ribbon panel one
below the other, like this:
A D
B E
C
However I would actually prefer to use the second constructor (the one
with
HICONs) because I already have some HICONs that I can get from a DLL,
which I
want to use as the images.
But when I tried using HICONs in the constructor, the buttons were added
*alongside* each other, like this:
A B C D E
I tried stepping into the MFC code and it seems that for buttons created
using the HICON constructor, CMFCRibbonButton::m_bIsLargeImage gets set to
TRUE. Even though my icons are only 16x16.
Here's some example code to demonstrate the problem:
//add category to ribbon
CMFCRibbonCategory* pCategoryTest =
m_wndRibbonBar.AddCategory(L"TestCategory", 0, 0);
//add panel to category
CMFCRibbonPanel* pPanelTest = pCategoryTest->AddPanel(L"TestPanel");
//load some 16x16 icons from resources
HICON hIcon1 = (HICON)::LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_TEST1), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON),
::GetSystemMetrics(SM_CYSMICON), 0);
HICON hIcon2 = (HICON)::LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_TEST2), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON),
::GetSystemMetrics(SM_CYSMICON), 0);
//create buttons
CMFCRibbonButton* pButton1 = new CMFCRibbonButton(ID_TEST1, L"Test1",
hIcon1);
CMFCRibbonButton* pButton2 = new CMFCRibbonButton(ID_TEST2, L"Test2",
hIcon2);
//add buttons to panel
pPanelTest->Add(pButton1);
pPanelTest->Add(pButton2);
Please could anyone give me some suggestions?