0

I would like to know if it's possible to set an image (and display only that, without text) in a CMFCToolbar, in a top level CMFCToolBarButton item (like File, Edit, Help, etc.):

enter image description here

What I've tried, but has no effect:

CMFCToolBarMenuButton* button = DYNAMIC_DOWNCAST(CMFCToolBarMenuButton, m_wndMenuBar.GetMenuItem(0));
button->m_bUserButton = TRUE;
button->m_bImage = TRUE;
button->m_bText = FALSE;
button->SetImage(1);
m_wndMenuBar.UpdateButton(0);

Prior to this I'm setting some custom images like so (it's actually the generated MFC project, from VS2010):

if (CMFCToolBar::GetUserImages() == NULL)
{
    // load user-defined toolbar images
    if (m_UserImages.Load(_T(".\\UserImages.bmp")))
    {
        CMFCToolBar::SetUserImages(&m_UserImages);
    }
}

So, is this possible or not? I would think that it is, since CMFCMenuBar is derived from CMFCToolBar, which supports it.

More info: Actually, what I'm trying to achieve is this (in red rectangle):

enter image description here

So I would like that in a classic menu bar (not ribbon like in the image), create an image button and right align it.

Marcel N.
  • 13,726
  • 5
  • 47
  • 72

2 Answers2

1

If you trying to show a 'Help' menu item with a drop down combobox then maybe the built-in

CMFCMenuBar::EnableHelpComboBox

should work for you. Check the help here.

Pankaj
  • 599
  • 3
  • 10
  • Not necessarily a help box. I'm actually trying to add a set of three image buttons, right aligned in the menu bar. I think I my have found a solution, at least for the images (http://msdn.microsoft.com/en-us/library/bb983718.aspx), by adding a `CMFCToolbarButton` to the menu bar. Anyway, +1, as this will allow me to see how they are right aligning the combo hoping that I can do the same for the buttons. – Marcel N. Aug 08 '12 at 16:45
0

I did this, and it seems to work ok:

VERIFY(CMFCToolBar::GetImages()->Load(IDB_MY_NEW_FILE,nullptr,TRUE));
int imageIndex = CMFCToolBar::GetImages()->GetCount();
m_wndToolBar.InsertButton( CMFCToolBarButton(ID_FILE_MYNEWICON,imageIndex) );