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?
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...@microsoft.com...
The trouble is, I can't because my icons are obtained on-the-fly from
different DLLs.
The second constructor does take a HICON so in theory it should work.
(however I understand that theory != practice :)
This is a bug in MFC right?
Anyone?