From ffa80e7e36ff39ebca423711579b17532103cfd0 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Sat, 23 Aug 2003 19:48:37 +0000 Subject: [PATCH] fixed create_absolute_pidl() svn path=/trunk/; revision=5802 --- .../subsys/system/explorer/shell/shellfs.cpp | 7 +++--- .../system/explorer/taskbar/startmenu.cpp | 2 +- .../system/explorer/taskbar/taskbar.cpp | 17 ++++++-------- .../subsys/system/explorer/taskbar/taskbar.h | 1 - .../system/explorer/utility/shellclasses.h | 23 ++++++++----------- .../subsys/system/explorer/utility/utility.h | 5 +++- .../subsys/system/explorer/utility/window.cpp | 4 +++- .../subsys/system/explorer/utility/window.h | 4 ++-- 8 files changed, 29 insertions(+), 34 deletions(-) diff --git a/reactos/subsys/system/explorer/shell/shellfs.cpp b/reactos/subsys/system/explorer/shell/shellfs.cpp index cc637282a36..d3a566cfde4 100644 --- a/reactos/subsys/system/explorer/shell/shellfs.cpp +++ b/reactos/subsys/system/explorer/shell/shellfs.cpp @@ -105,10 +105,9 @@ bool ShellDirectory::fill_w32fdata_shell(LPCITEMIDLIST pidl, SFGAOF attribs, WIN LPITEMIDLIST ShellEntry::create_absolute_pidl(HWND hwnd) { if (_up/* && _up->_etype==ET_SHELL*/) { - LPITEMIDLIST pidl = _pidl.create_absolute_pidl(static_cast(_up)->_folder, hwnd); + ShellDirectory* dir = static_cast(_up); - if (pidl) - return pidl; + return _pidl.create_absolute_pidl(dir->_pidl, hwnd); } return &*_pidl; @@ -147,7 +146,7 @@ BOOL ShellEntry::launch_entry(HWND hwnd, UINT nCmdShow) SHELLEXECUTEINFO shexinfo; shexinfo.cbSize = sizeof(SHELLEXECUTEINFO); - shexinfo.fMask = SEE_MASK_INVOKEIDLIST;//@@SEE_MASK_IDLIST; + shexinfo.fMask = SEE_MASK_INVOKEIDLIST; // SEE_MASK_IDLIST is also possible. shexinfo.hwnd = hwnd; shexinfo.lpVerb = NULL; shexinfo.lpFile = NULL; diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index cf2ae3fcedb..3ead01a0e2a 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -171,7 +171,7 @@ LRESULT StartMenu::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) // close start menu when activating another application if (!wparam) CloseStartMenu(); - goto def; + break; // don't call super::WndProc in case "this" has been deleted case WM_CANCELMODE: CloseStartMenu(); diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.cpp b/reactos/subsys/system/explorer/taskbar/taskbar.cpp index b47d9c6d537..8e07fcdd9a8 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/taskbar.cpp @@ -151,13 +151,19 @@ int TaskBar::Notify(int id, NMHDR* pnmh) if (pnmh->hwndFrom == _htoolbar) switch(pnmh->code) { case NM_RCLICK: { + TBBUTTONINFO btninfo; TaskBarMap::iterator it; Point pt(GetMessagePos()); ScreenToClient(_htoolbar, &pt); + btninfo.cbSize = sizeof(TBBUTTONINFO); + btninfo.dwMask = TBIF_BYINDEX|TBIF_COMMAND; + int idx = SendMessage(_htoolbar, TB_HITTEST, 0, (LPARAM)&pt); - if (idx>=0 && (it=_map.find_by_idx(idx))!=_map.end()) { + if (idx>=0 && + SendMessage(_htoolbar, TB_GETBUTTONINFO, idx, (LPARAM)&btninfo)!=-1 && + (it=_map.find_id(btninfo.idCommand))!=_map.end()) { TaskBarEntry& entry = it->second; ActivateApp(it, false); @@ -391,12 +397,3 @@ TaskBarMap::iterator TaskBarMap::find_id(int id) return end(); } - -TaskBarMap::iterator TaskBarMap::find_by_idx(int idx) -{ - for(iterator it=begin(); it!=end(); ++it) - if (it->second._btn_idx == idx) - return it; - - return end(); -} diff --git a/reactos/subsys/system/explorer/taskbar/taskbar.h b/reactos/subsys/system/explorer/taskbar/taskbar.h index 19799545be5..4b5029152cd 100644 --- a/reactos/subsys/system/explorer/taskbar/taskbar.h +++ b/reactos/subsys/system/explorer/taskbar/taskbar.h @@ -62,7 +62,6 @@ struct TaskBarMap : public map ~TaskBarMap(); iterator find_id(int id); - iterator find_by_idx(int idx); }; diff --git a/reactos/subsys/system/explorer/utility/shellclasses.h b/reactos/subsys/system/explorer/utility/shellclasses.h index 5fbace694c6..be6959c5b01 100644 --- a/reactos/subsys/system/explorer/utility/shellclasses.h +++ b/reactos/subsys/system/explorer/utility/shellclasses.h @@ -240,7 +240,7 @@ protected: } T* _p; - ShellMalloc _malloc; // IMalloc memory management object + mutable ShellMalloc _malloc; // IMalloc memory management object private: // disallow copying of SShellPtr objects @@ -599,23 +599,18 @@ struct ShellPath : public SShellPtr // convert an item id list from relative to absolute (=relative to the desktop) format - LPITEMIDLIST create_absolute_pidl(IShellFolder* parent_folder, HWND hwnd) const + LPITEMIDLIST create_absolute_pidl(LPCITEMIDLIST parent_pidl, HWND hwnd) const { - WCHAR buffer[MAX_PATH]; + // create a new item id list with _p append behind parent_pidl + int l1 = _malloc->GetSize((void*)parent_pidl) - sizeof(USHORT/*SHITEMID::cb*/); + int l2 = _malloc->GetSize(_p); - HRESULT hr = path_from_pidlW(parent_folder, _p, buffer, MAX_PATH); + LPITEMIDLIST p = (LPITEMIDLIST) _malloc->Alloc(l1+l2); - if (SUCCEEDED(hr)) { - LPITEMIDLIST pidl; - ULONG len; + memcpy(p, parent_pidl, l1); + memcpy((LPBYTE)p+l1, _p, l2); - hr = Desktop()->ParseDisplayName(hwnd, NULL, buffer, &len, &pidl, NULL); - - if (SUCCEEDED(hr)) - return pidl; - } - - return NULL; + return p; } }; diff --git a/reactos/subsys/system/explorer/utility/utility.h b/reactos/subsys/system/explorer/utility/utility.h index 6dea4d202ee..e28b5fdadb4 100644 --- a/reactos/subsys/system/explorer/utility/utility.h +++ b/reactos/subsys/system/explorer/utility/utility.h @@ -46,12 +46,15 @@ #ifndef BTNS_BUTTON -#define BTNS_BUTTON TBSTYLE_BUTTON //TODO: should be in mingw headers +#define BTNS_BUTTON TBSTYLE_BUTTON //missing in old mingw headers #define BTNS_SEP TBSTYLE_SEP #endif #ifndef TB_HITTEST //missing in mingw headers #define TB_HITTEST (WM_USER+69) #endif +#ifndef TB_GETBUTTONINFO //missing in mingw headers +#define TB_GETBUTTONINFO (WM_USER+65) +#endif #ifdef __cplusplus diff --git a/reactos/subsys/system/explorer/utility/window.cpp b/reactos/subsys/system/explorer/utility/window.cpp index 733223110ee..9ea6a2e0c75 100644 --- a/reactos/subsys/system/explorer/utility/window.cpp +++ b/reactos/subsys/system/explorer/utility/window.cpp @@ -186,12 +186,14 @@ LRESULT CALLBACK Window::WindowWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPAR LRESULT Window::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) { + HWND hwnd = _hwnd; + // close startup menu and other popup menus // This functionality is for tray notification icons missing in MS Windows. if (nmsg == WM_SETFOCUS) CancelModes((HWND)wparam); - return DefWindowProc(_hwnd, nmsg, wparam, lparam); + return DefWindowProc(hwnd, nmsg, wparam, lparam); } int Window::Command(int id, int code) diff --git a/reactos/subsys/system/explorer/utility/window.h b/reactos/subsys/system/explorer/utility/window.h index b42e421841f..f0ad683b33d 100644 --- a/reactos/subsys/system/explorer/utility/window.h +++ b/reactos/subsys/system/explorer/utility/window.h @@ -373,12 +373,12 @@ template struct OwnerDrawParent : public BASE { switch(nmsg) { case WM_DRAWITEM: - if (wparam) { // ein Control? + if (wparam) { // should there be drawn a control? HWND hctl = GetDlgItem(_hwnd, wparam); if (hctl) return SendMessage(hctl, PM_DISPATCH_DRAWITEM, wparam, lparam); - } /*else // oder ein Menüeintrag? + } /*else // or is it a menu entry? ; */ return 0;