当前位置: 首页>>代码示例>>C++>>正文


C++ LPCONTEXTMENU::Release方法代码示例

本文整理汇总了C++中LPCONTEXTMENU::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ LPCONTEXTMENU::Release方法的具体用法?C++ LPCONTEXTMENU::Release怎么用?C++ LPCONTEXTMENU::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPCONTEXTMENU的用法示例。


在下文中一共展示了LPCONTEXTMENU::Release方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ExecCommand

BOOL CRecBinViewer::ExecCommand (int iItem, LPCTSTR lpszCommand)
{
	if (iItem >= static_cast<int>(m_List.size ()))
		return FALSE;

	BOOL bReturn = FALSE;
	LPITEMIDLIST	pidl = NULL;
	LPCONTEXTMENU pCtxMenu = NULL;
	HRESULT hr = S_OK;

	pidl = m_List[iItem].m_PIDL;
	
	if (NULL != m_pFolder2)	
		hr = m_pFolder2->GetUIObjectOf (m_hWnd, 1, (LPCITEMIDLIST *)&pidl, IID_IContextMenu, NULL, (LPVOID *)&pCtxMenu);
	
	else	
		hr = m_pRecycleBin->GetUIObjectOf (m_hWnd, 1, (LPCITEMIDLIST *)&pidl, IID_IContextMenu, NULL, (LPVOID *)&pCtxMenu);
	
	if (SUCCEEDED (hr))
		bReturn = ExecCommand (pCtxMenu, lpszCommand);
	
	pCtxMenu->Release();
	
	return bReturn;
}
开发者ID:avrionov,项目名称:explorerxp,代码行数:25,代码来源:RecBinViewer.cpp

示例2: ShowContextMenu

UINT CShellContextMenu::ShowContextMenu(QWidget * pParentWidget, QPoint pt, QMenu* pMenu )
{
        HWND hWnd = pParentWidget->winId();
        int iMenuType = 0;	// to know which version of IContextMenu is supported
	LPCONTEXTMENU pContextMenu;	// common pointer to IContextMenu and higher version interface
   
	if (!GetContextMenu ((void**) &pContextMenu, iMenuType))	
		return (0);	// something went wrong

	if (!m_hMenu)
	{
		DestroyMenu( m_hMenu );
		m_hMenu = CreatePopupMenu ();
	}

        int i;
        QList<QAction*> actionList = pMenu->actions();
        for( i=0; i<actionList.count(); ++i )
        {
           QString s = actionList.at(i)->text();
           if (!s.isEmpty())
              AppendMenuW( m_hMenu, MF_STRING, i+1, (LPCWSTR)s.utf16() );
        }
        AppendMenuW( m_hMenu, MF_SEPARATOR, i+1, L"" );

	// lets fill the our popupmenu  
	pContextMenu->QueryContextMenu (m_hMenu, GetMenuItemCount (m_hMenu), MIN_ID, MAX_ID, CMF_NORMAL | CMF_EXPLORE);
 
	// subclass window to handle menurelated messages in CShellContextMenu 
	WNDPROC OldWndProc;
	if (iMenuType > 1)	// only subclass if its version 2 or 3
	{
		OldWndProc = (WNDPROC) SetWindowLongPtr (hWnd, GWLP_WNDPROC, (LONG_PTR) HookWndProc);
		if (iMenuType == 2)
			g_IContext2 = (LPCONTEXTMENU2) pContextMenu;
		else	// version 3
			g_IContext3 = (LPCONTEXTMENU3) pContextMenu;
	}
	else
		OldWndProc = NULL;

	UINT idCommand = TrackPopupMenu (m_hMenu,TPM_RETURNCMD | TPM_LEFTALIGN, pt.x(), pt.y(), 0, pParentWidget->winId(), 0);

	if (OldWndProc) // unsubclass
		SetWindowLongPtr (hWnd, GWLP_WNDPROC, (LONG_PTR) OldWndProc);

	if (idCommand >= MIN_ID && idCommand <= MAX_ID)	// see if returned idCommand belongs to shell menu entries
	{
		InvokeCommand (pContextMenu, idCommand - MIN_ID);	// execute related command
		idCommand = 0;
	}
	
	pContextMenu->Release();
	g_IContext2 = NULL;
	g_IContext3 = NULL;

	return (idCommand);
}
开发者ID:nigels-com,项目名称:nvidia-kdiff3,代码行数:58,代码来源:ShellContextMenu.cpp

示例3: DirList_PropertyDlg

//  Shows standard Win95 Property Dlg for selected Item
BOOL DirList_PropertyDlg(HWND hwnd, int iItem) {

    LV_ITEM lvi;
    LPLV_ITEMDATA lplvid;
    LPCONTEXTMENU lpcm;
    CMINVOKECOMMANDINFO cmi;
    BOOL bSuccess = TRUE;

    static const char* lpVerb = "properties";

    if (iItem == -1) {
        if (ListView_GetSelectedCount(hwnd))
            iItem = ListView_GetNextItem(hwnd, -1, LVNI_ALL | LVNI_SELECTED);

        else
            return FALSE;
    }

    lvi.mask = LVIF_PARAM;
    lvi.iItem = iItem;
    lvi.iSubItem = 0;

    if (!ListView_GetItem(hwnd, &lvi))
        return FALSE;

    lplvid = (LPLV_ITEMDATA)lvi.lParam;

    if (NOERROR ==
        lplvid->lpsf->GetUIObjectOf(GetParent(hwnd),               // Owner
                                    1,                             // Number of objects
                                    (LPCITEMIDLIST*)&lplvid->pidl, // pidl
                                    IID_IContextMenu, NULL, (void**)&lpcm)) {

        cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
        cmi.fMask = 0;
        cmi.hwnd = GetParent(hwnd);
        cmi.lpVerb = lpVerb;
        cmi.lpParameters = NULL;
        cmi.lpDirectory = NULL;
        cmi.nShow = SW_SHOWNORMAL;
        cmi.dwHotKey = 0;
        cmi.hIcon = NULL;

        if (NOERROR != lpcm->InvokeCommand(&cmi))
            bSuccess = FALSE;

        lpcm->Release();
    } else
        bSuccess = FALSE;

    return bSuccess;
}
开发者ID:vehar,项目名称:velociraptor8,代码行数:53,代码来源:Dlapi.cpp

示例4: ShowContextMenu

UINT CShellContextMenu::ShowContextMenu(HWND hWnd, CPoint pt)
{
	int iMenuType = 0;	// to know which version of IContextMenu is supported
	LPCONTEXTMENU pContextMenu;	// common pointer to IContextMenu and higher version interface

	if(!GetContextMenu((LPVOID*)&pContextMenu, iMenuType))	
		return 0;	// something went wrong

	if(!m_Menu)
	{
		delete m_Menu;
		m_Menu = NULL;
		m_Menu = new CMenu;
		m_Menu->CreatePopupMenu();
	}

	// lets fill the popupmenu 
	pContextMenu->QueryContextMenu(m_Menu->m_hMenu, m_Menu->GetMenuItemCount(), ID_SHELLCONTEXTMENU_MIN, ID_SHELLCONTEXTMENU_MAX, CMF_NORMAL | CMF_EXPLORE);

	// subclass window to handle menurelated messages in CShellContextMenu 
	WNDPROC OldWndProc;
	if(iMenuType > 1)	// only subclass if its version 2 or 3
	{
		OldWndProc = (WNDPROC) SetWindowLong(hWnd, GWL_WNDPROC, (DWORD) HookWndProc);
		if(iMenuType == 2)
			g_IContext2 = (LPCONTEXTMENU2) pContextMenu;
		else	// version 3
			g_IContext3 = (LPCONTEXTMENU3) pContextMenu;
	}
	else
		OldWndProc = NULL;

	UINT idCommand = m_Menu->TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN, pt.x, pt.y, hWnd);

	if(OldWndProc) // unsubclass
		SetWindowLong(hWnd, GWL_WNDPROC, (DWORD) OldWndProc);

	if(idCommand >= ID_SHELLCONTEXTMENU_MIN && idCommand <= ID_SHELLCONTEXTMENU_MAX)
	{
		InvokeCommand(pContextMenu, idCommand - ID_SHELLCONTEXTMENU_MIN);
		idCommand = 0;
	}

	pContextMenu->Release();
	g_IContext2 = NULL;
	g_IContext3 = NULL;

	return idCommand;
}
开发者ID:inetra,项目名称:peers1,代码行数:49,代码来源:ShellContextMenu.cpp

示例5: ShowContextMenu

UINT CShellContextMenu::ShowContextMenu(CWnd *pWnd, CPoint pt)
{
	int iMenuType = 0;	// to know which version of IContextMenu is supported
	LPCONTEXTMENU pContextMenu;	// common pointer to IContextMenu and higher version interface
   
	if (!GetContextMenu ((void**) &pContextMenu, iMenuType))	
		return (0);	// something went wrong

	if (m_Menu)
	{
		delete m_Menu;
		m_Menu = NULL;
	}
	m_Menu = new CMenu;
	m_Menu->CreatePopupMenu ();
	// lets fill the our popupmenu  
	pContextMenu->QueryContextMenu (m_Menu->m_hMenu, m_Menu->GetMenuItemCount (), MIN_ID, MAX_ID, CMF_NORMAL | CMF_EXPLORE);
 
	// subclass window to handle menurelated messages in CShellContextMenu 
	WNDPROC OldWndProc;
	if (iMenuType > 1)	// only subclass if its version 2 or 3
	{
		OldWndProc = (WNDPROC) SetWindowLong (pWnd->m_hWnd, GWL_WNDPROC, (DWORD) HookWndProc);
		if (iMenuType == 2)
			g_IContext2 = (LPCONTEXTMENU2) pContextMenu;
		else	// version 3
			g_IContext3 = (LPCONTEXTMENU3) pContextMenu;
	}
	else
		OldWndProc = NULL;

	UINT idCommand = m_Menu->TrackPopupMenu (TPM_RETURNCMD | TPM_LEFTALIGN, pt.x, pt.y, pWnd);

	if (OldWndProc) // unsubclass
		SetWindowLong (pWnd->m_hWnd, GWL_WNDPROC, (DWORD) OldWndProc);

	if (idCommand >= MIN_ID && idCommand <= MAX_ID)	// see if returned idCommand belongs to shell menu entries
	{
		InvokeCommand (pContextMenu, idCommand - MIN_ID);	// execute related command
		idCommand = 0;
	}
	
	pContextMenu->Release();
	g_IContext2 = NULL;
	g_IContext3 = NULL;

	return (idCommand);
}
开发者ID:cugxiangzhenwei,项目名称:MySrcCode,代码行数:48,代码来源:ShellContextMenu.cpp

示例6: DriveBox_PropertyDlg

//  Shows standard Win95 Property Dlg for selected Drive
BOOL DriveBox_PropertyDlg(HWND hwnd) {
    COMBOBOXEXITEM cbei;
    LPDC_ITEMDATA lpdcid;
    int iItem;
    LPCONTEXTMENU lpcm;
    CMINVOKECOMMANDINFO cmi;
    BOOL bSuccess = TRUE;

    static const char* lpVerb = "properties";

    iItem = (int)SendMessage(hwnd, CB_GETCURSEL, 0, 0);

    if (iItem == CB_ERR)
        return FALSE;

    cbei.mask = CBEIF_LPARAM;
    cbei.iItem = iItem;
    SendMessage(hwnd, CBEM_GETITEM, 0, (LPARAM)&cbei);
    lpdcid = (LPDC_ITEMDATA)cbei.lParam;

    if (NOERROR ==
        lpdcid->lpsf->GetUIObjectOf(GetParent(hwnd),               // Owner
                                    1,                             // Number of objects
                                    (LPCITEMIDLIST*)&lpdcid->pidl, // pidl
                                    IID_IContextMenu, NULL, (void**)&lpcm)) {

        cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
        cmi.fMask = 0;
        cmi.hwnd = GetParent(hwnd);
        cmi.lpVerb = lpVerb;
        cmi.lpParameters = NULL;
        cmi.lpDirectory = NULL;
        cmi.nShow = SW_SHOWNORMAL;
        cmi.dwHotKey = 0;
        cmi.hIcon = NULL;

        if (NOERROR != lpcm->InvokeCommand(&cmi))
            bSuccess = FALSE;

        lpcm->Release();

    } else
        bSuccess = FALSE;

    return bSuccess;
}
开发者ID:vehar,项目名称:velociraptor8,代码行数:47,代码来源:Dlapi.cpp

示例7: ShowContextMenu

UINT CShellContextMenu::ShowContextMenu(CWnd *pWnd, POINT pt)
{
	int iMenuType = 0;	// to know which version of IContextMenu is supported
	LPCONTEXTMENU pContextMenu;	// common pointer to IContextMenu and higher version interface
   
	if (!GetContextMenu ((void**) &pContextMenu, iMenuType))	
		return (0);	// something went wrong

    if (!m_Menu)
    {
        delete m_Menu;
        m_Menu = NULL;
        m_Menu = new CMenu;
        m_Menu->CreatePopupMenu ();
        m_Menu->AppendMenu(MF_STRING, WM_MENU_FILE,_T("打开文件所在目录"));

        // lets fill the our popupmenu
        pContextMenu->QueryContextMenu(m_Menu->m_hMenu, m_Menu->GetMenuItemCount(), MIN_ID, MAX_ID, CMF_NORMAL | CMF_EXPLORE);
    }

	if (iMenuType > 1)	// only subclass if its version 2 or 3
	{
		if (iMenuType == 2)
			g_IContext2 = (LPCONTEXTMENU2) pContextMenu;
		else	// version 3
			g_IContext3 = (LPCONTEXTMENU3) pContextMenu;
	}


	UINT idCommand = m_Menu->TrackPopupMenu (TPM_RETURNCMD | TPM_LEFTALIGN, pt.x, pt.y, pWnd);

	if (idCommand >= MIN_ID && idCommand <= MAX_ID)	// see if returned idCommand belongs to shell menu entries
	{
		InvokeCommand (pContextMenu, idCommand - MIN_ID);	// execute related command
		idCommand = 0;
	}
	
	pContextMenu->Release();
	g_IContext2 = NULL;
	g_IContext3 = NULL;

	return (idCommand);
}
开发者ID:tempbottle,项目名称:TestSet,代码行数:43,代码来源:ShellContextMenu.cpp

示例8: ExecCommandOnSelection

BOOL CRecBinViewer::ExecCommandOnSelection (LPCTSTR lpszCommand)
{
	if (!m_pGridCtrl)
		return false;

	int nItems = m_List.size();
	LPITEMIDLIST *pidlArray = (LPITEMIDLIST *) malloc ( (nItems) * sizeof (LPITEMIDLIST));
	int selCount = 0;
	for (POSITION pos = m_pGridCtrl->m_SelectedCellMap.GetStartPosition(); pos != NULL; )
    {
		DWORD key;
        CCellID cell;
        m_pGridCtrl->m_SelectedCellMap.GetNextAssoc(pos, key, (CCellID&)cell);
		if (cell.col == 0)  
		{
			pidlArray[selCount] =  m_List[cell.row -1].m_PIDL;
			selCount++;
		}		
    }

	HRESULT hr = S_OK;
	LPCONTEXTMENU pCtxMenu = NULL;

	if (NULL != m_pFolder2)
		hr = m_pFolder2->GetUIObjectOf (m_hWnd, selCount, (LPCITEMIDLIST *)pidlArray, IID_IContextMenu, NULL, (LPVOID *)&pCtxMenu);	
	else
		hr = m_pRecycleBin->GetUIObjectOf (m_hWnd, selCount, (LPCITEMIDLIST *)pidlArray, IID_IContextMenu, NULL, (LPVOID *)&pCtxMenu);
	
	BOOL bReturn = FALSE;

	if (SUCCEEDED (hr))	
		bReturn = ExecCommand (pCtxMenu, lpszCommand);
	
	pCtxMenu->Release();
	free (pidlArray);

	return bReturn;
}
开发者ID:avrionov,项目名称:explorerxp,代码行数:38,代码来源:RecBinViewer.cpp

示例9: OnNotify


//.........这里部分代码省略.........
                        }
                        break;
                    default:
                        {
                        }
                    }
                }
                m_pidlManager.Delete( pItem );
                pItem = NULL;
            }
        }
        else if( pNmhdr->code == NM_RCLICK )
        {
            LPITEMIDLIST* ppIdl = NULL;
            int nSelCount = ListView_GetSelectedCount(m_hWnd);
            if ( nSelCount > 0 )
            {
                ppIdl = (LPITEMIDLIST*)_Module.m_Allocator.Alloc( sizeof(LPITEMIDLIST)*nSelCount );
                int iIndex = ListView_GetNextItem( m_hWnd, -1, LVIS_SELECTED );
                LV_ITEM item = {0};
                item.iSubItem = 0;
                item.mask = LVIF_PARAM;
                int _i = 0;
                while( iIndex >= 0 
                    && _i < nSelCount )
                {    
                    item.iItem = iIndex;
                    ListView_GetItem( m_hWnd, &item );
                    ppIdl[_i] = m_pidlManager.Copy( ITEMLISTPTR(item.lParam) );
                    ++_i;
                    iIndex = ListView_GetNextItem( m_hWnd, -1, LVIS_SELECTED );
                }
            }
            LPCONTEXTMENU pMenu = NULL;
            HRESULT hr = E_FAIL;
            hr = m_pFolder->GetUIObjectOf( m_hWnd, nSelCount, \
                (LPCITEMIDLIST*)ppIdl, IID_IContextMenu, NULL, (void**)&pMenu );
            if ( FAILED(hr)
                || !pMenu)
            {
                LOG(_T("IID_IContextMenu Failed"));
                if ( nSelCount > 0 )
                {
                    for ( int _i = 0; _i < nSelCount; ++_i )
                    {
                        m_pidlManager.Delete( ppIdl[_i] );
                    }
                    _Module.m_Allocator.Free( ppIdl );
                }
                return S_OK;
            }
            HMENU hMenu = ::CreatePopupMenu();
            if ( !hMenu )
            {
                if ( nSelCount > 0 )
                {
                    for ( int _i = 0; _i < nSelCount; ++_i )
                    {
                        m_pidlManager.Delete( ppIdl[_i] );
                    }
                    _Module.m_Allocator.Free( ppIdl );
                }
                return S_OK;
            }
            hr = pMenu->QueryContextMenu( hMenu, 0, 10, 32767, CMF_NORMAL | CMF_EXPLORE );
            if ( FAILED(hr) )
            {
                if ( nSelCount > 0 )
                {
                    for ( int _i = 0; _i < nSelCount; ++_i )
                    {
                        m_pidlManager.Delete( ppIdl[_i] );
                    }
                    _Module.m_Allocator.Free( ppIdl );
                }
                DestroyMenu( hMenu );
                return hr;
            }
            POINT point = {0};
            GetCursorPos( &point );
            UINT command = (UINT)TrackPopupMenu ( hMenu, TPM_RETURNCMD | TPM_LEFTALIGN, point.x, point.y, 0, m_hWnd, NULL );
            CMINVOKECOMMANDINFO cmi = {0};
            cmi.cbSize = sizeof (CMINVOKECOMMANDINFO);
            cmi.lpVerb = (LPSTR) MAKEINTRESOURCE (command-10);
            cmi.nShow = SW_SHOWNORMAL;
            pMenu->InvokeCommand( &cmi );
            pMenu->Release();
            if ( nSelCount > 0 )
            {
                for ( int _i = 0; _i < nSelCount; ++_i )
                {
                    m_pidlManager.Delete( ppIdl[_i] );
                }
                _Module.m_Allocator.Free( ppIdl );
            }
            DestroyMenu( hMenu );
        }
    }
    TRACE_RETURN S_OK;
}
开发者ID:winwingy,项目名称:Study,代码行数:101,代码来源:SEShellView.cpp

示例10: InvokeCommand


//.........这里部分代码省略.........
Carries out the command associated with a context menu item. 

Returns NOERROR if successful, or an OLE-defined error code otherwise. 

lpici	-	Address of a CMINVOKECOMMANDINFO structure containing information about 
			the command. 
			
			 typedef struct _CMInvokeCommandInfo{ 
				DWORD cbSize; 
				DWORD fMask; 
				HWND hwnd; 
				LPCSTR lpVerb; 
				LPCSTR lpParameters; 
				LPCSTR lpDirectory; 
				int nShow; 
				DWORD dwHotKey; 
				HANDLE hIcon; 
			} CMINVOKECOMMANDINFO, *LPCMINVOKECOMMANDINFO; 

			Contains information about a context menu command. 

			cbSize			-	Contains the size of this structure, in bytes. 
			fMask			-	Zero, or one or more of the following flags: 
								CMIC_MASK_HOTKEY	-	The dwHotKey member is valid.  
								CMIC_MASK_ICON		-	The hIcon member is valid.  
								CMIC_MASK_FLAG_NO_UI-	The system is prevented from 
														displaying user interface 
														elements (for example, error 
														messages) while carrying out 
														a command.  

			hwnd			-	Handle of the window that is the owner of the context 
								menu. An extension can also use this handle as the 
								owner of any message boxes or dialog boxes it displays. 
			lpVerb			-	A 32-bit value that contains zero in the high-order 
								word and a menu-identifier offset of the command to 
								carry out in the low-order word. The shell specifies 
								this value (using the MAKEINTRESOURCE macro) when the 
								user chooses a menu command. If the high-order word 
								is not zero, this member is the address of a 
								null-terminated string specifying the 
								language-independent name of the command to carry out. 
								This member is typically a string when a command is 
								being activated by an application. The system provides 
								predefined constant values for the following command 
								strings. 

								Value				String  
								CMDSTR_NEWFOLDER	"NewFolder"  
								CMDSTR_VIEWDETAILS  "ViewDetails"  
								CMDSTR_VIEWLIST		"ViewList"  

			lpParameters	-	Optional parameters. This member is always NULL for 
								menu items inserted by a shell extension. 
			lpDirectory		-	Optional working directory name. This member is always 
								NULL for menu items inserted by a shell extension. 
			nShow			-	Set of SW_ values to pass to the ShowWindow function 
								if the command displays a window or starts an 
								application. 
			dwHotKey		-	Optional hot key to assign to any application 
								activated by the command. If the fMask parameter does 
								not specify CMIC_MASK_HOTKEY, this member is ignored. 
			hIcon			-	Icon to use for any application activated by the 
								command. If the fMask member does not specify 
								CMIC_MASK_ICON, this member is ignored. 


The shell calls this method when the user chooses a command that the handler added 
to a context menu. This method may also be called by an application without any 
corresponding user action. 
*/
	HMENU hMenu=::CreatePopupMenu();
	if(hMenu==NULL)
	{
		TRACE(_T("COXShellNamespaceNavigator::GetObjectContextMenu: CreatePopupMenu() failed\n"));
		return NULL;
	}

	hResult=lpcm->QueryContextMenu(hMenu,0,1,0x7fff,dwFlags);
	if(FAILED(hResult))  
	{
		TRACE(_T("COXShellNamespaceNavigator::GetObjectContextMenu: QueryContextMenu() failed\n"));
		::DestroyMenu(hMenu);
		return NULL;
	}
	
	hResult=lpcm->InvokeCommand(&cmici);

	::DestroyMenu(hMenu);

	lpcm->Release();

	if(FAILED(hResult))  
	{
		TRACE(_T("COXShellNamespaceNavigator::InvokeCommand: InvokeCommand() failed\n"));
		return FALSE;
	}

	return TRUE;
}
开发者ID:drupalhunter-team,项目名称:TrackMonitor,代码行数:101,代码来源:OXShellNamespaceNavigator.cpp

示例11: GetUIObjectOf


//.........这里部分代码省略.........
IQueryInfo				The cidl parameter can only be one.  
*/
	LPCONTEXTMENU lpcm;
    HRESULT hResult=lpParentFolder->
		GetUIObjectOf(m_pOwnerWnd!=NULL ? m_pOwnerWnd->GetSafeHwnd() : NULL, 1,
		(const struct _ITEMIDLIST**)&(lpRelativeIDL),IID_IContextMenu,0,
		(LPVOID*)&lpcm);
	if(FAILED(hResult))  
		return NULL;

	// Use IContextMenu::QueryContextMenu method to get handle to popup menu.
	//
/*
HRESULT QueryContextMenu(
    HMENU hmenu,
    UINT indexMenu,
    UINT idCmdFirst,
    UINT idCmdLast,
    UINT uFlags
   );

Adds menu items to the specified menu. The menu items should be inserted in the menu 
at the position specified by indexMenu, and their menu item identifiers must be 
between the idCmdFirst and idCmdLast parameter values. 

Returns an HRESULT structure in which, if the method is successful, the code member 
contains the menu identifier of the last menu item added plus one. 

hmenu		-	Handle to the menu. The handler should specify this handle when 
				adding menu items. 
indexMenu	-	Zero-based position at which to insert the first menu item. 
idCmdFirst	-	Minimum value that the handler can specify for a menu item identifier. 
idCmdLast	-	Maximum value that the handler can specify for a menu item identifier. 
uFlags		-	Optional flags specifying how the context menu can be changed. Can be 
				any combination of the following values: 
				CMF_CANRENAME		-	This flag is set if the calling application 
										supports renaming of items. A context menu 
										extension or drag-and-drop handler should 
										ignore this flag. A namespace extension should 
										add a rename item to the menu if applicable.  
				CMF_DEFAULTONLY		-	This flag is set when the user is activating 
										the default action, typically by 
										double-clicking. This flag provides a hint for 
										the context menu extension to add nothing if 
										it does not modify the default item in the 
										menu. A context menu extension or 
										drag-and-drop handler should not add any menu 
										items if this value is specified. A namespace 
										extension should add only the default item 
										(if any).  
				CMF_EXPLORE			-	This flag is set when Windows Explorer's tree 
										window is present. Context menu handlers 
										should ignore this value.  
				CMF_INCLUDESTATIC	-	This flag is set when a static menu is being 
										constructed. Only the browser should use this 
										flag. All other context menu extensions should 
										ignore this flag.  
				CMF_NODEFAULT		-	This flag is set if no item in the menu should 
										be the default item. A context menu extension 
										or drag-and-drop handler should ignore this 
										flag. A namespace extension should not set 
										any of the menu items to the default.  
				CMF_NORMAL			-	Indicates normal operation. A context menu 
										extension, namespace extension, or 
										drag-and-drop handler can add all menu items.  
				CMF_NOVERBS			-	This flag is set for items displayed in the 
										"Send To:" menu. Context menu handlers should 
										ignore this value.  
				CMF_VERBSONLY		-	This flag is set if the context menu is for a 
										shortcut object. Context menu handlers should 
										ignore this value.  

The remaining bits of the low-order word are reserved by the system. The high-order 
word may be used for context-specific communications. The CMF_RESERVED value can be 
used to mask out the low-order word. 

The actual identifier of each menu item should be idCmdFirst plus a menu identifier 
offset in the range zero through (idCmdLast ... idCmdFirst). 
*/
	//
	// Create popup menu and populate it using above described method

	HMENU hMenu=::CreatePopupMenu();
	if(hMenu==NULL)
	{
		TRACE(_T("COXShellNamespaceNavigator::GetObjectContextMenu: CreatePopupMenu() failed\n"));
		return NULL;
	}

	hResult=lpcm->QueryContextMenu(hMenu,0,1,0x7fff,dwFlags);
	if(FAILED(hResult))  
	{
		TRACE(_T("COXShellNamespaceNavigator::GetObjectContextMenu: QueryContextMenu() failed\n"));
		return NULL;
	}

	lpcm->Release();

	return hMenu;
}
开发者ID:drupalhunter-team,项目名称:TrackMonitor,代码行数:101,代码来源:OXShellNamespaceNavigator.cpp


注:本文中的LPCONTEXTMENU::Release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。