Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Sat Feb 06, 2010 6:16 am Post subject: |
|
|
Finally today i got my time to look into some double buffering, the idea seems pretty simple to me, however i dont seem to be able to get it to work, here is my code so far:
| Code: | LRESULT CustomControl::OnPaint(){
HDC hDC = GetDC(hWnd);
HDC hDCMem = CreateCompatibleDC(hDC);
RECT rect;
GetClientRect(hWnd, &rect);
int iHeight = rect.bottom-rect.top;
int iWidth = rect.right-rect.left;
HBITMAP hBM = CreateCompatibleBitmap(hDCMem, iWidth, iHeight);
HBITMAP hOldBM = (HBITMAP)SelectObject(hDCMem, hBM);
//Paint code here, right?, painting to the hDCMem
BitBlt(hDC, 0, 0, iWidth, iHeight, hDCMem, 0, 0, SRCCOPY);
SelectObject(hDCMem, hOldBM);
DeleteObject(hBM);
DeleteDC(hDCMem);
ReleaseDC(hWnd, hDC);
return 0;
} |
But whatever i do to paint the hDCMem, it keeps being entirely black, what am i doing wrong? , i can paint it using TextOut, then the text will show in black, and the background around the text will be gray (as any other window), but how do i make the entire hDCMem gray?, if i try to SetBkColor with anything but 0xFFFFFF, the Text wont even show, and it will stay entirely black -.-
edit: FillRect seems to solve the entire black thing, except that i can only make it white..., but SetBkColor still doesent work
|
|