Cannot paint into offscreen DC
I have this code for drawing my custom control. I am going to do my drawing into an off-screen DC and then blit it to the screen DC. However, it won't work. If i pass the screen DC to the Rectangle() function it will draw a rectangle, but when passing the memory DC it will not. I have done this many times before, but I can't get it to work in this particular case. Does it have anything to do with my OO approach?
Edit: What I mean by "won't work" is that seemingly nothing gets drawn to the memory DC. No function calls fail either. I have checked return values and GetLastError(). I can for instance use the BLACKNESS raster operation on the BitBlt function and the control gets painted black.
LRESULT Button::OnPaint(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
m_hdc = BeginPaint(hwnd,&ps);
void Button::OffscreenBitmap(PAINTSTRUCT *ps)
HDC hdcMem = CreateCompatibleDC(ps->hdc);
HBITMAP hbm = CreateCompatibleBitmap(ps->hdc,m_cx,m_cy);
hbmOld = (HBITMAP)SelectObject(hdcMem,hbm);