ack...sorry i was doing cut and paste to replicate the problem and the SelectBrush() wasn't there at first.
Here is the actual problem:
Code:
hDC = GetDC(hwnd);
HBITMAP hbitmap;
// create bitmap brush
hbitmap = LoadBitmap(hinst,MAKEINTRESOURCE(IDB_BACKGROUND));
hbrush = CreatePatternBrush(hbitmap);
DeleteBitmap(hbitmap);
SelectBrush(hDC,hbrush);
ReleaseDC(hwnd,hDC);
My background brush was initially (COLOR_WINDOW+1) for the hbrBackground field.
list of things i tried AFTER CREATING THE WINDOW and didnt work
:
1. Delete bitmap after selecting brush
Code:
hDC = GetDC(hwnd);
HBITMAP hbitmap;
// create bitmap brush
hbitmap = LoadBitmap(hinst,MAKEINTRESOURCE(IDB_BACKGROUND));
hbrush = CreatePatternBrush(hbitmap);
SelectBrush(hDC,hbrush);
DeleteBitmap(hbitmap);
ReleaseDC(hwnd,hDC);
2. select black brush into hDC, the background remains white instead of black
Code:
hDC = GetDC(hwnd);
HBITMAP hbitmap;
// create bitmap brush
hbitmap = LoadBitmap(hinst,MAKEINTRESOURCE(IDB_BACKGROUND));
hbrush = CreatePatternBrush(hbitmap);
SelectBrush(hDC,hbrush);
DeleteBitmap(hbitmap);
SelectBrush(hDC,GetStockBrush(BLACK_BRUSH));
ReleaseDC(hwnd,hDC);
BTW, I am using private DCs because i will be making two windows base on the same window class. But their background will be of different bitmap brush.