Support
Joined: 18 Jul 2005 Posts: 731
|
Posted: Mon Oct 06, 2008 8:30 am Post subject: HOWTO: Display a bitmap for the menu item in a context menu |
|
|
HOWTO: Display a bitmap in a menu item
Instead of using owner-drawn menu items (OnDrawMenuItem and OnMeasureMenuItem ), you can use the SetBitmap method if you only want to display a bitmap next to the text of the menu item. To do so, use the CShellMenuItem.SetBitmap method as follows :
void CKeyItem::GetMenuItems(CGetMenuitemsEventArgs& e)
{
CShellMenuItem* menuitem = e.menu->AddItem(_T("My Menu Item"));
CString filePath = "C:\\MyImage.bmp";
HBITMAP hBmp = (HBITMAP)LoadImage(AfxGetInstanceHandle(),filePath,IMAGE_BITMAP,0,0, LR_LOADFROMFILE);
menuitem->SetBitmap(hBmp);
} |
|