VCommand* VCommandList::RetainCommand(const VString& inCommandID, bool inGlobalSearch) const { VCommand* com = _GetCommand(inCommandID, inGlobalSearch); if (com != NULL) com->Retain(); else if (inGlobalSearch && fParent != NULL) com = fParent->RetainCommand(inCommandID, true); if (com == NULL) com = VCommand::RetainNullCommand(); return com; }
STDMETHODIMP CExplorerCommandProvider::GetCommands(IUnknown* punkSite, REFIID riid, LPVOID* ppenumr) { ATLTRACE(L"CExplorerCommandProvider::GetCommands\n"); typedef CComEnum< IEnumExplorerCommand, &IID_IEnumExplorerCommand, IExplorerCommand*, _CopyInterface<IExplorerCommand> > CEnumCommands; HMENU hMenuPopup = ::GetSubMenu(m_hMenu, _T("CommandMenu")); CInterfaceArray<IExplorerCommand> aList; for( int i = 0; i < ::GetMenuItemCount(hMenuPopup); i++ ) { CComPtr<IExplorerCommand> spCommand; HR( _GetCommand(hMenuPopup, ::GetMenuItemID(hMenuPopup, i), IID_PPV_ARGS(&spCommand)) ); aList.Add(spCommand); } CComObject<CEnumCommands>* pEnumResources; HR( CComObject<CEnumCommands>::CreateInstance(&pEnumResources) ); HR( pEnumResources->Init(&aList.GetData()->p, &aList.GetData()->p + aList.GetCount(), NULL, AtlFlagCopy) ); return pEnumResources->QueryInterface(riid, ppenumr); }
STDMETHODIMP CExplorerCommandProvider::GetCommand(REFGUID rguidCommandId, REFIID riid, LPVOID* ppRetVal) { ATLTRACE(L"CExplorerCommandProvider::GetCommand\n"); HMENU hMenuPopup = ::GetSubMenu(m_hMenu, _T("CommandMenu")); return _GetCommand(hMenuPopup, CExplorerCommand::GetMenuID(rguidCommandId), riid, ppRetVal); }
void VCommandList::RemoveCommand(const VString& inID) { VCommand* command = _GetCommand(inID, false); if (command != NULL) RemoveCommand(command); }
bool VCommandList::HasCommand(const VString& inID, bool inGlobalSearch) const { VCommand* command = _GetCommand(inID, inGlobalSearch); return (command != NULL); }