From b95e68a45d26b0248bc552c33cc64124718b9c42 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Sun, 14 Mar 2004 22:20:10 +0000 Subject: [PATCH] handle WM_NOTIFYFORMAT svn path=/trunk/; revision=8738 --- .../system/explorer/taskbar/traynotify.cpp | 17 ++++------ .../subsys/system/explorer/utility/window.cpp | 12 +++++++ .../subsys/system/explorer/utility/window.h | 32 +++++++++++++++---- 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/reactos/subsys/system/explorer/taskbar/traynotify.cpp b/reactos/subsys/system/explorer/taskbar/traynotify.cpp index c032ab48b59..a40cae1fe9f 100644 --- a/reactos/subsys/system/explorer/taskbar/traynotify.cpp +++ b/reactos/subsys/system/explorer/taskbar/traynotify.cpp @@ -95,24 +95,20 @@ NotifyInfo& NotifyInfo::operator=(NOTIFYICONDATA* pnid) // store tool tip text if (pnid->uFlags & NIF_TIP) - if (pnid->cbSize==NID_SIZE_W6 || pnid->cbSize==NID_SIZE_W5 || pnid->cbSize==NID_SIZE_W3) - { // UNICODE version of NOTIFYICONDATA structure + if (pnid->cbSize==NID_SIZE_W6 || pnid->cbSize==NID_SIZE_W5 || pnid->cbSize==NID_SIZE_W3) { + // UNICODE version of NOTIFYICONDATA structure LPCWSTR txt = (LPCWSTR)pnid->szTip; - - // get string length int max_len = pnid->cbSize==NID_SIZE_W3? 64: 128; + // get tooltip string length int l = 0; for(; lcbSize==NID_SIZE_A6 || pnid->cbSize==NID_SIZE_A5 || pnid->cbSize==NID_SIZE_A3) - { // ANSI version of NOTIFYICONDATA structure + } else if (pnid->cbSize==NID_SIZE_A6 || pnid->cbSize==NID_SIZE_A5 || pnid->cbSize==NID_SIZE_A3) { LPCSTR txt = (LPCSTR)pnid->szTip; - - // get string length int max_len = pnid->cbSize==NID_SIZE_A3? 64: 128; int l = 0; @@ -378,9 +374,10 @@ void NotifyArea::Refresh() // sync tooltip areas to current icon number if (_sorted_icons.size() != _last_icon_count) { RECT rect = {2, 3, 2+16, 3+16}; - size_t tt_idx = 0; + size_t icon_cnt = _sorted_icons.size(); - for(NotifyIconSet::const_iterator it=_sorted_icons.begin(); it!=_sorted_icons.end(); ++it) { + size_t tt_idx = 0; + while(tt_idx < icon_cnt) { _tooltip.add(_hwnd, tt_idx++, rect); rect.left += NOTIFYICON_DIST; diff --git a/reactos/subsys/system/explorer/utility/window.cpp b/reactos/subsys/system/explorer/utility/window.cpp index 793414709a6..8769ebf9758 100644 --- a/reactos/subsys/system/explorer/utility/window.cpp +++ b/reactos/subsys/system/explorer/utility/window.cpp @@ -259,6 +259,9 @@ LRESULT CALLBACK Window::WindowWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPAR case WM_NOTIFY: return pThis->Notify(wparam, (NMHDR*)lparam); + case WM_NOTIFYFORMAT: + return NFR_CURRENT; + case WM_CREATE: return pThis->Init((LPCREATESTRUCT)lparam); @@ -331,6 +334,9 @@ LRESULT CALLBACK SubclassedWindow::SubclassedWndProc(HWND hwnd, UINT nmsg, WPARA case WM_NOTIFY: return pThis->Notify(wparam, (NMHDR*)lparam); + case WM_NOTIFYFORMAT: + return NFR_CURRENT; + case WM_CREATE: return pThis->Init((LPCREATESTRUCT)lparam); @@ -677,6 +683,9 @@ INT_PTR CALLBACK Window::DialogProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM pThis->Notify(wparam, (NMHDR*)lparam); return TRUE; // message has been processed + case WM_NOTIFYFORMAT: + return NFR_CURRENT; + case WM_NCDESTROY: delete pThis; return TRUE; // message has been processed @@ -1355,6 +1364,9 @@ INT_PTR CALLBACK PropSheetPageDlg::DialogProc(HWND hwnd, UINT nmsg, WPARAM wpara pThis->Notify(wparam, (NMHDR*)lparam); return TRUE; // message has been processed + case WM_NOTIFYFORMAT: + return NFR_CURRENT; + case WM_NCDESTROY: delete pThis; return TRUE; // message has been processed diff --git a/reactos/subsys/system/explorer/utility/window.h b/reactos/subsys/system/explorer/utility/window.h index 8d615ab731e..2113f65ebfe 100644 --- a/reactos/subsys/system/explorer/utility/window.h +++ b/reactos/subsys/system/explorer/utility/window.h @@ -138,6 +138,12 @@ protected: static WindowSet s_dialogs; }; +#ifdef UNICODE +#define NFR_CURRENT NFR_UNICODE +#else +#define NFR_CURRENT NFR_ANSI +#endif + #ifdef _MSC_VER template struct GetWindowHelper @@ -845,27 +851,40 @@ struct ToolTip : public WindowHandle void add(HWND hparent, HWND htool, LPCTSTR txt=LPSTR_TEXTCALLBACK, LPARAM lparam=0) { TOOLINFO ti = { - sizeof(TOOLINFO), TTF_SUBCLASS|TTF_IDISHWND/*|TTF_TRANSPARENT*/, hparent, (UINT)htool, + sizeof(TOOLINFO), TTF_SUBCLASS|TTF_IDISHWND|TTF_TRANSPARENT, hparent, (UINT)htool, {0,0,0,0}, 0, (LPTSTR)txt, lparam }; - SendMessage(_hwnd, TTM_ADDTOOL, 0, (LPARAM)&ti); +#ifdef UNICODE ///@todo Why is it neccesary to try both TTM_ADDTOOLW and TTM_ADDTOOLW ?! + if (!SendMessage(_hwnd, TTM_ADDTOOLW, 0, (LPARAM)&ti)) + SendMessage(_hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti); +#else + if (!SendMessage(_hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti)) + SendMessage(_hwnd, TTM_ADDTOOLW, 0, (LPARAM)&ti); +#endif } void add(HWND hparent, UINT id, const RECT& rect, LPCTSTR txt=LPSTR_TEXTCALLBACK, LPARAM lparam=0) { TOOLINFO ti = { - sizeof(TOOLINFO), TTF_SUBCLASS/*|TTF_TRANSPARENT*/, hparent, id, + sizeof(TOOLINFO), TTF_SUBCLASS|TTF_TRANSPARENT, hparent, id, {rect.left,rect.top,rect.right,rect.bottom}, 0, (LPTSTR)txt, lparam }; - SendMessage(_hwnd, TTM_ADDTOOL, 0, (LPARAM)&ti); +#ifdef UNICODE + if (!SendMessage(_hwnd, TTM_ADDTOOLW, 0, (LPARAM)&ti)) + SendMessage(_hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti); +#else + if (!SendMessage(_hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti)) + SendMessage(_hwnd, TTM_ADDTOOLW, 0, (LPARAM)&ti); +#endif } void remove(HWND hparent, HWND htool) { TOOLINFO ti = { - sizeof(TOOLINFO), TTF_IDISHWND, hparent, (UINT)htool, {0,0,0,0}, 0, 0, 0 + sizeof(TOOLINFO), TTF_IDISHWND, hparent, (UINT)htool, + {0,0,0,0}, 0, 0, 0 }; SendMessage(_hwnd, TTM_DELTOOL, 0, (LPARAM)&ti); @@ -874,7 +893,8 @@ struct ToolTip : public WindowHandle void remove(HWND hparent, UINT id) { TOOLINFO ti = { - sizeof(TOOLINFO), 0, hparent, id, {0,0,0,0}, 0, 0, 0 + sizeof(TOOLINFO), 0, hparent, id, + {0,0,0,0}, 0, 0, 0 }; SendMessage(_hwnd, TTM_DELTOOL, 0, (LPARAM)&ti);