|
-
August 17th, 2008, 04:29 PM
#1
[RESOLVED]How can I have seperate icons for both the CMFCMenuBar and the CMFCToolBar?
I am using the new 2008 MFC Feature Pack, and when I am creating my toolbar I have large icons in it. The problem is, the icons are also being used by my Menu bar (which I dont want to happen) and I end up with a big chunky menu with tiny text in it and big icons.
I am creating 2 seperate instances of my CMFCMenuBar and CMFCToolBar, and I dont understand why the menu is using the icons from the toolbar when they have nothing to do with each other. They dont reference each other at all in the code, so the only link they have between each other is they use the same event handlers.
I would like to somehow have the usual tiny icons in my menu but big icons in the toolbar, but I cant find a way to do it.
Last edited by SIBUK; August 18th, 2008 at 11:31 PM.
Reason: set status to resolved
-
August 18th, 2008, 12:42 AM
#2
Re: How can I have seperate icons for both the CMFCMenuBar and the CMFCToolBar?
Is the menu items and the toolbar buttons have the the same ID then what happens is normal, since the toolbar buttons are supposed to be shortcuts for the menu items.
Well, I see two ways: either use different IDs, or use SetIcon, passing NULL, to remove any existing icon associated with a window (toolbar button, menu item, etc.).
-
August 18th, 2008, 11:31 PM
#3
Re: How can I have seperate icons for both the CMFCMenuBar and the CMFCToolBar?
Hello cilu 
Thankyou for your reply, however I managed to figure out the best way of doing it! I call CMFCToolBar::SetMenuSizes before I call CMFCToolBar::CreateEx to create the toolbar. Then, instead of calling LoadToolBar I called LoadToolBarEx and passed to it a CMFCToolBarInfo struct which I left all NULL except for the m_uiMenuResID variable which I set to be the resource ID of my smaller icons.
Problem solved! =)) I now have a normal sized menu and a big chunky toolbar :P
I would like to ask though; how do I change the topic of my post so that it says [RESOLVED] on the main pages? I change it, and in my first post you can clearly see that it says [RESOLVED], but yet on the main page the topic of the thread is still the same
Last edited by SIBUK; August 18th, 2008 at 11:33 PM.
-
March 9th, 2010, 09:02 AM
#4
Re: How can I have seperate icons for both the CMFCMenuBar and the CMFCToolBar?
Hi, I have similar problem. I've tried to use your solution - but I cannot set bitmaps for menu items. I made toolbar for my menu. I set the same IDs for menu items and toolbar items and there are still no icons in menu. Below is part of my code:
Code:
if ( !m_wndMenuBar.Create(this) ) {
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
m_wndMenuBar.SetPaneStyle( m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY );
// prevent the menu bar from taking the focus on activation
CMFCPopupMenu::SetForceMenuFocus(FALSE);
CMFCToolBarInfo toolBarStruct;
SecureZeroMemory( &toolBarStruct, sizeof(CMFCToolBarInfo) );
toolBarStruct.m_uiMenuResID = IDR_MENU_IMAGES;
m_wndToolBar.SetMenuSizes( CSize(21,22), CSize(15,16) );
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC ) || //, CRect(1,1,1,1), theApp.m_bHiColorIcons ? IDR_TOOLBAR_MAIN_256 : IDR_TOOLBAR_MAIN ) ||
!m_wndToolBar.LoadToolBarEx( theApp.m_bHiColorIcons ? IDR_TOOLBAR_MAIN_256 : IDR_TOOLBAR_MAIN, toolBarStruct ) ) {
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar);
DockPane(&m_wndToolBar);
Could you correct my code ? One more question: how CMFCMenuBar is releted with CMFCToolbar? Regards.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|