Support
Joined: 18 Jul 2005 Posts: 731
|
Posted: Tue Jan 27, 2009 8:58 am Post subject: HOWTO: Show a bitmap for a menu item |
|
|
Use the following code in the OnContextMenuPopup event of the FolderView Control to show a bitmap for a menu item :
[C++]
Code: | void CCustomContextMenuItemDlg::OnOnContextMenuPopupFolderviewctrl(LPDISPATCH ShellMenu, 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 fldrView_OnContextMenuPopup(ByVal ShellMenu As FolderViewControl.IShellContextMenu, 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 |
|
|