* Sync with recent trunk (r52637).
[reactos.git] / base / shell / explorer / desktop / desktop.cpp
index f83e749..52c5dce 100644 (file)
@@ -13,7 +13,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 
@@ -259,7 +259,7 @@ BackgroundWindow::BackgroundWindow(HWND hwnd)
 {
         // set background brush for the short moment of displaying the
         // background color while moving foreground windows
-       SetClassLong(hwnd, GCL_HBRBACKGROUND, COLOR_BACKGROUND+1);
+       SetClassLongPtr(hwnd, GCL_HBRBACKGROUND, COLOR_BACKGROUND+1);
 
        _display_version = RegGetDWORDValue(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), TEXT("PaintDesktopVersion"), 1);
 }
@@ -435,6 +435,12 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
                explorer_show_frame(SW_SHOWNORMAL);
                break;
 
+      case WM_DISPLAYCHANGE:
+        MoveWindow(_hwnd, 0, 0, LOWORD(lparam), HIWORD(lparam), TRUE);
+        MoveWindow(g_Globals._hwndShellView, 0, 0, LOWORD(lparam), HIWORD(lparam), TRUE);
+        MoveWindow(_desktopBar, 0, HIWORD(lparam) - DESKTOPBARBAR_HEIGHT, LOWORD(lparam), DESKTOPBARBAR_HEIGHT, TRUE);
+        break;
+
          case WM_GETISHELLBROWSER:
                return (LRESULT)static_cast<IShellBrowser*>(this);
 
@@ -458,11 +464,12 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
                goto def;
 
          case WM_SYSCOLORCHANGE:
-                // redraw background window
-               InvalidateRect(g_Globals._hwndShellView, NULL, TRUE);
+               // redraw background window - it's done by system
+               //InvalidateRect(g_Globals._hwndShellView, NULL, TRUE);
 
-                // forward message to shell view window to redraw icon backgrounds
-               SendMessage(g_Globals._hwndShellView, WM_SYSCOLORCHANGE, wparam, lparam);
+                // forward message to common controls
+               SendMessage(g_Globals._hwndShellView, WM_SYSCOLORCHANGE, 0, 0);
+               SendMessage(_desktopBar, WM_SYSCOLORCHANGE, 0, 0);
                break;
 
          default: def:
@@ -490,8 +497,6 @@ DesktopShellView::DesktopShellView(HWND hwnd, IShellView* pShellView)
 {
        _hwndListView = GetNextWindow(hwnd, GW_CHILD);
 
-       SetWindowStyle(_hwndListView, GetWindowStyle(_hwndListView)&~LVS_ALIGNMASK);//|LVS_ALIGNTOP|LVS_AUTOARRANGE);
-
         // work around for Windows NT, Win 98, ...
         // Without this the desktop has mysteriously only a size of 800x600 pixels.
        ClientRect rect(hwnd);
@@ -500,30 +505,34 @@ DesktopShellView::DesktopShellView(HWND hwnd, IShellView* pShellView)
         // subclass background window
        new BackgroundWindow(_hwndListView);
 
-       _icon_algo = 1; // default icon arrangement
+       _icon_algo = 0; // default icon arrangement
 
-       PositionIcons();
        InitDragDrop();
 }
 
+
+DesktopShellView::~DesktopShellView()
+{
+       if (FAILED(RevokeDragDrop(_hwnd)))
+               assert(0);
+}
+
+
 bool DesktopShellView::InitDragDrop()
 {
        CONTEXT("DesktopShellView::InitDragDrop()");
 
-       _pDropTarget = new DesktopDropTarget(_hwnd);
+       DesktopDropTarget * pDropTarget = new DesktopDropTarget(_hwnd);
 
-       if (!_pDropTarget)
+       if (!pDropTarget)
                return false;
 
-       _pDropTarget->AddRef();
+       pDropTarget->AddRef();
 
-       if (FAILED(RegisterDragDrop(_hwnd, _pDropTarget))) {
-               _pDropTarget->Release();
-               _pDropTarget = NULL;
+       if (FAILED(RegisterDragDrop(_hwnd, pDropTarget))) {
+               pDropTarget->Release();
                return false;
        }
-       else
-               _pDropTarget->Release();
 
        FORMATETC ftetc;
 
@@ -532,7 +541,8 @@ bool DesktopShellView::InitDragDrop()
        ftetc.tymed = TYMED_HGLOBAL;
        ftetc.cfFormat = CF_HDROP;
 
-       _pDropTarget->AddSuportedFormat(ftetc);
+       pDropTarget->AddSuportedFormat(ftetc);
+       pDropTarget->Release();
 
        return true;
 }
@@ -725,6 +735,9 @@ void DesktopShellView::PositionIcons(int dir)
        RECT work_area;
        SystemParametersInfo(SPI_GETWORKAREA, 0, &work_area, 0);
 
+       /* disable default allignment */
+       SetWindowStyle(_hwndListView, GetWindowStyle(_hwndListView)&~LVS_ALIGNMASK);//|LVS_ALIGNTOP|LVS_AUTOARRANGE);
+
        const POINTS& dir1 = s_align_dir1[_icon_algo];
        const POINTS& dir2 = s_align_dir2[_icon_algo];
        const POINTS& start_pos = s_align_start[_icon_algo];