/* 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; }
HRESULT CShellBrowser::ParsePath(LPITEMIDLIST *pidlDirectory,UINT uFlags, BOOL *bStoreHistory) { if((uFlags & SBSP_RELATIVE) == SBSP_RELATIVE) { LPITEMIDLIST pidlComplete; if(pidlDirectory == NULL) return E_INVALIDARG; /* This is a relative path. Add it on to the end of the current directory name to get a fully qualified path. */ pidlComplete = ILCombine(m_pidlDirectory,*pidlDirectory); *pidlDirectory = ILClone(pidlComplete); CoTaskMemFree(pidlComplete); } else if((uFlags & SBSP_PARENT) == SBSP_PARENT) { HRESULT hr; hr = GetVirtualParentPath(m_pidlDirectory,pidlDirectory); } else if((uFlags & SBSP_NAVIGATEBACK) == SBSP_NAVIGATEBACK) { if(m_pPathManager->GetNumBackPathsStored() == 0) { SetFocus(m_hListView); return E_FAIL; } /*Gets the path of the folder that was last visited. Ignores the supplied Path argument.*/ *bStoreHistory = FALSE; *pidlDirectory = m_pPathManager->RetrieveAndValidateIdl(-1); } else if((uFlags & SBSP_NAVIGATEFORWARD) == SBSP_NAVIGATEFORWARD) { if(m_pPathManager->GetNumForwardPathsStored() == 0) { SetFocus(m_hListView); return E_FAIL; } /*Gets the path of the folder that is 'forward' of this one. Ignores the supplied Path argument.*/ *bStoreHistory = FALSE; *pidlDirectory = m_pPathManager->RetrieveAndValidateIdl(1); } else { /* Assume that SBSP_ABSOLUTE was passed. */ if(pidlDirectory == NULL) return E_INVALIDARG; } if((uFlags & SBSP_WRITENOHISTORY) == SBSP_WRITENOHISTORY) { /* Client has requested that the folder to be browsed to will have no history item associated with it. */ *bStoreHistory = FALSE; } if(!CheckIdl(*pidlDirectory)) return E_FAIL; return S_OK; }