Support
Joined: 18 Jul 2005 Posts: 731
|
Posted: Tue Jan 27, 2009 9:00 am Post subject: HOWTO: Show a bitmap for a menu item |
|
|
Use the following code in the OnContextMenuPopup event of the FileView Control to show a bitmap for a menu item :
[C++]
Code: | void CCustomContextMenuItemDlg::OnOnContextMenuPopupFileview(LPDISPATCH ShellMenu, BOOL BackgroundMenu, BOOL FAR* Cancel)
{
CShellContextMenu shellContextMenu;
shellContextMenu.AttachDispatch( ShellMenu,FALSE );
CShellMenuItem newMenuItem = shellContextMenu.AddItem("Custom Menu Item");
//Set the path of the bitmap file here
CString imagePath = _T("C:\\logo.bmp");
HBITMAP hBmp = (HBITMAP)LoadImage(AfxGetInstanceHandle(),imagePath,IMAGE_BITMAP,0,0, LR_LOADFROMFILE);
CPictureHolder ph ;
ph.CreateFromBitmap(hBmp,NULL,FALSE);
newMenuItem.SetBitmap(ph.GetPictureDispatch());
} |
[VB6]
Code: | Private Sub flView_OnContextMenuPopup(ByVal ShellMenu As FileViewControl.IShellContextMenu, ByVal BackgroundMenu As Boolean, Cancel As Boolean)
Dim newMenuItem As ShellMenuItem
Set newMenuItem = ShellMenu.AddItem("Custom Menu Item")
Dim image As IPictureDisp
Set image = LoadPicture("C:\logo.bmp")
newMenuItem.SetBitmap image
End Sub |
|
|