int Icon::add_to_imagelist(HIMAGELIST himl, HDC hdc_wnd, COLORREF bk_color, HBRUSH bk_brush) const { int ret; if (_itype == IT_SYSCACHE) { HIMAGELIST himl = g_Globals._icon_cache.get_sys_imagelist(); int cx, cy; ImageList_GetIconSize(himl, &cx, &cy); HBITMAP hbmp = CreateCompatibleBitmap(hdc_wnd, cx, cy); HDC hdc = CreateCompatibleDC(hdc_wnd); HBITMAP hbmp_old = SelectBitmap(hdc, hbmp); ImageList_DrawEx(himl, _sys_idx, hdc, 0, 0, cx, cy, bk_color, CLR_DEFAULT, ILD_NORMAL); SelectBitmap(hdc, hbmp_old); DeleteDC(hdc); ret = ImageList_Add(himl, hbmp, 0); DeleteObject(hbmp); } else ret = ImageList_AddAlphaIcon(himl, _hicon, bk_brush, hdc_wnd); return ret; }
void TrayNotifyDlg::InsertItem(HTREEITEM hparent, HTREEITEM after, const NotifyIconDlgInfo& entry, HDC hdc, HICON hicon, NOTIFYICONMODE mode) { int idx = _info.size() + 1; _info[idx] = entry; String mode_str = string_from_mode(mode); switch(mode) { case NIM_SHOW: mode_str = ResString(IDS_NOTIFY_SHOW); break; case NIM_HIDE: mode_str = ResString(IDS_NOTIFY_HIDE); break; case NIM_AUTO: mode_str = ResString(IDS_NOTIFY_AUTOHIDE); } FmtString txt(TEXT("%s - %s [%s]"), entry._tipText.c_str(), entry._windowTitle.c_str(), mode_str.c_str()); TV_INSERTSTRUCT tvi; tvi.hParent = hparent; tvi.hInsertAfter = after; TV_ITEM& tv = tvi.item; tv.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; tv.lParam = (LPARAM)idx; tv.pszText = txt.str(); tv.iSelectedImage = tv.iImage = ImageList_AddAlphaIcon(_himl, hicon, GetStockBrush(WHITE_BRUSH), hdc); (void)TreeView_InsertItem(_tree_ctrl, &tvi); }
TrayNotifyDlg::TrayNotifyDlg(HWND hwnd) : super(hwnd), _tree_ctrl(GetDlgItem(hwnd, IDC_NOTIFY_ICONS)), _himl(ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR24, 3, 0)), _pNotifyArea(static_cast<NotifyArea*>(Window::get_window((HWND)SendMessage(g_Globals._hwndDesktopBar, PM_GET_NOTIFYAREA, 0, 0)))) { _selectedItem = 0; if (_pNotifyArea) { // save original icon states and configuration data for(NotifyIconMap::const_iterator it=_pNotifyArea->_icon_map.begin(); it!=_pNotifyArea->_icon_map.end(); ++it) _icon_states_org[it->first] = IconStatePair(it->second._mode, it->second._dwState); _cfg_org = _pNotifyArea->_cfg; _show_hidden_org = _pNotifyArea->_show_hidden; } SetWindowIcon(hwnd, IDI_REACTOS); _haccel = LoadAccelerators(g_Globals._hInstance, MAKEINTRESOURCE(IDA_TRAYNOTIFY)); { WindowCanvas canvas(_hwnd); HBRUSH hbkgnd = GetStockBrush(WHITE_BRUSH); ImageList_AddAlphaIcon(_himl, SmallIcon(IDI_DOT), hbkgnd, canvas); ImageList_AddAlphaIcon(_himl, SmallIcon(IDI_DOT_TRANS), hbkgnd, canvas); ImageList_AddAlphaIcon(_himl, SmallIcon(IDI_DOT_RED), hbkgnd, canvas); } (void)TreeView_SetImageList(_tree_ctrl, _himl, TVSIL_NORMAL); _resize_mgr.Add(IDC_NOTIFY_ICONS, RESIZE); _resize_mgr.Add(IDC_LABEL1, MOVE_Y); _resize_mgr.Add(IDC_NOTIFY_TOOLTIP, RESIZE_X|MOVE_Y); _resize_mgr.Add(IDC_LABEL2, MOVE_Y); _resize_mgr.Add(IDC_NOTIFY_TITLE, RESIZE_X|MOVE_Y); _resize_mgr.Add(IDC_LABEL3, MOVE_Y); _resize_mgr.Add(IDC_NOTIFY_MODULE, RESIZE_X|MOVE_Y); _resize_mgr.Add(IDC_LABEL4, MOVE_Y); _resize_mgr.Add(IDC_NOTIFY_SHOW, MOVE_Y); _resize_mgr.Add(IDC_NOTIFY_HIDE, MOVE_Y); _resize_mgr.Add(IDC_NOTIFY_AUTOHIDE,MOVE_Y); _resize_mgr.Add(IDC_PICTURE, MOVE); _resize_mgr.Add(ID_SHOW_HIDDEN_ICONS,MOVE_Y); _resize_mgr.Add(IDC_LABEL6, MOVE_Y); _resize_mgr.Add(IDC_LAST_CHANGE, MOVE_Y); _resize_mgr.Add(IDOK, MOVE); _resize_mgr.Add(IDCANCEL, MOVE); _resize_mgr.Resize(+150, +200); Refresh(); SetTimer(_hwnd, 0, 3000, NULL); register_pretranslate(hwnd); }