re-enable DesktopWindow::OnDefaultCommand to open explorer windows on desktop double clicks

svn path=/trunk/; revision=9706
This commit is contained in:
Martin Fuchs
2004-06-18 16:36:00 +00:00
parent 26c98df753
commit be7a6c466b
5 changed files with 83 additions and 59 deletions
@@ -481,9 +481,9 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
HRESULT DesktopWindow::OnDefaultCommand(LPIDA pida)
{
/*@@ if (SDIMainFrame::OpenShellFolders(pida, 0))
if (MainFrameBase::OpenShellFolders(pida, 0))
return S_OK;
*/
return E_NOTIMPL;
}
@@ -86,6 +86,67 @@ HWND MainFrameBase::Create(LPCTSTR path, bool mdi, UINT cmdshow)
}
int MainFrameBase::OpenShellFolders(LPIDA pida, HWND hFrameWnd, bool mdi)
{
int cnt = 0;
LPCITEMIDLIST parent_pidl = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]);
ShellFolder folder(parent_pidl);
for(int i=pida->cidl; i>0; --i) {
LPCITEMIDLIST pidl = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[i]);
SFGAOF attribs = SFGAO_FOLDER;
HRESULT hr = folder->GetAttributesOf(1, &pidl, &attribs);
if (SUCCEEDED(hr))
if (attribs & SFGAO_FOLDER) {
try {
ShellPath pidl_abs = ShellPath(pidl).create_absolute_pidl(parent_pidl);
if (hFrameWnd) {
if (SendMessage(hFrameWnd, PM_OPEN_WINDOW, OWM_PIDL, (LPARAM)(LPCITEMIDLIST)pidl_abs))
++cnt;
} else {
HWND hwnd;
#ifndef _NO_MDI
if (mdi)
hwnd = MDIMainFrame::Create(pidl_abs, 0);
else
#endif
hwnd = SDIMainFrame::Create(pidl_abs, 0);
if (hwnd)
++cnt;
}
} catch(COMException& e) {
HandleException(e, g_Globals._hMainWnd);
}
}/*TEST
else { // !(attribs & SFGAO_FOLDER))
SHELLEXECUTEINFOA shexinfo;
shexinfo.cbSize = sizeof(SHELLEXECUTEINFOA);
shexinfo.fMask = SEE_MASK_INVOKEIDLIST;
shexinfo.hwnd = NULL;
shexinfo.lpVerb = NULL;
shexinfo.lpFile = NULL;
shexinfo.lpParameters = NULL;
shexinfo.lpDirectory = NULL;
shexinfo.nShow = SW_NORMAL;
shexinfo.lpIDList = ILCombine(parent_pidl, pidl);
if (ShellExecuteExA(&shexinfo))
++cnt;
ILFree((LPITEMIDLIST)shexinfo.lpIDList);
}*/
}
return cnt;
}
MainFrameBase::MainFrameBase(HWND hwnd)
: super(hwnd),
_himl(ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK|ILC_COLOR24, 2, 0))
@@ -815,60 +876,6 @@ ChildWindow* MDIMainFrame::CreateChild(LPCITEMIDLIST pidl, int mode)
}
int MDIMainFrame::OpenShellFolders(LPIDA pida, HWND hFrameWnd)
{
int cnt = 0;
LPCITEMIDLIST parent_pidl = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]);
ShellFolder folder(parent_pidl);
for(int i=pida->cidl; i>0; --i) {
LPCITEMIDLIST pidl = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[i]);
SFGAOF attribs = SFGAO_FOLDER;
HRESULT hr = folder->GetAttributesOf(1, &pidl, &attribs);
if (SUCCEEDED(hr))
if (attribs & SFGAO_FOLDER) {
try {
ShellPath pidl_abs = ShellPath(pidl).create_absolute_pidl(parent_pidl);
if (hFrameWnd) {
if (SendMessage(hFrameWnd, PM_OPEN_WINDOW, OWM_PIDL, (LPARAM)(LPCITEMIDLIST)pidl_abs))
++cnt;
} else {
if (MDIMainFrame::Create(pidl_abs, 0))
++cnt;
}
} catch(COMException& e) {
HandleException(e, g_Globals._hMainWnd);
}
}/*TEST
else { // !(attribs & SFGAO_FOLDER))
SHELLEXECUTEINFOA shexinfo;
shexinfo.cbSize = sizeof(SHELLEXECUTEINFOA);
shexinfo.fMask = SEE_MASK_INVOKEIDLIST;
shexinfo.hwnd = NULL;
shexinfo.lpVerb = NULL;
shexinfo.lpFile = NULL;
shexinfo.lpParameters = NULL;
shexinfo.lpDirectory = NULL;
shexinfo.nShow = SW_NORMAL;
shexinfo.lpIDList = ILCombine(parent_pidl, pidl);
if (ShellExecuteExA(&shexinfo))
++cnt;
ILFree((LPITEMIDLIST)shexinfo.lpIDList);
}*/
}
return cnt;
}
BOOL MDIMainFrame::TranslateMsg(MSG* pmsg)
{
if (_hmdiclient && TranslateMDISysAccel(_hmdiclient, pmsg))
@@ -1284,6 +1291,22 @@ HWND SDIMainFrame::Create()
0/*hwndDesktop*/, hMenuFrame);
}
HWND SDIMainFrame::Create(LPCITEMIDLIST pidl, int mode)
{
HWND hFrame = Create();
if (!hFrame)
return 0;
ShowWindow(hFrame, SW_SHOW);
SDIMainFrame* pFrame = GET_WINDOW(SDIMainFrame, hFrame);
if (pFrame)
pFrame->jump_to(pidl, mode);
return hFrame;
}
LRESULT SDIMainFrame::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
{
switch(nmsg) {
@@ -39,6 +39,7 @@ struct MainFrameBase : public PreTranslateWindow
~MainFrameBase();
static HWND Create(LPCTSTR path, bool mdi=true, UINT cmdshow=SW_SHOWNORMAL);
static int OpenShellFolders(LPIDA pida, HWND hFrameWnd, bool mdi=true);
WindowHandle _hwndrebar;
@@ -93,7 +94,6 @@ struct MDIMainFrame : public MainFrameBase
static HWND Create();
static HWND Create(LPCTSTR path, int mode=OWM_EXPLORE|OWM_DETAILS);
static HWND Create(LPCITEMIDLIST pidl, int mode=OWM_EXPLORE|OWM_DETAILS|OWM_PIDL);
static int OpenShellFolders(LPIDA pida, HWND hFrameWnd);
ChildWindow* CreateChild(LPCTSTR path=NULL, int mode=OWM_EXPLORE|OWM_DETAILS);
ChildWindow* CreateChild(LPCITEMIDLIST pidl, int mode=OWM_EXPLORE|OWM_DETAILS|OWM_PIDL);
@@ -131,6 +131,7 @@ struct SDIMainFrame : public ShellBrowserChildT<MainFrameBase>
SDIMainFrame(HWND hwnd);
static HWND Create();
static HWND Create(LPCITEMIDLIST pidl, int mode=OWM_EXPLORE|OWM_DETAILS|OWM_PIDL);
protected:
ShellPathInfo _shellpath_info;
@@ -421,7 +421,7 @@ HRESULT ShellBrowser::OnDefaultCommand(LPIDA pida)
}
}
} else { // no tree control
if (MDIMainFrame::OpenShellFolders(pida, _hWndFrame))
if (MainFrameBase::OpenShellFolders(pida, _hWndFrame))
return S_OK;
/* create new Frame Window
@@ -1395,7 +1395,7 @@ struct XMLDoc : public XMLNode
return status != XML_STATUS_ERROR;
}
bool read(XMLReaderBase& reader, const string& display_path)
bool read(XMLReaderBase& reader, const std::string& display_path)
{
XML_Status status = reader.read();