Support
Joined: 18 Jul 2005 Posts: 731
|
Posted: Mon Oct 06, 2008 8:26 am Post subject: HOWTO: Display a bitmap for the menu item in a context menu |
|
|
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 ShellMenuItem.SetBitmap method as follows :
[C#]
public override void GetMenuItems(GetMenuitemsEventArgs e)
{
ShellMenuItem menuItem =e.Menu.AddItem("My Menu Item");
menuItem.SetBitmap(new Bitmap("C:\\MyImage.bmp"));
}
[VB.Net]
Public Overrides Sub GetMenuItems(ByVal e As GetMenuitemsEventArgs)
Dim menuItem As ShellMenuItem = e.Menu.AddItem("My Menu Item")
menuItem.SetBitmap(New Bitmap("C:\MyImage))
End Sub |
|