From ae7cd5ec73739309e638d92f4591267f7815efca Mon Sep 17 00:00:00 2001 From: David Quintana Date: Thu, 15 Jan 2015 17:43:03 +0000 Subject: [PATCH] [EXPLORER] * Fix the notify window not resizing itself when the number of icons changes. * Add error prints when AlignControls fails and exits early. * Rename the Shell_NotifyIcon handler methods to something more appropriate. CORE-9061 #resolve svn path=/trunk/; revision=66040 --- reactos/base/shell/explorer/precomp.h | 3 +-- reactos/base/shell/explorer/trayntfy.cpp | 34 +++++++++++++++--------- reactos/base/shell/explorer/traywnd.cpp | 13 ++++++++- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/reactos/base/shell/explorer/precomp.h b/reactos/base/shell/explorer/precomp.h index 07749ac082b..1205e7d8d3d 100644 --- a/reactos/base/shell/explorer/precomp.h +++ b/reactos/base/shell/explorer/precomp.h @@ -338,8 +338,7 @@ HWND CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow, IN BOOL bHideClock, CTrayNotifyWnd** ppTrayNotify); BOOL -TrayNotify_NotifyMsg(CTrayNotifyWnd* pTrayNotify, IN WPARAM wParam, -IN LPARAM lParam); +TrayNotify_NotifyIconCmd(CTrayNotifyWnd* pTrayNotify, IN WPARAM wParam, IN LPARAM lParam); BOOL TrayNotify_GetClockRect(CTrayNotifyWnd* pTrayNotify, OUT PRECT rcClock); diff --git a/reactos/base/shell/explorer/trayntfy.cpp b/reactos/base/shell/explorer/trayntfy.cpp index dc42992f44d..5f6ff2c01cf 100644 --- a/reactos/base/shell/explorer/trayntfy.cpp +++ b/reactos/base/shell/explorer/trayntfy.cpp @@ -417,7 +417,7 @@ public: return TRUE; } - LRESULT NotifyMsg(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + LRESULT NotifyIconCmd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { PCOPYDATASTRUCT cpData = (PCOPYDATASTRUCT) lParam; if (cpData->dwData == 1) @@ -426,6 +426,7 @@ public: NOTIFYICONDATA *iconData; HWND parentHWND; RECT windowRect; + BOOL ret = FALSE; parentHWND = GetParent(); parentHWND = ::GetParent(parentHWND); ::GetClientRect(parentHWND, &windowRect); @@ -433,23 +434,30 @@ public: data = (PSYS_PAGER_COPY_DATA) cpData->lpData; iconData = &data->nicon_data; + TRACE("NotifyIconCmd received. Code=%d\n", data->notify_code); switch (data->notify_code) { case NIM_ADD: - return Toolbar.AddButton(iconData); - case NIM_MODIFY: - return Toolbar.UpdateButton(iconData); - case NIM_DELETE: - return Toolbar.RemoveButton(iconData); - default: - TRACE("NotifyMessage received with unknown code %d.\n", data->notify_code); + ret = Toolbar.AddButton(iconData); break; + case NIM_MODIFY: + ret = Toolbar.UpdateButton(iconData); + break; + case NIM_DELETE: + ret = Toolbar.RemoveButton(iconData); + break; + default: + TRACE("NotifyIconCmd received with unknown code %d.\n", data->notify_code); + return FALSE; } + SendMessage(parentHWND, WM_SIZE, 0, MAKELONG(windowRect.right - windowRect.left, - windowRect.bottom - windowRect.top)); + windowRect.bottom - windowRect.top)); + + return ret; } return TRUE; @@ -1449,11 +1457,11 @@ public: return DrawBackground(hdc); } - LRESULT NotifyMsg(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + LRESULT NotifyIconCmd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if (m_pager) { - return m_pager->NotifyMsg(uMsg, wParam, lParam, bHandled); + return m_pager->NotifyIconCmd(uMsg, wParam, lParam, bHandled); } return TRUE; @@ -1585,10 +1593,10 @@ HWND CreateTrayNotifyWnd(IN OUT ITrayWindow *Tray, BOOL bHideClock, CTrayNotifyW } BOOL -TrayNotify_NotifyMsg(CTrayNotifyWnd* pTrayNotify, WPARAM wParam, LPARAM lParam) +TrayNotify_NotifyIconCmd(CTrayNotifyWnd* pTrayNotify, WPARAM wParam, LPARAM lParam) { BOOL bDummy; - return pTrayNotify->NotifyMsg(0, wParam, lParam, bDummy); + return pTrayNotify->NotifyIconCmd(0, wParam, lParam, bDummy); } BOOL diff --git a/reactos/base/shell/explorer/traywnd.cpp b/reactos/base/shell/explorer/traywnd.cpp index 1c9e4db4d34..26c0ad416ec 100644 --- a/reactos/base/shell/explorer/traywnd.cpp +++ b/reactos/base/shell/explorer/traywnd.cpp @@ -1316,6 +1316,7 @@ ChangePos: { if (!GetClientRect(&rcClient)) { + ERR("Could not get client rect lastErr=%d\n", GetLastError()); return; } } @@ -1326,7 +1327,10 @@ ChangePos: the tray notification control */ dwp = BeginDeferWindowPos(3); if (dwp == NULL) + { + ERR("BeginDeferWindowPos failed. lastErr=%d\n", GetLastError()); return; + } /* Limit the Start button width to the client width, if neccessary */ StartSize = m_StartButton.GetSize(); @@ -1345,7 +1349,10 @@ ChangePos: StartSize.cy, SWP_NOZORDER | SWP_NOACTIVATE); if (dwp == NULL) + { + ERR("DeferWindowPos for start button failed. lastErr=%d\n", GetLastError()); return; + } } /* Determine the size that the tray notification window needs */ @@ -1381,7 +1388,10 @@ ChangePos: TraySize.cy, SWP_NOZORDER | SWP_NOACTIVATE); if (dwp == NULL) + { + ERR("DeferWindowPos for notification area failed. lastErr=%d\n", GetLastError()); return; + } } /* Resize/Move the rebar control */ @@ -2188,7 +2198,8 @@ ChangePos: { if (m_TrayNotify) { - return TrayNotify_NotifyMsg(m_TrayNotifyInstance, wParam, lParam); + TRACE("WM_COPYDATA notify message received. Handling...\n"); + return TrayNotify_NotifyIconCmd(m_TrayNotifyInstance, wParam, lParam); } return TRUE; }