Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   Display Icon or Bitmap at Menuitem (http://www.go4expert.com/forums/display-icon-bitmap-menuitem-t11460/)

cb02061 19Jun2008 07:01

Display Icon or Bitmap at Menuitem
 
Hi,

I have been developed a SDI application. I want to show icon or bitmap at menuitem.
I already tested codes below, but it's not working???
I got assertion failure error...
I need help???

Code:

private:
CBitmap m_bmpMenuFileNew; //File new bitmap (Checked and unchecked)
CBitmap m_bmpMenuFileOpen; //File open bitmap (Checked and unchecked)



int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;

//Load the bitmap resource
ASSERT( m_bmpMenuFileNew.LoadBitmap( IDB_MENU_NEW ) );
ASSERT( m_bmpMenuFileOpen.LoadBitmap( IDB_MENU_OPEN ) );

//Access the application menu
CMenu* pMenu = GetMenu();
ASSERT( pMenu );

//Assign the icon
ASSERT( pMenu->SetMenuItemBitmaps( ID_FILE_NEW, MF_BYCOMMAND,
&m_bmpMenuFileNew, &m_bmpMenuFileNew ) );
ASSERT( pMenu->SetMenuItemBitmaps( ID_FILE_OPEN, MF_BYCOMMAND,
&m_bmpMenuFileOpen, &m_bmpMenuFileOpen ) );

return 0;
}


CMainFrame::~CMainFrame()
{
if( m_bmpMenuFileNew.m_hObject )
m_bmpMenuFileNew.DeleteObject();
if( m_bmpMenuFileOpen.m_hObject )
m_bmpMenuFileOpen.DeleteObject();
}



All times are GMT +5.5. The time now is 08:57.