I'm trying to load a png to my button, but it's not showing the png in my button.
I create my button with this function:
HWND MyControls::CreateButton(LPCTSTR text, int x, int y, int w, int h, HMENU id, HWND hwnd, HINSTANCE hInst, bool png){
if (png){
return CreateWindow("BUTTON", text, BS_BITMAP | WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
x, y, w, h, hwnd, id, hInst, NULL);
}
else{
return CreateWindow("BUTTON", text, WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
x, y, w, h, hwnd, id, hInst, NULL);
}
}
Add Png to button (WM_CREATE):
void MyControls::AddPngBtn(HWND hwnd, const WCHAR* fileName){
Bitmap bmp(fileName);
HBITMAP tBmp;
bmp.GetHBITMAP(Color(0, 0, 0, 0), &tBmp);
SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)tBmp);
ShowWindow(hwnd, SW_SHOW);
DeleteObject(tBmp);
}
how i initialize GDI+:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(szCmdLine);
UNREFERENCED_PARAMETER(iCmdShow);
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
if (!Wnd.RegClassEx(hInstance)) return 0;
if (!Wnd.CreateMyWindow(hInstance)) return 0;
GdiplusShutdown(gdiplusToken);
return Wnd.MyMsg();
}
The LPARAM is not NULL;
My button size: 25x25;
My png size: 24x24;
And i don't have a error in the "Error List".
What i should do, or what am i doing wrong?
Ty.