Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

BitBlt trouble.

Question posted by: DumRat (Member) on June 4th, 2008 02:17 PM
Hi,
Can anyone plz help?
I have the following code for the WM_PAINT event, but it doesn't work. Need to knw why. I'm drawing the scene to the window, but am using an intermediate DC. Then it just shows a white screen, however, if I drop the intermediate DC, it works. I need to know why this fails. Thanks in advance.

Code: ( text )
  1. case WM_PAINT:
  2.         {
  3.         HBITMAP hBm = (HBITMAP)LoadImageA(NULL, "black.bmp", IMAGE_BITMAP, 768, 768, LR_LOADFROMFILE);
  4.         HBITMAP hBmMask = (HBITMAP)LoadImageA(NULL, "blackm.bmp", IMAGE_BITMAP, 768, 768, LR_LOADFROMFILE);
  5.         HDC ourDC = CreateCompatibleDC(GetDC(hWnd));
  6.         HDC comDC = CreateCompatibleDC(ourDC);
  7.         HDC mDC = CreateCompatibleDC(ourDC);
  8.         HBITMAP old = (HBITMAP)SelectObject(comDC, hBm);
  9.         HBITMAP old2 = (HBITMAP)SelectObject(mDC, hBmMask);
  10.        
  11.         BitBlt(ourDC, 0, 0, 768, 768, mDC, 0, 0, SRCAND);
  12.         BitBlt(ourDC, 0, 0, 768, 768, comDC, 0, 0, SRCPAINT);
  13.  
  14.         BitBlt(GetDC(hWnd), 0, 0, 768, 768, ourDC, 0, 0, SRCCOPY);
  15.         }
  16.         break;
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
romanize's Avatar
romanize
Newbie
5 Posts
July 24th, 2008
12:37 PM
#2

Re: BitBlt trouble.
a late response it seems. have you found out where the problem was?
i remember having similar problems - some years ago though. did you try to createcompatibledc from the same GetDC?
r.

Reply
Reply
Not the answer you were looking for? Post your question . . .
182,317 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top C / C++ Forum Contributors