[Bug 44392] BM_SETIMAGE sets image with white background instead of transparent
wine-bugs at winehq.org
wine-bugs at winehq.org
Mon Jan 22 23:08:41 CST 2018
https://bugs.winehq.org/show_bug.cgi?id=44392
--- Comment #6 from nikolaysemenkov at gmail.com ---
The full file (vs2005):
#define UNICODE
#define _WIN32_IE 0x0600
#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <gdiplus.h>
#include <Commctrl.h>
#pragma comment(lib,"gdiplus.lib")
#pragma comment(lib,"gdi32.lib")
#pragma comment(lib,"user32.lib")
#pragma comment(lib,"comctl32.lib")
#pragma comment(linker,"/manifestdependency:\"type='win32'
name='Microsoft.Windows.Common-Controls' ""version='6.0.0.0'
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
HBITMAP loadBitmap(const wchar_t* path)
{
HBITMAP tBmp = NULL;
ULONG_PTR token = 0;
Gdiplus::GdiplusStartupInput input = NULL;
Gdiplus::GdiplusStartup(&token, &input, NULL);
if (token != 0)
{
Gdiplus::Bitmap* bmp = new Gdiplus::Bitmap(path);
bmp->GetHBITMAP(Gdiplus::Color::Transparent, &tBmp);
delete bmp;
Gdiplus::GdiplusShutdown(token);
}
return tBmp;
}
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
static HBITMAP tBmp = NULL;
switch (message)
{
case WM_CREATE:
{
HWND btn = CreateWindow(L"BUTTON", L"TEXT", BS_BITMAP | WS_VISIBLE |
WS_CHILD | BS_DEFPUSHBUTTON,
100, 100, 95, 25, hwnd, (HMENU)1, NULL, NULL);
tBmp =
loadBitmap(L"C:\\sourcecode\\llib\\include\\llib\\resources\\images\\zoomin_disabled.png");
SendMessage(btn, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)tBmp);
ShowWindow(btn, SW_SHOW);
}
break;
case WM_DESTROY:
DeleteObject(tBmp);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
void SetImageBug(HINSTANCE hInstance)
{
MSG msg;
WNDCLASS wc = { 0 };
wc.lpszClassName = TEXT("EU");
wc.hInstance = hInstance;
wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
wc.lpfnWndProc = WindowProcedure;
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hIcon = NULL;
RegisterClass(&wc);
CreateWindow(wc.lpszClassName, TEXT("Test png loading"),
WS_VISIBLE | WS_CAPTION | WS_SYSMENU ,
(GetSystemMetrics(SM_CXSCREEN) - 230) / 2, (GetSystemMetrics(SM_CYSCREEN)
- 100) / 2, 280 + 10, 110 + 20 + 190, 0, 0, hInstance, 0);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
exit(0);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
{
INITCOMMONCONTROLSEX x;
x.dwSize = sizeof(x);
x.dwICC = ICC_STANDARD_CLASSES;
if(!InitCommonControlsEx(&x)) return 0;
SetImageBug(hInstance);
}
--
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.
More information about the wine-bugs
mailing list