fixed create_absolute_pidl()
authorMartin Fuchs <fuchs.martin@gmail.com>
Sat, 23 Aug 2003 19:48:37 +0000 (19:48 +0000)
committerMartin Fuchs <fuchs.martin@gmail.com>
Sat, 23 Aug 2003 19:48:37 +0000 (19:48 +0000)
svn path=/trunk/; revision=5802

reactos/subsys/system/explorer/shell/shellfs.cpp
reactos/subsys/system/explorer/taskbar/startmenu.cpp
reactos/subsys/system/explorer/taskbar/taskbar.cpp
reactos/subsys/system/explorer/taskbar/taskbar.h
reactos/subsys/system/explorer/utility/shellclasses.h
reactos/subsys/system/explorer/utility/utility.h
reactos/subsys/system/explorer/utility/window.cpp
reactos/subsys/system/explorer/utility/window.h

index cc63728..d3a566c 100644 (file)
@@ -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<ShellDirectory*>(_up)->_folder, hwnd);
+               ShellDirectory* dir = static_cast<ShellDirectory*>(_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;
index cf2ae3f..3ead01a 100644 (file)
@@ -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();
index b47d9c6..8e07fcd 100644 (file)
@@ -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();
-}
index 1979954..4b50291 100644 (file)
@@ -62,7 +62,6 @@ struct TaskBarMap : public map<HWND, TaskBarEntry>
        ~TaskBarMap();
 
        iterator find_id(int id);
-       iterator find_by_idx(int idx);
 };
 
 
index 5fbace6..be6959c 100644 (file)
@@ -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<ITEMIDLIST>
 
 
         // 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;
        }
 };
 
index 6dea4d2..e28b5fd 100644 (file)
 
 
 #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
index 7332231..9ea6a2e 100644 (file)
@@ -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)
index b42e421..f0ad683 100644 (file)
@@ -373,12 +373,12 @@ template<typename BASE> 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;