xpr_bool_t Pidl::getInfotip(LPSHELLFOLDER aShellFolder, LPCITEMIDLIST aPidl, xpr::string &aInfotip) { xpr_bool_t sResult = XPR_FALSE; IQueryInfo *sQueryInfo = XPR_NULL; HRESULT sComResult; sComResult = aShellFolder->GetUIObjectOf( XPR_NULL, 1, (LPCITEMIDLIST *)&aPidl, IID_IQueryInfo, 0, (LPVOID *)&sQueryInfo); if (SUCCEEDED(sComResult) && XPR_IS_NOT_NULL(sQueryInfo)) { xpr_wchar_t *sWideInfotip = XPR_NULL; sComResult = sQueryInfo->GetInfoTip(SHGDN_INFOLDER, &sWideInfotip); if (SUCCEEDED(sComResult) && XPR_IS_NOT_NULL(sWideInfotip)) { xpr_size_t sInfotipLen = wcslen(sWideInfotip); if (sInfotipLen != 0) { aInfotip.clear(); aInfotip.reserve(sInfotipLen + 1); xpr_tchar_t *sInfotip = (xpr_tchar_t *)aInfotip.c_str(); xpr_size_t sInputBytes = sInfotipLen * sizeof(xpr_wchar_t); xpr_size_t sOutputBytes = sInfotipLen * sizeof(xpr_tchar_t); XPR_UTF16_TO_TCS(sWideInfotip, &sInputBytes, sInfotip, &sOutputBytes); sInfotip[sOutputBytes / sizeof(xpr_tchar_t)] = 0; aInfotip.update(); sResult = XPR_TRUE; } } COM_FREE(sWideInfotip); } COM_RELEASE(sQueryInfo); return sResult; }
// IShellFolder + PIDL -> full qualified PIDL LPITEMIDLIST Pidl::getFullPidl(LPSHELLFOLDER aShellFolder, LPCITEMIDLIST aSimplePidl) { if (XPR_IS_NULL(aShellFolder) || XPR_IS_NULL(aSimplePidl)) { return XPR_NULL; } LPITEMIDLIST sFullPidl = XPR_NULL; IDataObject *sDataObject = XPR_NULL; HRESULT sComResult; sComResult = aShellFolder->GetUIObjectOf(0, 1, &aSimplePidl, IID_IDataObject, 0, (LPVOID *)&sDataObject); if (SUCCEEDED(sComResult)) { FORMATETC sFormatEtc = {0}; sFormatEtc.cfFormat = RegisterClipboardFormat(CFSTR_SHELLIDLIST); sFormatEtc.ptd = XPR_NULL; sFormatEtc.dwAspect = DVASPECT_CONTENT; sFormatEtc.lindex = -1; sFormatEtc.tymed = TYMED_HGLOBAL; STGMEDIUM sStgMedium = {0,}; sComResult = sDataObject->GetData(&sFormatEtc, &sStgMedium); if (SUCCEEDED(sComResult)) { LPIDA sPida = (LPIDA)::GlobalLock(sStgMedium.hGlobal); LPCITEMIDLIST sFolderPidl = (LPCITEMIDLIST)((xpr_byte_t *)sPida + sPida->aoffset[0]); LPCITEMIDLIST sChildPidl = (LPCITEMIDLIST)((xpr_byte_t *)sPida + sPida->aoffset[1]); sFullPidl = concat(sFolderPidl, sChildPidl); ::GlobalUnlock(sStgMedium.hGlobal); if (XPR_IS_NOT_NULL(sStgMedium.pUnkForRelease)) { ::ReleaseStgMedium(&sStgMedium); } } COM_RELEASE(sDataObject); } return sFullPidl; }
BOOL CShellMgr::DoContextMenu(HWND hWnd, LPSHELLFOLDER lpsfParent, LPITEMIDLIST lpi, POINT point) { CComPtr<IContextMenu> spContextMenu; HRESULT hr = lpsfParent->GetUIObjectOf(hWnd, 1, (const struct _ITEMIDLIST**)&lpi, IID_IContextMenu, 0, (LPVOID*)&spContextMenu); if(FAILED(hr)) return FALSE; HMENU hMenu = ::CreatePopupMenu(); if(hMenu == NULL) return FALSE; // Get the context menu for the item. hr = spContextMenu->QueryContextMenu(hMenu, 0, 1, 0x7FFF, CMF_EXPLORE); if(FAILED(hr)) return FALSE; int idCmd = ::TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON, point.x, point.y, 0, hWnd, NULL); if (idCmd != 0) { USES_CONVERSION; // Execute the command that was selected. CMINVOKECOMMANDINFO cmi = { 0 }; cmi.cbSize = sizeof(CMINVOKECOMMANDINFO); cmi.fMask = 0; cmi.hwnd = hWnd; cmi.lpVerb = T2CA(MAKEINTRESOURCE(idCmd - 1)); cmi.lpParameters = NULL; cmi.lpDirectory = NULL; cmi.nShow = SW_SHOWNORMAL; cmi.dwHotKey = 0; cmi.hIcon = NULL; hr = spContextMenu->InvokeCommand(&cmi); } ::DestroyMenu(hMenu); return TRUE; }
HBITMAP ExtractThumb(LPSHELLFOLDER psfFolder, LPCITEMIDLIST localPidl ) { LPEXTRACTIMAGE pIExtract = NULL; HRESULT hr; hr = psfFolder->GetUIObjectOf(NULL, 1, &localPidl, IID_IExtractImage, NULL, (void**)&pIExtract); if(NULL == pIExtract) // early shell version, thumbs not supported return NULL; OLECHAR wszPathBuffer[MAX_PATH]; DWORD dwPriority = 0; // IEI_PRIORITY_NORMAL is defined nowhere! DWORD dwFlags = IEIFLAG_SCREEN; HBITMAP hBmpImage = NULL; SIZE prgSize = {500, 500}; hr = pIExtract->GetLocation(wszPathBuffer, MAX_PATH, &dwPriority, &prgSize, 32, &dwFlags); if(NOERROR == hr) hr = pIExtract->Extract(&hBmpImage); pIExtract->Release(); return hBmpImage; // callers should DeleteObject this handle after use }
BOOL showContextMenu (HWND hDlg, TCHAR* FName, WNDPROC menuProc) { TCHAR* FileName = PathFindFileName (FName); TCHAR FilePath [MAX_PATH]; lstrcpy (FilePath, FName); *PathFindFileName (FilePath) = L'\0'; LPSHELLFOLDER DesktopFolder; if (NOERROR != SHGetDesktopFolder (&DesktopFolder)) { return FALSE; } LPITEMIDLIST ParentPidl; ULONG Eaten; if (S_OK != DesktopFolder->ParseDisplayName (hDlg, 0, FilePath, &Eaten, &ParentPidl, 0)) { return FALSE; } LPSHELLFOLDER ParentFolder; if (S_OK != DesktopFolder->BindToObject (ParentPidl, 0, IID_IShellFolder, (void**)&ParentFolder)) { return FALSE; } LPITEMIDLIST Pidl; if (S_OK != ParentFolder->ParseDisplayName (hDlg, 0, FileName, &Eaten, &Pidl, 0)) { return FALSE; } LPCONTEXTMENU CM; if (S_OK != ParentFolder->GetUIObjectOf (hDlg, 1, (LPCITEMIDLIST*)&Pidl, IID_IContextMenu, 0, (void**)&CM)) { return FALSE; } HMENU hMenu = CreatePopupMenu (); if (hMenu == NULL) { return FALSE; } CM->QueryContextMenu (hMenu, 0, 1, 0x7FFF, CMF_EXTENDEDVERBS | CMF_EXPLORE); WNDPROC defWndProc = (WNDPROC) SetWindowLong (hDlg, GWL_WNDPROC, (LONG)menuProc); SetProp (hDlg, L"defWndProc", (HANDLE) defWndProc); POINT pt; GetCursorPos (&pt); int Cmd = TrackPopupMenu (hMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, hDlg, 0); SetWindowLong (hDlg, GWL_WNDPROC, (LONG) RemoveProp (hDlg, L"defWndProc")); if (Cmd) { // Set up a CMINVOKECOMMANDINFO structure. CMINVOKECOMMANDINFO CI; ZeroMemory (&CI, sizeof(CMINVOKECOMMANDINFO)); CI.cbSize = sizeof (CMINVOKECOMMANDINFO); CI.hwnd = hDlg; CI.lpVerb = (LPCSTR) MAKEINTRESOURCE(Cmd - 1); CI.lpParameters = ""; CI.lpDirectory = ""; CI.nShow = SW_SHOWNORMAL; CM->InvokeCommand (&CI); } return DestroyMenu (hMenu); }
CPlugin::EDoMenu CPlugin::DoMenu(LPSHELLFOLDER pCurFolder, LPCITEMIDLIST* pPiids, LPCWSTR pFiles[], unsigned nFiles, unsigned nFolders, LPCWSTR szCommand/*=NULL*/, EAutoItem enAutoItem/*=AI_NONE*/) { assert(nFolders+nFiles); auto_sz strMnuTitle; if (nFolders+nFiles==1) { strMnuTitle=pFiles[0]; if (nFolders) { strMnuTitle.RemoveTrailing(L'\\'); strMnuTitle+=L"\\"; } } else { auto_sz strFiles; strFiles.Realloc(20); wsprintf(strFiles, L"%u %s", nFiles, GetMsg(LNG_FILES)); auto_sz strFolders; strFolders.Realloc(20); wsprintf(strFolders, L"%u %s", nFolders, GetMsg(LNG_FOLDERS)); if (nFiles) { strMnuTitle+=strFiles; } if (nFolders) { if (nFiles) strMnuTitle+=L", "; strMnuTitle+=strFolders; } } IContextMenuPtr pCMenu1; if (FAILED(pCurFolder->GetUIObjectOf(NULL_HWND, nFolders+nFiles, pPiids, IID_IContextMenu, 0, reinterpret_cast<void**>(&pCMenu1)))) { return DOMNU_ERR_SHOW; } LPCONTEXTMENU pPreferredMenu=pCMenu1; IContextMenu2Ptr pCMenu2(pCMenu1); if (pCMenu2) { pPreferredMenu=pCMenu2; } IContextMenu3Ptr pCMenu3(pCMenu1); if (pCMenu3) { pPreferredMenu=pCMenu3; } // Решение дурацкой проблемы с падением в 2000 на paste if (m_bWin2K) pCMenu1.Detach(); CHMenu oHMenu; if (!oHMenu) return DOMNU_ERR_SHOW; enum {EMENU_CMF_EXTENDEDVERBS=0x00000100}; // rarely used verbs if (!pPreferredMenu || FAILED(pPreferredMenu->QueryContextMenu(oHMenu, 0, MENUID_CMDOFFSET, 0x7FFF, CMF_CANRENAME|(GetKeyState(VK_SHIFT)&0xF000?EMENU_CMF_EXTENDEDVERBS:0)))) { return DOMNU_ERR_SHOW; } int nCmd=0; if (szCommand) { for (int i=0; i<oHMenu.GetMenuItemCount(); i++) { MENUITEMINFO mii={0}; mii.cbSize=sizeof(mii); mii.fMask=MIIM_ID|MIIM_STATE; if (!GetMenuItemInfo(oHMenu, i, TRUE, &mii)) return DOMNU_ERR_INVOKE; if (mii.fState&MFS_DISABLED) continue; auto_sz strAutoItem; switch (enAutoItem) { case AI_VERB: if (!GetAdditionalString(pPreferredMenu, mii.wID-MENUID_CMDOFFSET, AS_VERB, &strAutoItem)) { continue; } break; case AI_ITEM: { int nLen=GetMenuString(oHMenu, i, NULL, 0, MF_BYPOSITION); if (!nLen) continue; ++nLen; strAutoItem.Realloc(nLen); if (!GetMenuString(oHMenu, i, strAutoItem, nLen, MF_BYPOSITION)) { continue; } } break; default: assert(0); break; } if (strAutoItem.CompareExcluding(szCommand, L'&')) { nCmd=mii.wID; break; } } if (nCmd<MENUID_CMDOFFSET) return DOMNU_ERR_INVOKE; } else { int nSelItem=0; CFarMenu oTypeMenu(g_szTopicChooseMenuType, &GuiTextMenuGuid); oTypeMenu.AddItem(GetMsg(LNG_MNU_GUI)); oTypeMenu.AddItem(GetMsg(LNG_MNU_TEXT)); while (1) { bool bGUI; if(2!=m_UseGUI) { bGUI=(0!=m_UseGUI); } else { nSelItem=OleThread::ShowMenu(oTypeMenu,strMnuTitle, nSelItem, m_GuiPos==0); switch (nSelItem) { case CFarMenu::SHOW_CANCEL: return DOMENU_CANCELLED; case CFarMenu::SHOW_BACK: return DOMENU_BACK; case 0: bGUI=true; break; case 1: bGUI=false; break; } } if (bGUI) { if (!ShowGuiMenu(oHMenu, pCMenu1, pCMenu2, pCMenu3, &nCmd)) { return DOMNU_ERR_SHOW; } } else { if (!ShowTextMenu(oHMenu, pPreferredMenu, pCMenu2, pCMenu3, &nCmd, strMnuTitle, pCurFolder, pPiids, nFolders+nFiles)) { return DOMNU_ERR_SHOW; } } if (nCmd==MENUID_CANCELLED) { return DOMENU_CANCELLED; } if (nCmd!=MENUID_BACK) { break; } } } if (nCmd>=MENUID_CMDOFFSET) { int nId=nCmd-MENUID_CMDOFFSET; CHAR szVerb[100]; if (FAILED(pPreferredMenu->GetCommandString(nId, GCS_VERBA, NULL, szVerb, ARRAYSIZE(szVerb)))) { szVerb[0]='\0'; } if (lstrcmpA(szVerb, "rename")==0) { MacroSendMacroText mcmd = {sizeof(MacroSendMacroText), 0, {0}, L"Keys'F6'"}; MacroControl(NULL, MCTL_SENDSTRING, MSSC_POST, &mcmd); return DOMENU_CANCELLED; } if (m_DelUsingFar && lstrcmpA(szVerb, "delete")==0) { MacroSendMacroText mcmd = {sizeof(MacroSendMacroText), 0, {0}, L"Keys'F8'"}; if (GetKeyState(VK_LSHIFT)&0x8000 || GetKeyState(VK_RSHIFT)&0x8000) { mcmd.SequenceText=L"Keys'ShiftDel'"; } else if (GetKeyState(VK_LMENU)&0x8000 || GetKeyState(VK_RMENU)&0x8000) { mcmd.SequenceText=L"Keys'AltDel'"; } MacroControl(NULL, MCTL_SENDSTRING, MSSC_POST, &mcmd); return DOMENU_CANCELLED; } else { CMINVOKECOMMANDINFO cmici; cmici.cbSize = sizeof(cmici); cmici.fMask = 0; cmici.hwnd = NULL_HWND; cmici.lpVerb = (LPCSTR)MAKEINTRESOURCE(nId); cmici.lpParameters = NULL; cmici.lpDirectory = NULL; cmici.nShow = SW_SHOWNORMAL; cmici.dwHotKey = 0; cmici.hIcon = NULL; if (FAILED(pPreferredMenu->InvokeCommand(&cmici))) { // return DOMNU_ERR_INVOKE; // Иногда здесь возвращается ошибка даже в // нормальных ситуациях. // Например, если занести это в реестр //[HKEY_CLASSES_ROOT\AllFileSystemObjects\shellex\ContextMenuHandlers\Copy To] //@="{C2FBB630-2971-11D1-A18C-00C04FD75D13}" //[HKEY_CLASSES_ROOT\AllFileSystemObjects\shellex\ContextMenuHandlers\Move To] //@="{C2FBB631-2971-11D1-A18C-00C04FD75D13}" // , а потом вызвать один из добавившихся пунктов // и нажать Esc. } // Эта функция решает проблему, когда // после помещения файла в буфер и выхода из FARа // буфер портился. // проблема точно проявлялась на Build950 и XP if (FAILED(OleFlushClipboard())) { // иногда бывает E_FAIL //assert(0); } } } return DOMNU_OK; }
void BookmarkToolBar::OnDropTarget(COleDataObject *aOleDataObject, DROPEFFECT aDropEffect, CPoint aPoint, xpr_sint_t aBookmark) { if (aOleDataObject == XPR_NULL) return; BookmarkItem *sBookmarkItem = BookmarkMgr::instance().getBookmark(aBookmark); if (sBookmarkItem == XPR_NULL) return; LPITEMIDLIST sFullPidl = Path2Pidl(sBookmarkItem->mPath); if (sFullPidl != XPR_NULL) { xpr_bool_t sResult; LPSHELLFOLDER sShellFolder = XPR_NULL; LPCITEMIDLIST sPidl = XPR_NULL; sResult = fxfile::base::Pidl::getSimplePidl(sFullPidl, sShellFolder, sPidl); if (XPR_IS_TRUE(sResult)) { POINTL sPointL = {0}; ClientToScreen(&aPoint); sPointL.x = aPoint.x; sPointL.y = aPoint.y; DWORD sKeyState = mDropTarget.isRightDrag() ? MK_RBUTTON : MK_LBUTTON; DWORD sTempEffect = DROPEFFECT_MOVE; switch (aDropEffect) { case DROPEFFECT_MOVE: sKeyState |= MK_SHIFT; break; case DROPEFFECT_COPY: sKeyState |= MK_CONTROL; break; case DROPEFFECT_LINK: sKeyState |= MK_SHIFT | MK_CONTROL; break; } LPDROPTARGET sDropTarget = XPR_NULL; HRESULT sHResult = sShellFolder->GetUIObjectOf( GetSafeHwnd(), 1, (LPCITEMIDLIST*)&sPidl, IID_IDropTarget, XPR_NULL, (LPVOID*)&sDropTarget); if (SUCCEEDED(sHResult) && sDropTarget != XPR_NULL) { LPDATAOBJECT sDataObject = aOleDataObject->Detach(); if (sDataObject != XPR_NULL) { sDropTarget->DragEnter(sDataObject, sKeyState, sPointL, &sTempEffect); sDropTarget->DragOver(sKeyState, sPointL, &sTempEffect); if (mDropTarget.isRightDrag() == XPR_TRUE) aDropEffect = DROPEFFECT_MOVE | DROPEFFECT_COPY | DROPEFFECT_LINK; sDropTarget->Drop(sDataObject, sKeyState, sPointL, &aDropEffect); } } COM_RELEASE(sDropTarget); } COM_RELEASE(sShellFolder); } COM_FREE(sFullPidl); }
DROPEFFECT BookmarkToolBar::OnDragOver(COleDataObject* aOleDataObject, DWORD aKeyState, CPoint aPoint) { DROPEFFECT sDropEffect = DROPEFFECT_LINK; DragImage &sDragImage = DragImage::instance(); if (sDragImage.isMyDragging() == XPR_TRUE) { CImageList *sMyDragImage = sDragImage.getMyDragImage(); if (XPR_IS_NOT_NULL(sMyDragImage)) { CPoint sDragPoint(aPoint); ClientToScreen(&sDragPoint); sMyDragImage->DragMove(sDragPoint); } } else { if (mDropTarget.isUseDropHelper() == XPR_TRUE) { CPoint sDragPoint(aPoint); mDropTarget.getDropHelper()->DragOver(&sDragPoint, sDropEffect); } } CToolBarCtrl &sToolBarCtrl = GetToolBarCtrl(); TBBUTTON sTbButton = {0}; TBINSERTMARK sTbInsertMark = {0}; xpr_sint_t sHitTest = GetToolBarCtrl().HitTest(&aPoint); xpr_sint_t sInsertHitTest = -1; if (sToolBarCtrl.InsertMarkHitTest(&aPoint, &sTbInsertMark) && sTbInsertMark.iButton >= 0) sInsertHitTest = sTbInsertMark.iButton; xpr_sint_t sBookmark, sInsert; if (XPR_TEST_BITS(aKeyState, MK_SHIFT) && XPR_TEST_BITS(aKeyState, MK_CONTROL)) { sInsert = -1; sBookmark = -1; } else { if (sHitTest < 0 || sInsertHitTest >= 0) { if (sTbInsertMark.dwFlags == TBIMHT_AFTER) { sTbInsertMark.dwFlags = 0; sInsertHitTest++; } if (sHitTest == -1) sInsertHitTest = -1; sInsert = sInsertHitTest; sBookmark = -1; } else { sInsert = -1; sBookmark = sHitTest; } } BookmarkMgr &sBookmarkMgr = BookmarkMgr::instance(); if (sBookmark >= sBookmarkMgr.getCount()) sBookmark = -1; if (sBookmark != -1) { sDropEffect = DROPEFFECT_LINK; BookmarkItem *sBookmarkItem = sBookmarkMgr.getBookmark(sBookmark); if (sBookmarkItem != XPR_NULL) { xpr_bool_t sGetPidl = XPR_TRUE; LPITEMIDLIST sFullPidl = XPR_NULL; if (IsNetItem(sBookmarkItem->mPath.c_str())) sGetPidl = WnetMgr::instance().isConnectedServer(sBookmarkItem->mPath); if (sGetPidl == XPR_TRUE) sFullPidl = Path2Pidl(sBookmarkItem->mPath); if (sFullPidl != XPR_NULL && IsFileSystemFolder(sFullPidl)) { sDropEffect = DROPEFFECT_MOVE; if (aKeyState & MK_ALT) sDropEffect = DROPEFFECT_LINK; else if (aKeyState & MK_CONTROL) sDropEffect = DROPEFFECT_COPY; else if (aKeyState & MK_SHIFT) sDropEffect = DROPEFFECT_MOVE; else { switch (gOpt->mConfig.mDragDefaultFileOp) { case DRAG_FILE_OP_DEFAULT: sDropEffect = DROPEFFECT_MOVE; break; case DRAG_FILE_OP_COPY: sDropEffect = DROPEFFECT_COPY; break; case DRAG_FILE_OP_LINK: sDropEffect = DROPEFFECT_LINK; break; default: sDropEffect = DROPEFFECT_MOVE; break; } } } else { HRESULT sHResult; LPSHELLFOLDER sShellFolder = XPR_NULL; LPCITEMIDLIST sPidl = XPR_NULL; fxfile::base::Pidl::getSimplePidl(sFullPidl, sShellFolder, sPidl); sHResult = E_FAIL; LPDROPTARGET sDropTarget = XPR_NULL; if (sShellFolder != XPR_NULL && sPidl != XPR_NULL) { sHResult = sShellFolder->GetUIObjectOf(GetSafeHwnd(), 1, (LPCITEMIDLIST *)&sPidl, IID_IDropTarget, XPR_NULL, (LPVOID *)&sDropTarget); } xpr_bool_t sSucceeded = XPR_FALSE; if (SUCCEEDED(sHResult) && sDropTarget != XPR_NULL) { POINTL sPointL = {0}; ClientToScreen(&aPoint); sPointL.x = aPoint.x; sPointL.y = aPoint.y; DWORD sTempDropEffect = DROPEFFECT_MOVE | DROPEFFECT_COPY | DROPEFFECT_LINK; sHResult = sDropTarget->DragEnter(aOleDataObject->m_lpDataObject, aKeyState, sPointL, &sTempDropEffect); if (SUCCEEDED(sHResult)) { sHResult = sDropTarget->DragOver(aKeyState, sPointL, &sTempDropEffect); sSucceeded = SUCCEEDED(sHResult) && sTempDropEffect != 0; } } COM_RELEASE(sDropTarget); COM_RELEASE(sShellFolder); if (sSucceeded == XPR_TRUE) sDropEffect = DROPEFFECT_MOVE; else { sBookmark = -1; sDropEffect = DROPEFFECT_NONE; } } COM_FREE(sFullPidl); } else { sBookmark = -1; sDropEffect = DROPEFFECT_NONE; } } if (sBookmark == -1) { // Insert Bookmark if (mOldBookmark >= 0) { sToolBarCtrl.GetButton(mOldBookmark, &sTbButton); sToolBarCtrl.SetState(sTbButton.idCommand, TBSTATE_ENABLED); } if (mOldInsert != sInsert) { sTbInsertMark.iButton = sInsert; sToolBarCtrl.SetInsertMark(&sTbInsertMark); } sDropEffect = DROPEFFECT_LINK; } else { // Run Program or File Operation if (mOldInsert >= 0) { sTbInsertMark.iButton = -1; sToolBarCtrl.SetInsertMark(&sTbInsertMark); } if (mOldBookmark != sBookmark) { sToolBarCtrl.GetButton(mOldBookmark, &sTbButton); sToolBarCtrl.SetState(sTbButton.idCommand, TBSTATE_ENABLED); sToolBarCtrl.GetButton(sBookmark, &sTbButton); sToolBarCtrl.SetState(sTbButton.idCommand, TBSTATE_MARKED | TBSTATE_PRESSED | TBSTATE_ENABLED); } } mOldInsert = sInsert; mOldBookmark = sBookmark; if (XPR_IS_NOT_NULL(mObserver)) { mObserver->onBookmarkToolBarStatus(*this, mOldBookmark, mOldInsert, sDropEffect); } return sDropEffect; }
/**************************************************************************** * * FUNCTION: DoTheMenuThing(HWND hwnd, * LPSHELLFOLDER lpsfParent, * LPITEMIDLIST lpi, * LPPOINT lppt) * * PURPOSE: Displays a popup context menu, given a parent shell folder, * relative item id and screen location. * * PARAMETERS: * hwnd - Parent window handle * lpsfParent - Pointer to parent shell folder. * lpi - Pointer to item id that is relative to lpsfParent * lppt - Screen location of where to popup the menu. * * RETURN VALUE: * Returns TRUE on success, FALSE on failure * ****************************************************************************/ BOOL CShellPidl::DoTheMenuThing(HWND hwnd, LPSHELLFOLDER lpsfParent, LPITEMIDLIST lpi, LPPOINT lppt) { LPCONTEXTMENU lpcm; HRESULT hr; char szTemp[64]; CMINVOKECOMMANDINFO cmi; DWORD dwAttribs=0; int idCmd; HMENU hMenu; BOOL bSuccess=TRUE; hr=lpsfParent->GetUIObjectOf(hwnd, 1, //Number of objects to get attributes of (const struct _ITEMIDLIST **)&lpi, IID_IContextMenu, 0, (LPVOID *)&lpcm); if (SUCCEEDED(hr)) { hMenu = CreatePopupMenu(); if (hMenu) { hr=lpcm->QueryContextMenu(hMenu, 0, 1, 0x7fff, CMF_EXPLORE); if (SUCCEEDED(hr)) { idCmd=TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON, lppt->x, lppt->y, 0, hwnd, NULL); if (idCmd) { cmi.cbSize = sizeof(CMINVOKECOMMANDINFO); cmi.fMask = 0; cmi.hwnd = hwnd; cmi.lpVerb = MAKEINTRESOURCE(idCmd-1); cmi.lpParameters = NULL; cmi.lpDirectory = NULL; cmi.nShow = SW_SHOWNORMAL; cmi.dwHotKey = 0; cmi.hIcon = NULL; hr=lpcm->InvokeCommand(&cmi); if (!SUCCEEDED(hr)) { wsprintf(szTemp, "InvokeCommand failed. hr=%lx", hr); AfxMessageBox(szTemp); } } } else bSuccess = FALSE; DestroyMenu(hMenu); } else bSuccess = FALSE; lpcm->Release(); } else { wsprintf(szTemp, "GetUIObjectOf failed! hr=%lx", hr); AfxMessageBox(szTemp ); bSuccess = FALSE; } return bSuccess; }