Hey,
I'm having some troubles reloading a new png in place of my old one on my window using the GDI+ SDK. Here is my WM_PAINT message:
case WM_PAINT:
{
BITMAP bm;
PAINTSTRUCT ps;
//Painting the Background
HDC hdc = BeginPaint(hwnd, &ps);
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmOld = (HBITMAP)SelectObject (hdcMem, g_hbmBackground);
GetObject(g_hbmBackground, sizeof(bm), &bm);
BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
SelectObject(hdcMem, hbmOld);
DeleteDC(hdcMem);
OnPaint(hdc);
EndPaint(hwnd, &ps);
}
That mainly paints the background but the OnPaint function paints my pngs. Here's the OnPaint function:
VOID OnPaint(HDC hdc)
{
if (main_menu == 1)
{
Graphics graphics(hdc);
Image image(L"Welcome.png");
graphics.DrawImage(&image, 0, 0);
}
if (main_menu == 2)
{
Graphics graphics(hdc);
Image image(L"Master.png");
graphics.DrawImage(&image, 0, 0);
}
}
Here's the section in the windows procedure that calls WM_PAINT:
ScreenToClient(hwnd,&p);
ScreenToClient(hwnd,&p2);
if(DetectLeftUpClickInRectangle(lParam,p.x,p.y,p2.x,p2.y) == TRUE)
{
main_menu = 2;
InvalidateRect(hwnd,NULL, true);
}
And lastly, here's the DetectLeftUpClickInRectangle function I made:
BOOLEAN DetectLeftUpClickInRectangle(LPARAM lParam, int ex1, int ey1, int ex2, int ey2)
{
static int x1, y1, x2, y2;
if(ex1 != -1)
{
x1 = ex1;
y1 = ey1;
x2 = ex2;
y2 = ey2;
}
int mx, my; //x and y mouse coordinate variables
mx = LOWORD(lParam);
my = HIWORD(lParam);
if( (mx >= x1 && mx <= x2) && (my <= y1 && my >= y2) )
return TRUE;
else
return FALSE;
}
Also, main_menu is defaultly set to equal 1. All I get is the Welcome.png.
Any help?
Thank you.