diff --git a/reactos/subsys/system/explorer/taskbar/desktopbar.cpp b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp index 413bb71a4e3..be20039d0b8 100644 --- a/reactos/subsys/system/explorer/taskbar/desktopbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp @@ -47,7 +47,7 @@ DesktopBar::DesktopBar(HWND hwnd) WM_TASKBARCREATED(RegisterWindowMessage(WINMSG_TASKBARCREATED)) #endif { - SetWindowIcon(hwnd, IDI_REACTOS/*IDI_SEARCH*/); // icon in for TrayNotifyDlg + SetWindowIcon(hwnd, IDI_REACTOS); SystemParametersInfo(SPI_GETWORKAREA, 0, &_work_area_org, 0); } diff --git a/reactos/subsys/system/explorer/taskbar/traynotify.cpp b/reactos/subsys/system/explorer/taskbar/traynotify.cpp index 2502fbb2f31..b77e639fca4 100644 --- a/reactos/subsys/system/explorer/taskbar/traynotify.cpp +++ b/reactos/subsys/system/explorer/taskbar/traynotify.cpp @@ -905,7 +905,7 @@ TrayNotifyDlg::TrayNotifyDlg(HWND hwnd) _show_hidden_org = _pNotifyArea->_show_hidden; } - SetWindowIcon(hwnd, IDI_REACTOS/*IDI_SEARCH*/); + SetWindowIcon(hwnd, IDI_REACTOS); _haccel = LoadAccelerators(g_Globals._hInstance, MAKEINTRESOURCE(IDA_TRAYNOTIFY)); @@ -1053,7 +1053,7 @@ void TrayNotifyDlg::InsertItem(HTREEITEM hparent, HTREEITEM after, const NotifyI void TrayNotifyDlg::InsertItem(HTREEITEM hparent, HTREEITEM after, const NotifyIconDlgInfo& entry, HDC hdc, HICON hicon, NOTIFYICONMODE mode) { - int idx = _info.size(); + int idx = _info.size() + 1; _info[idx] = entry; String mode_str = string_from_mode(mode); @@ -1163,42 +1163,10 @@ int TrayNotifyDlg::Notify(int id, NMHDR* pnmh) switch(pnmh->code) { case TVN_SELCHANGED: { NMTREEVIEW* pnmtv = (NMTREEVIEW*)pnmh; - LPARAM lparam = pnmtv->itemNew.lParam; - - if (lparam) { - const NotifyIconDlgInfo& entry = _info[lparam]; - - SetDlgItemText(_hwnd, IDC_NOTIFY_TOOLTIP, entry._tipText); - SetDlgItemText(_hwnd, IDC_NOTIFY_TITLE, entry._windowTitle); - SetDlgItemText(_hwnd, IDC_NOTIFY_MODULE, entry._modulePath); - - CheckRadioButton(_hwnd, IDC_NOTIFY_SHOW, IDC_NOTIFY_AUTOHIDE, IDC_NOTIFY_SHOW+entry._mode); - - String change_str; - if (entry._lastChange) - change_str.printf(TEXT("before %d s"), (GetTickCount()-entry._lastChange+500)/1000); - SetDlgItemText(_hwnd, IDC_LAST_CHANGE, change_str); - - HICON hicon = 0; //get_window_icon_big(entry._hWnd, false); - - // If we could not find an icon associated with the owner window, try to load one from the owning module. - if (!hicon && !entry._modulePath.empty()) { - hicon = ExtractIcon(g_Globals._hInstance, entry._modulePath, 0); - - if (!hicon) { - SHFILEINFO sfi; - - if (SHGetFileInfo(entry._modulePath, 0, &sfi, sizeof(sfi), SHGFI_ICON|SHGFI_LARGEICON)) - hicon = sfi.hIcon; - } - } - - if (hicon) { - SendMessage(GetDlgItem(_hwnd, IDC_PICTURE), STM_SETICON, (LPARAM)hicon, 0); - DestroyIcon(hicon); - } else - SendMessage(GetDlgItem(_hwnd, IDC_PICTURE), STM_SETICON, 0, 0); + int idx = pnmtv->itemNew.lParam; + if (idx) { + RefreshProperties(_info[idx]); _selectedItem = pnmtv->itemNew.hItem; } else { /* @@ -1214,14 +1182,48 @@ int TrayNotifyDlg::Notify(int id, NMHDR* pnmh) return 0; } +void TrayNotifyDlg::RefreshProperties(const NotifyIconDlgInfo& entry) +{ + SetDlgItemText(_hwnd, IDC_NOTIFY_TOOLTIP, entry._tipText); + SetDlgItemText(_hwnd, IDC_NOTIFY_TITLE, entry._windowTitle); + SetDlgItemText(_hwnd, IDC_NOTIFY_MODULE, entry._modulePath); + + CheckRadioButton(_hwnd, IDC_NOTIFY_SHOW, IDC_NOTIFY_AUTOHIDE, IDC_NOTIFY_SHOW+entry._mode); + + String change_str; + if (entry._lastChange) + change_str.printf(TEXT("before %d s"), (GetTickCount()-entry._lastChange+500)/1000); + SetDlgItemText(_hwnd, IDC_LAST_CHANGE, change_str); + + HICON hicon = 0; //get_window_icon_big(entry._hWnd, false); + + // If we could not find an icon associated with the owner window, try to load one from the owning module. + if (!hicon && !entry._modulePath.empty()) { + hicon = ExtractIcon(g_Globals._hInstance, entry._modulePath, 0); + + if (!hicon) { + SHFILEINFO sfi; + + if (SHGetFileInfo(entry._modulePath, 0, &sfi, sizeof(sfi), SHGFI_ICON|SHGFI_LARGEICON)) + hicon = sfi.hIcon; + } + } + + if (hicon) { + SendMessage(GetDlgItem(_hwnd, IDC_PICTURE), STM_SETICON, (LPARAM)hicon, 0); + DestroyIcon(hicon); + } else + SendMessage(GetDlgItem(_hwnd, IDC_PICTURE), STM_SETICON, 0, 0); +} + void TrayNotifyDlg::SetIconMode(NOTIFYICONMODE mode) { - LPARAM lparam = TreeView_GetItemData(_tree_ctrl, _selectedItem); + int idx = TreeView_GetItemData(_tree_ctrl, _selectedItem); - if (!lparam) + if (!idx) return; - NotifyIconConfig& entry = _info[lparam]; + NotifyIconConfig& entry = _info[idx]; if (entry._mode != mode) { entry._mode = mode; diff --git a/reactos/subsys/system/explorer/taskbar/traynotify.h b/reactos/subsys/system/explorer/taskbar/traynotify.h index b4aa4750631..7d90406ab35 100644 --- a/reactos/subsys/system/explorer/taskbar/traynotify.h +++ b/reactos/subsys/system/explorer/taskbar/traynotify.h @@ -230,6 +230,7 @@ protected: void InsertItem(HTREEITEM hparent, HTREEITEM after, const NotifyInfo&, HDC); void InsertItem(HTREEITEM hparent, HTREEITEM after, const NotifyIconDlgInfo&, HDC, HICON, NOTIFYICONMODE); void SetIconMode(NOTIFYICONMODE mode); + void RefreshProperties(const NotifyIconDlgInfo& entry); };