Now when opening a folder from the command line in single instance mode, if the folder is already open it makes that tab in focus instead of creating a new tab.
I also needed to apply the restore fix on http://www.explorerplusplus.com/phpBB3/ ... 96&start=0
Simply search for the two "SW_SHOW" occurrences and replace with "SW_RESTORE" (unless Davids already applied that fix).
Together with the "new/last instance argument" patch, you can even control an existing explorer++ window in multiple instance mode, eg "explorer++ -last_instance d:\" would tell the last instance to focus its d drive tab.
Demo exe: http://members.iinet.net.au/~bertdb/rya ... sen_2.3.7z
I haven't made a patch yet, but here are the changes if any one is interested...
In 1.2 its Explorer.cpp, WindowProcedure where WM_COPYDATA is handled, this is the extra code.
Code: Select all
if(pcds->lpData != NULL)
{
TCHAR szBrowseDirectory[MAX_PATH];
StringCchCopy(szBrowseDirectory,SIZEOF_ARRAY(szBrowseDirectory),(TCHAR*)pcds->lpData);
if (szBrowseDirectory[lstrlen(szBrowseDirectory)-1] == '\\')
{
// Remove slash.
PathRemoveFileSpec(szBrowseDirectory);
}
// Check if the dir is already open, if so just make that active
// a bit like what windows explorer does if you open the same folder twice
// from the command line.
bool alreadyOpen = false;
int nTabs = TabCtrl_GetItemCount(m_hTabCtrl);
for (int i=0;i<nTabs;++i)
{
TCITEM tcItem;
TCHAR szTabDirectory[MAX_PATH];
tcItem.mask = TCIF_PARAM;
TabCtrl_GetItem(m_hTabCtrl,i,&tcItem);
m_pShellBrowser[(int)tcItem.lParam]->QueryCurrentDirectory(MAX_PATH,szTabDirectory);
if (szTabDirectory[lstrlen(szTabDirectory)-1] == '\\')
{
// Remove slash.
PathRemoveFileSpec(szTabDirectory);
}
if (lstrcmpi(szTabDirectory,szBrowseDirectory) == 0)
{
alreadyOpen = true;
// Put tab in focus instead.
TabCtrl_SetCurSel(m_hTabCtrl,i);
OnTabSelectionChange();
// Now focus the list view so don't need to click the mouse.
SetFocus(m_hActiveListView);
}
}
if (!alreadyOpen)
{
BrowseFolder(szBrowseDirectory,SBSP_ABSOLUTE,TRUE,TRUE,FALSE);
}
}