Originally posted by: Heiko Gschwind
Hello,
there seems to be a resource leak in method DrawItem() of class CMenuSpawn:
...
{
HICON hIcon = m_ilList.ExtractIcon( pItem->iImageIdx );
pDC->DrawState( CPoint(rcImage.left + ax, rcImage.top + ay ), m_szImage, (HICON)hIcon, DST_ICON | DSS_DISABLED, (CBrush *)NULL );
}
...
After extracting an icon the icon handle has to be destroyed with ::DestroyIcon(...);
...
{
HICON hIcon = m_ilList.ExtractIcon( pItem->iImageIdx );
pDC->DrawState( CPoint(rcImage.left + ax, rcImage.top + ay ), m_szImage, (HICON)hIcon, DST_ICON | DSS_DISABLED, (CBrush *)NULL );
::DestroyIcon( hIcon );
}
...
Heiko
Reply
Originally posted by: CosmoS
Your Menus are rally cool, but could you use flat Menus?
Reply
Originally posted by: Joshua Liu
How should I do in a SDI application that has two toolbars?
Originally posted by: Richard Hollis
To make the recent file list look size correctly with the rest of the menus
//
BEGIN_MESSAGE_MAP(CMapperApp, CWinApp)
void CMapperApp::OnUpdateRecentFile(CCmdUI* pCmdUI)
CMainFrame* pFrameWnd = (CMainFrame*)AfxGetMainWnd();
if(pFrameWnd)
if(pMenu)
if(pSubMenu)
And then add the following line to the header file:
//
// Implementation
If you have been using this class you might of noticed that the recent file list
sizing is wrong. It looks like the menus did before you added the extended menu class.
add the following code to your CWinApp dervied class:
// myapp.cpp
//////////////////////////////////////////////////////
//...
//...
ON_UPDATE_COMMAND_UI_RANGE( ID_FILE_MRU_FIRST, ID_FILE_MRU_LAST, OnUpdateRecentFile)
//...
//...
END_MESSAGE_MAP()
{
m_pRecentFileList->UpdateMenu(pCmdUI);
ASSERT(pFrameWnd);
{
CMenu *pMenu = pFrameWnd->GetMenu();
ASSERT(pMenu);
{
CMenu *pSubMenu = pMenu->GetSubMenu(0);
ASSERT(pSubMenu);
pFrameWnd->cSpawn.RemapMenu(pSubMenu);
}
}
}
// myapp.h
//////////////////////////////////////////////////////
//{{AFX_MSG(CMapperApp)
//....
//....
afx_msg void OnUpdateRecentFile(CCmdUI* pCmdUI);
//....
//....
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
Originally posted by: Scott MacLaughlin
How do you use these menu classes if you are also using the SECMenuBar class from Stringray's Objective Toolkit Pro 6.03 for a dockable menu bar ?
Originally posted by: Walter Hahn
The Problem could be fixed by modifying the handler for WM_INITMENUPOPUP in the class deviated from CFrameWnd. In the example from Iuri Apollonio, replace the code segment:
void CSpawnFrameWnd::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
cSpawn.RemapMenu(pPopupMenu);
}
found in file SpawnFrameWnd.cpp by the following code, that calls RemapMenu only for system menus:
void CSpawnFrameWnd::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
if (bSysMenu)
cSpawn.RemapMenu(pPopupMenu);
}
With this modification the menus with icons work on both platforms (NT, W2K) as expected.
Examination of the WM_INITMENU and WM_INITMENUPOPUP calls show, that on Windows 2000 the handler for WM_INITMENUPOPUP is also called for popup items included in regular menus and not only for system popup menus. By this, RemapMenu() get confused and CMenuSpawn::MeasureItem() handles popup menus within regular menus like "title Items", which have no icons and a size only depending on the text size
Originally posted by: Chris Ryan
I have been trying to use this class with the supplied sample in Windows 2000. A problem occurrs with Pop-out menus. The size of these menu items is scruched way down, making it unreadable. I will bee looking into this a bit further, however was wondering if there were any solutions already out there. Thanks
Reply
Originally posted by: Sujatha
Hi,
I would like to enable/disable a sub menu item on the event of
clicking another menu item.I tried with OnUpdatexxxx() by
setting pCmdUI->Enable(TRUE|FALSE). Also I tried using your
EnableMenuItems()... to enable/disable my item (Actually I passed
CWnd::GetMenu() as the first argument to this call but it seems to crash
the application. Could you please help me out in this?
Thanks,
Sujatha.
Originally posted by: Why Zhang
I want to create a popup menu whose menuitems are image(or ownerdraw) without text when sending TOOLBARDROPDOWN message, like selecting the Line mode in Ms Word.
I have failed some times. I can't let the image-menuitem
drawn according to my idea. I can't find out the reason.
Who can help you? Better give me a example.
SOS!
Originally posted by: C. Natal
Hi,
I'm a beginner on MFC and I really like your menu.
I just would like to know if it is possible, in some way, to use your code on my dialog based
application.
Thanks!
Regards,
Carlos Natal