+ /* Create a font */
+ hFont = NULL;
+ if (SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0))
+ {
+ /* Override the current size with something manageable */
+ lf.lfHeight = -11;
+ lf.lfWidth = 0;
+ hFont = CreateFontIndirectW(&lf);
+ }
+ if (!hFont)
+ hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
+
+ SetRect(&rect, 0, 0, cxIcon, cyIcon);
+
+ /* Draw hbmColor */
+ hBmpOld = SelectObject(hdc, hbmColor);
+ SetDCBrushColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
+ FillRect(hdc, &rect, (HBRUSH)GetStockObject(DC_BRUSH));
+ hFontOld = SelectObject(hdc, hFont);
+ SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
+ SetBkMode(hdc, TRANSPARENT);
+ DrawTextW(hdc, szBuf, 2, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
+ SelectObject(hdc, hFontOld);
+
+ /* Fill hbmMono with black */
+ SelectObject(hdc, hbmMono);
+ PatBlt(hdc, 0, 0, cxIcon, cyIcon, BLACKNESS);
+ SelectObject(hdc, hBmpOld);
+
+ /* Create an icon from hbmColor and hbmMono */
+ IconInfo.fIcon = TRUE;
+ IconInfo.xHotspot = IconInfo.yHotspot = 0;
+ IconInfo.hbmColor = hbmColor;
+ IconInfo.hbmMask = hbmMono;
+ hIcon = CreateIconIndirect(&IconInfo);
+
+ /* Clean up */
+ DeleteObject(hFont);
+ DeleteObject(hbmMono);
+ DeleteObject(hbmColor);
+ DeleteDC(hdc);