<p>There are three places where menus show up in the new MFC functionality (Feature Pack):</p>

<ul>
<li>In menu bars (CMFCMenuBar)</li>
<li>In popup menus (CMFCPopupMenu)</li>
<li>In the 'dropdown menu' version of CMFCButton</li>
</ul>

<p>I want to put icons (high-color and with transparancy) in the menus in all of them. I have found CFrameWndEx::OnDrawMenuImage() which I can use to custom draw the icons in front of the menu bar items. It's not very convenient, having to implement icon drawing in 2008, but it works. For the others I haven't found a solution yet. Is there an automagic way to set icons for menus?</p>

[{'answer_id': 72654, 'author': 'Nevermind', 'author_id': 12366, 'author_profile': 'https://Stackoverflow.com/users/12366', 'pm_score': 2, 'selected': False, 'text': "<p>I believe (but I may be wrong) that these classes are the same as the BCGToolbar classes that were included in MFC when Microsoft bought BCG. If so, you can create a toolbar with and use the same ID on a toolbar button as in the menu items you want to create icons for, and they should appear automatically. Of course, you don't have to actually display the toolbars.</p>\n"}, {'answer_id': 92995, 'author': 'Nevermind', 'author_id': 12366, 'author_profile': 'https://Stackoverflow.com/users/12366', 'pm_score': 2, 'selected': False, 'text': "<p>In BCGToolbar, it's enough to create a toolbar in the resources &amp; load it (but not display the window), but the toolbar button must have the same ID as the menu item you want to link it to.</p>\n"}, {'answer_id': 783923, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>One thing that can catch a person by surprise is that for customizable (ie, non-locked) toolbars, the first toolbar you make, the framework splits up and turns into some sort of palette bitmap of all icons in the program.  If you try to add more toolbars later (or different toolbars) that have bitmaps (or pngs) with a different color depth than that first one, they seem to fail because it can't add them to the same palette.</p>\n"}, {'answer_id': 1213583, 'author': 'foraidt', 'author_id': 27596, 'author_profile': 'https://Stackoverflow.com/users/27596', 'pm_score': 3, 'selected': True, 'text': "<p>This is how I got it to work:</p>\n\n<h3>First</h3>\n\n<p>, as the others said, create an invisible toolbar next to your main toolbar (I'm using the usual names based on AppWizard's names):</p>\n\n<pre><code>MainFrm.h:\nclass CMainFrame\n{\n    //...    \n    CMFCToolBar m_wndToolBar;\n    CMFCToolBar m_wndInvisibleToolBar;\n    //...\n};\n\nMainFrm.cpp:\nint CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)\n{\n    //...\n\n    // Normal, visible toolbar\n    if(m_wndToolBar.Create(this,\n        TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC))\n    {\n        VERIFY( m_wndToolBar.LoadToolBar(\n            theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME) );\n\n        // Only the docking makes the toolbar visible\n        m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);\n        DockPane(&amp;m_wndToolBar);\n    }\n\n    // Invisible toolbar; simply calling Create(this) seems to be enough\n    if(m_wndInvisibleToolBar.Create(this))\n    {\n        // Just load, no docking and stuff\n        VERIFY( m_wndInvisibleToolBar.LoadToolBar(IDR_OTHERTOOLBAR) );\n    }\n}\n</code></pre>\n\n<h3>Second: The images and toolbar resources</h3>\n\n<p><code>IDR_MAINFRAME</code> and <code>IDR_MAINFRAME_256</code> were generated by AppWizard. The former is the ugly 16 color version and the latter is the interesting high color version.<br>\nDespite its name, if I remember correctly, even the AppWizard-generated image has 24bit color depth. The cool thing: Just replace it with a 32bit image and that'll work, too.  </p>\n\n<p>There is the invisible toolbar <code>IDR_OTHERTOOLBAR</code>: I created a toolbar with the resource editor. Just some dummy icons and the command IDs. VS then generated a bitmap which I replaced with my high color version. Done!</p>\n\n<h3>Note</h3>\n\n<p>Don't open the toolbars with the resource editor: It may have to convert it to 4bit before it can do anything with it. And even <em>if</em> you let it do that (because, behind Visual Studio's back, wou're going to replace the result with the high color image again, ha!), I found that it (sometimes?) simply cannot edit the toolbar. Very strange.<br>\nIn that case I advise to directly edit the .rc file.</p>\n"}, {'answer_id': 1239950, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>Try using this function:</p>\n\n<pre><code>CMFCToolBar::AddToolBarForImageCollection(UINT uiResID,\n   UINT uiBmpResID=0,\n   UINT uiColdResID=0,\n   UINT uiMenuResID=0,\n   UINT uiDisabledResID=0,\n   UINT uiMenuDisabledResID=0);\n</code></pre>\n\n<p>So e.g.: </p>\n\n<pre><code>CMFCToolBar::AddToolBarForImageCollection(IDR_TOOLBAROWNBITMAP_256);\n</code></pre>\n\n<p>Worked very well for me.</p>\n'}]
['https://Stackoverflow.com/questions/70386', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11449/']