BOOL IsNamespaceRoot(LPCITEMIDLIST pidl) { LPITEMIDLIST pidlDesktop = NULL; BOOL bNamespaceRoot = FALSE; HRESULT hr; hr = SHGetFolderLocation(NULL,CSIDL_DESKTOP,NULL,0,&pidlDesktop); if(SUCCEEDED(hr)) { bNamespaceRoot = CompareIdls(pidl,pidlDesktop); CoTaskMemFree(pidlDesktop); } return bNamespaceRoot; }
void Explorerplusplus::OnTreeViewHolderWindowTimer(void) { LPITEMIDLIST pidlDirectory = NULL; LPITEMIDLIST pidlCurrentDirectory = NULL; pidlDirectory = m_pMyTreeView->BuildPath(g_NewSelectionItem); pidlCurrentDirectory = m_pActiveShellBrowser->QueryCurrentDirectoryIdl(); if(!m_bSelectingTreeViewDirectory && !m_bTreeViewRightClick && !CompareIdls(pidlDirectory,pidlCurrentDirectory)) { BrowseFolder(pidlDirectory,SBSP_SAMEBROWSER); if(m_bTVAutoExpandSelected) { TreeView_Expand(m_hTreeView,g_NewSelectionItem,TVE_EXPAND); } } CoTaskMemFree(pidlDirectory); KillTimer(m_hHolder,0); }
/* Creates a new tab. If the settings argument is NULL, the global settings will be used. */ HRESULT Explorerplusplus::CreateNewTab(LPITEMIDLIST pidlDirectory, InitialSettings_t *pSettings,TabInfo_t *pTabInfo,BOOL bSwitchToNewTab, int *pTabObjectIndex) { UINT uFlags; HRESULT hr; InitialSettings_t is; int iNewTabIndex; int iTabId; if(!CheckIdl(pidlDirectory) || !IsIdlDirectory(pidlDirectory)) return E_FAIL; if(m_bOpenNewTabNextToCurrent) iNewTabIndex = m_iTabSelectedItem + 1; else iNewTabIndex = TabCtrl_GetItemCount(m_hTabCtrl); iTabId = GenerateUniqueTabId(); if(iTabId == -1) return E_FAIL; if(pTabInfo == NULL) { m_TabInfo[iTabId].bLocked = FALSE; m_TabInfo[iTabId].bAddressLocked = FALSE; m_TabInfo[iTabId].bUseCustomName = FALSE; } else { m_TabInfo[iTabId] = *pTabInfo; } m_hListView[iTabId] = CreateMainListView(m_hContainer,ListViewStyles); if(m_hListView[iTabId] == NULL) return E_FAIL; NListView::ListView_ActivateOneClickSelect(m_hListView[iTabId],m_bOneClickActivate,m_OneClickActivateHoverTime); /* Set the listview to its initial size. */ SetListViewInitialPosition(m_hListView[iTabId]); /* If no explicit settings are specified, use the global ones. */ if(pSettings == NULL) { BOOL bFound = FALSE; /* These settings are program-wide. */ is.bGridlinesActive = m_bShowGridlinesGlobal; is.bShowHidden = m_bShowHiddenGlobal; is.bShowInGroups = m_bShowInGroupsGlobal; is.bSortAscending = m_bSortAscendingGlobal; is.bAutoArrange = m_bAutoArrangeGlobal; is.bShowFolderSizes = m_bShowFolderSizes; is.bDisableFolderSizesNetworkRemovable = m_bDisableFolderSizesNetworkRemovable; is.bHideSystemFiles = m_bHideSystemFilesGlobal; is.bHideLinkExtension = m_bHideLinkExtensionGlobal; /* Check if there are any specific settings saved for the specified directory. */ for each(auto ds in m_DirectorySettingsList) { if(CompareIdls(pidlDirectory,ds.pidlDirectory)) { /* TODO: */ //bFound = TRUE; is.SortMode = ds.dsi.SortMode; is.ViewMode = ds.dsi.ViewMode; is.bApplyFilter = FALSE; is.bFilterCaseSensitive = FALSE; is.pControlPanelColumnList = &ds.dsi.ControlPanelColumnList; is.pMyComputerColumnList = &ds.dsi.MyComputerColumnList; is.pMyNetworkPlacesColumnList = &ds.dsi.MyNetworkPlacesColumnList; is.pNetworkConnectionsColumnList = &ds.dsi.NetworkConnectionsColumnList; is.pPrintersColumnList = &ds.dsi.PrintersColumnList; is.pRealFolderColumnList = &ds.dsi.RealFolderColumnList; is.pRecycleBinColumnList = &ds.dsi.RecycleBinColumnList; } } if(bFound) { /* There are existing settings for this directory, so use those, rather than the defaults. */ } else { is.SortMode = GetDefaultSortMode(pidlDirectory); is.ViewMode = m_ViewModeGlobal; is.bApplyFilter = FALSE; is.bFilterCaseSensitive = FALSE; StringCchCopy(is.szFilter,SIZEOF_ARRAY(is.szFilter),EMPTY_STRING); is.pControlPanelColumnList = &m_ControlPanelColumnList; is.pMyComputerColumnList = &m_MyComputerColumnList; is.pMyNetworkPlacesColumnList = &m_MyNetworkPlacesColumnList; is.pNetworkConnectionsColumnList = &m_NetworkConnectionsColumnList; is.pPrintersColumnList = &m_PrintersColumnList; is.pRealFolderColumnList = &m_RealFolderColumnList; is.pRecycleBinColumnList = &m_RecycleBinColumnList; } pSettings = &is; }
void TestCompareIdls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2, BOOL bExpected) { BOOL bRet = CompareIdls(pidl1, pidl2); EXPECT_EQ(bExpected, bRet); }
void inline CShellBrowser::InsertAwaitingItems(BOOL bInsertIntoGroup) { LVITEM lv; ULARGE_INTEGER ulFileSize; unsigned int nPrevItems; int nAdded = 0; int iItemIndex; nPrevItems = ListView_GetItemCount(m_hListView); m_nAwaitingAdd = (int)m_AwaitingAddList.size(); if((nPrevItems + m_nAwaitingAdd) == 0) { if(m_bApplyFilter) SendMessage(m_hOwner,WM_USER_FILTERINGAPPLIED,m_ID,TRUE); else SendMessage(m_hOwner,WM_USER_FOLDEREMPTY,m_ID,TRUE); m_nTotalItems = 0; return; } else if(!m_bApplyFilter) { SendMessage(m_hOwner,WM_USER_FOLDEREMPTY,m_ID,FALSE); } /* Make the listview allocate space (for internal data structures) for all the items at once, rather than individually. Acts as a speed optimization. */ ListView_SetItemCount(m_hListView,m_nAwaitingAdd + nPrevItems); lv.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM; if(bInsertIntoGroup) lv.mask |= LVIF_GROUPID; /* Constant for each item. */ lv.iSubItem = 0; if(m_bAutoArrange) NListView::ListView_SetAutoArrange(m_hListView,FALSE); for(auto itr = m_AwaitingAddList.begin();itr != m_AwaitingAddList.end();itr++) { if(!IsFileFiltered(itr->iItemInternal)) { lv.iItem = itr->iItem; lv.pszText = ProcessItemFileName(itr->iItemInternal); lv.iImage = I_IMAGECALLBACK; lv.lParam = itr->iItemInternal; if(bInsertIntoGroup) { lv.iGroupId = DetermineItemGroup(itr->iItemInternal); } /* Insert the item into the list view control. */ iItemIndex = ListView_InsertItem(m_hListView,&lv); if(itr->bPosition && m_ViewMode != VM_DETAILS) { POINT ptItem; if(itr->iAfter != -1) { ListView_GetItemPosition(m_hListView,itr->iAfter,&ptItem); } else { ptItem.x = 0; ptItem.y = 0; } /* The item will end up in the position AFTER iAfter. */ ListView_SetItemPosition32(m_hListView,iItemIndex,ptItem.x,ptItem.y); } if(m_ViewMode == VM_TILES) { SetTileViewItemInfo(iItemIndex,itr->iItemInternal); } if(m_bNewItemCreated) { LPITEMIDLIST pidlComplete = NULL; pidlComplete = ILCombine(m_pidlDirectory,m_pExtraItemInfo[(int)itr->iItemInternal].pridl); if(CompareIdls(pidlComplete,m_pidlNewItem)) m_bNewItemCreated = FALSE; m_iIndexNewItem = iItemIndex; CoTaskMemFree(pidlComplete); } /* If the file is marked as hidden, ghost it out. */ if(m_pwfdFiles[itr->iItemInternal].dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) { ListView_SetItemState(m_hListView,iItemIndex,LVIS_CUT,LVIS_CUT); } /* Add the current file's size to the running size of the current directory. */ /* A folder may or may not have 0 in its high file size member. It should either be zeroed, or never counted. */ ulFileSize.LowPart = m_pwfdFiles[itr->iItemInternal].nFileSizeLow; ulFileSize.HighPart = m_pwfdFiles[itr->iItemInternal].nFileSizeHigh; m_ulTotalDirSize.QuadPart += ulFileSize.QuadPart; nAdded++; } else { m_FilteredItemsList.push_back(itr->iItemInternal); } } if(m_bAutoArrange) NListView::ListView_SetAutoArrange(m_hListView,TRUE); m_nTotalItems = nPrevItems + nAdded; if(m_ViewMode == VM_DETAILS) { TCHAR szDrive[MAX_PATH]; BOOL bNetworkRemovable = FALSE; QueueUserAPC(SetAllColumnDataAPC,m_hThread,(ULONG_PTR)this); StringCchCopy(szDrive,SIZEOF_ARRAY(szDrive),m_CurDir); PathStripToRoot(szDrive); if(GetDriveType(szDrive) == DRIVE_REMOVABLE || GetDriveType(szDrive) == DRIVE_REMOTE) { bNetworkRemovable = TRUE; } /* If the user has selected to disable folder sizes on removable drives or networks, and we are currently on such a drive, do not calculate folder sizes. */ if(m_bShowFolderSizes && !(m_bDisableFolderSizesNetworkRemovable && bNetworkRemovable)) QueueUserAPC(SetAllFolderSizeColumnDataAPC,m_hFolderSizeThread,(ULONG_PTR)this); } PositionDroppedItems(); m_AwaitingAddList.clear(); m_nAwaitingAdd = 0; }