how to paint a bitmap on client?
-
case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; hdcMem = CreateCompatibleDC (hdc) ; SelectObject (hdcMem, hBitmap) ; BitBlt (hdc, 0, 0, cx , cy, hdcMem, 0, 0, SRCCOPY) ; DeleteDC (hdcMem) ; EndPaint (hwnd, &ps) ; return 0 ; it is a way,but how to paint without memory device context? but SelectObject (hdc, hBitmap) does not put bitmap on screen.
-
case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; hdcMem = CreateCompatibleDC (hdc) ; SelectObject (hdcMem, hBitmap) ; BitBlt (hdc, 0, 0, cx , cy, hdcMem, 0, 0, SRCCOPY) ; DeleteDC (hdcMem) ; EndPaint (hwnd, &ps) ; return 0 ; it is a way,but how to paint without memory device context? but SelectObject (hdc, hBitmap) does not put bitmap on screen.
derek7 wrote:
but how to paint without memory device context?
if you can get your image as a DIB, you can use StretchDIBits (and related functions). but if you have an HBITMAP/CBitmap, you'll need to use a memory DC. Cleek | Image Toolkits | Thumbnail maker
-
case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; hdcMem = CreateCompatibleDC (hdc) ; SelectObject (hdcMem, hBitmap) ; BitBlt (hdc, 0, 0, cx , cy, hdcMem, 0, 0, SRCCOPY) ; DeleteDC (hdcMem) ; EndPaint (hwnd, &ps) ; return 0 ; it is a way,but how to paint without memory device context? but SelectObject (hdc, hBitmap) does not put bitmap on screen.
Hi derek7, CImage m_Image; m_Image.Load("c:\\picture.bmp"); void CAnswerView::OnPaint() { CPaintDC dc(this); // device context for painting m_Image.BitBlt(dc.m_hDC,CRect(0,0,800,600),CPoint(0,0)); } -- modified at 9:04 Monday 13th March, 2006
-
Hi derek7, CImage m_Image; m_Image.Load("c:\\picture.bmp"); void CAnswerView::OnPaint() { CPaintDC dc(this); // device context for painting m_Image.BitBlt(dc.m_hDC,CRect(0,0,800,600),CPoint(0,0)); } -- modified at 9:04 Monday 13th March, 2006
-Although you do NOT want to keep on loading the image file each time you get a paint message... Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!) -
-Although you do NOT want to keep on loading the image file each time you get a paint message... Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!)Thank you for remind