int ImageList_AddAlphaIcon(HIMAGELIST himl, HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd) { HBITMAP hbmp = create_bitmap_from_icon(hIcon, hbrush_bkgnd, hdc_wnd); int ret = ImageList_Add(himl, hbmp, 0); DeleteObject(hbmp); return ret; }
HBITMAP Icon::create_bitmap(COLORREF bk_color, HBRUSH hbrBkgnd, HDC hdc_wnd) const { 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); return hbmp; } else return create_bitmap_from_icon(_hicon, hbrBkgnd, hdc_wnd); }
// fill task bar with buttons for enumerated top level windows BOOL CALLBACK TaskBar::EnumWndProc(HWND hwnd, LPARAM lparam) { TaskBar* pThis = (TaskBar*)lparam; DWORD style = GetWindowStyle(hwnd); DWORD ex_style = GetWindowExStyle(hwnd); if ((style&WS_VISIBLE) && !(ex_style&WS_EX_TOOLWINDOW) && !GetParent(hwnd) && !GetWindow(hwnd,GW_OWNER)) { TCHAR title[BUFFER_LEN]; if (!GetWindowText(hwnd, title, BUFFER_LEN)) title[0] = '\0'; TaskBarMap::iterator found = pThis->_map.find(hwnd); int last_id = 0; if (found != pThis->_map.end()) { last_id = found->second._id; if (!last_id) found->second._id = pThis->_next_id++; } else { HBITMAP hbmp; HICON hIcon = get_window_icon_small(hwnd); BOOL delete_icon = FALSE; if (!hIcon) { hIcon = LoadIcon(0, IDI_APPLICATION); delete_icon = TRUE; } if (hIcon) { hbmp = create_bitmap_from_icon(hIcon, GetSysColorBrush(COLOR_BTNFACE), WindowCanvas(pThis->_htoolbar)); if (delete_icon) DestroyIcon(hIcon); // some icons can be freed, some not - so ignore any error return of DestroyIcon() } else hbmp = 0; TBADDBITMAP ab = {0, (UINT_PTR)hbmp}; int bmp_idx = SendMessage(pThis->_htoolbar, TB_ADDBITMAP, 1, (LPARAM)&ab); TaskBarEntry entry; entry._id = pThis->_next_id++; entry._hbmp = hbmp; entry._bmp_idx = bmp_idx; entry._title = title; pThis->_map[hwnd] = entry; found = pThis->_map.find(hwnd); } TBBUTTON btn = {-2/*I_IMAGENONE*/, 0, TBSTATE_ENABLED/*|TBSTATE_ELLIPSES*/, BTNS_BUTTON, {0, 0}, 0, 0}; TaskBarEntry& entry = found->second; ++entry._used; btn.idCommand = entry._id; HWND foreground = GetForegroundWindow(); HWND foreground_owner = GetWindow(foreground, GW_OWNER); if (hwnd==foreground || hwnd==foreground_owner) { btn.fsState |= TBSTATE_PRESSED|TBSTATE_CHECKED; pThis->_last_foreground_wnd = hwnd; } if (!last_id) { // create new toolbar buttons for new windows if (title[0]) btn.iString = (INT_PTR)title; btn.iBitmap = entry._bmp_idx; entry._btn_idx = SendMessage(pThis->_htoolbar, TB_BUTTONCOUNT, 0, 0); SendMessage(pThis->_htoolbar, TB_INSERTBUTTON, entry._btn_idx, (LPARAM)&btn); pThis->ResizeButtons(); } else { // refresh attributes of existing buttons if (btn.fsState != entry._fsState) SendMessage(pThis->_htoolbar, TB_SETSTATE, entry._id, MAKELONG(btn.fsState,0)); if (entry._title != title) { TBBUTTONINFO info; info.cbSize = sizeof(TBBUTTONINFO); info.dwMask = TBIF_TEXT; info.pszText = title; SendMessage(pThis->_htoolbar, TB_SETBUTTONINFO, entry._id, (LPARAM)&info); entry._title = title; } } entry._fsState = btn.fsState; #ifdef __REACTOS__ // now handled by activating the ARW_HIDE flag with SystemParametersInfo(SPI_SETMINIMIZEDMETRICS) // move minimized windows out of sight if (IsIconic(hwnd)) { RECT rect; GetWindowRect(hwnd, &rect); if (rect.bottom > 0) SetWindowPos(hwnd, 0, -32000, -32000, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE); } #endif } return TRUE; }