https://bugs.winehq.org/show_bug.cgi?id=54906
Bug ID: 54906 Summary: Menu items with icons are drawn with black squares if Wine is running in Vista+ mode Product: Wine Version: 8.7 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: user32 Assignee: [email protected] Reporter: [email protected] Distribution: ---
The following construction fails in the all 8.x versions of Wine (currently I upgraded to version 8.7 devel) and works Ok in Wine 7.1:
MENUITEMINFO mii = {}; mii.cbSize = sizeof(mii); mii.fMask = MIIM_STRING | MIIM_STATE; if (pimi->iconId != -1) { mii.fMask |= MIIM_BITMAP; if (IsWinVerVistaPlus() && IsThemeActive()) { if (pimi->hBmp == nullptr) pimi->hBmp = ConvertIconToBitmap(pimi->parent->m_hMenuIcons, pimi->iconId); mii.hbmpItem = pimi->hBmp; } else mii.hbmpItem = HBMMENU_CALLBACK; } InsertMenuItemW(hMenu, uItem, TRUE, &mii);
I.e. if I run command 'winecfg -v win2003', then everything is Ok with icons, otherwise I see black squares instead of icons. This code works Ok under all versions of Windows, from XP to Windows 11, the problem is specific to Wine 8.x under Linux (I use Kubuntu 23.04).
To see the problem you can download my open source messenger Miranda NG from https://miranda-ng.org/downloads, just download a ZIP, run it and open main or tray icon menu. The full source code is avalable here: https://github.com/miranda-ng/miranda-ng, you need module menu_utils.cpp inside mir_app, InsertMenuItemWithSeparators or BuildRecursiveMenu functions.
WMBR, George Hazan.
https://bugs.winehq.org/show_bug.cgi?id=54906
[email protected] changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |jacobbrett+winehqbugs@jacob | |brett.id.au
https://bugs.winehq.org/show_bug.cgi?id=54906
George Hazan [email protected] changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|8.7 |9.13
--- Comment #1 from George Hazan [email protected] --- Bug still exists on Wine 9.13 / Kubuntu 24.04.
https://bugs.winehq.org/show_bug.cgi?id=54906
Fabian Maurer [email protected] changed:
What |Removed |Added ---------------------------------------------------------------------------- URL| |https://miranda-ng.org/down | |loads/ CC| |[email protected] Keywords| |download, regression, | |source
--- Comment #2 from Fabian Maurer [email protected] --- Can you do a git bisect to find the faulty commit?
https://bugs.winehq.org/show_bug.cgi?id=54906
--- Comment #3 from George Hazan [email protected] --- Well, imho I've found the root of problems.
In Miranda's console output there're a lot of lines like
011c:fixme:uxtheme:BeginBufferedPaint painting parameters are ignored
And inside Miranda the ICO file is converted into HBITMAP inside the following code:
HBITMAP ConvertIconToBitmap(HIMAGELIST hIml, int iconId) { if (!beginBufferedPaint) { HMODULE hThemeAPI = GetModuleHandleA("uxtheme.dll"); beginBufferedPaint = (pfnBeginBufferedPaint)GetProcAddress(hThemeAPI, "BeginBufferedPaint"); endBufferedPaint = (pfnEndBufferedPaint)GetProcAddress(hThemeAPI, "EndBufferedPaint"); }
BITMAPINFO bmi = { 0 }; bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biCompression = BI_RGB; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biWidth = g_iIconSX; bmi.bmiHeader.biHeight = g_iIconSY;
HDC hdc = CreateCompatibleDC(nullptr); HBITMAP hbmp = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, nullptr, nullptr, 0); HBITMAP hbmpOld = (HBITMAP)SelectObject(hdc, hbmp);
BLENDFUNCTION bfAlpha = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; BP_PAINTPARAMS paintParams = { 0 }; paintParams.cbSize = sizeof(paintParams); paintParams.dwFlags = BPPF_ERASE; paintParams.pBlendFunction = &bfAlpha;
HDC hdcBuffer; RECT rcIcon = { 0, 0, g_iIconSX, g_iIconSY }; HANDLE hPaintBuffer = beginBufferedPaint(hdc, &rcIcon, BPBF_DIB, &paintParams, &hdcBuffer); if (hPaintBuffer) { ImageList_Draw(hIml, iconId, hdc, 0, 0, ILD_TRANSPARENT); endBufferedPaint(hPaintBuffer, TRUE); }
SelectObject(hdc, hbmpOld); DeleteDC(hdc);
return hbmp; }
This function generates a black bitmap under Wine.
https://bugs.winehq.org/show_bug.cgi?id=54906
--- Comment #4 from George Hazan [email protected] --- And if I lock the interface to win2003, this code isn't executed, because the BeginBufferedPaint() call requires Vista+ compatibility level.