-
Help with CDC.
I have just signed up for this new board so lets see if can get any replies for this.
I have the following code in Microsoft Visual C++ 6.0
CBitmap bmpBlue;
bmpBlue.LoadBitmap(IDB_BLUE);
CDC bmpDC;
bmpDC.CreateCompatibleDC(dc);
bmpDC.SelectObject(&bmpBlue);
CDC memDC;
memDC.CreateCompatibleDC(dc);
memDC.BitBlt(0,0,400,400,&bmpDC,0,0,SRCCOPY);
BitBlt(dc->m_hDC, 0, 0, 400, 400, memDC.m_hDC, 0, 0, SRCCOPY);
and it outputs nothing. I belive this is because the memDC does not have a size. If i just paint the tmpDC like this:
BitBlt(dc->m_hDC, 0, 0, 400, 400, bmpDC.m_hDC, 0, 0, SRCCOPY);
it works fine. Do you know i can fix my problem?
Thanx,
HeadExplodes .:p
-
You have to select your bitmap into your memDC to 'paint' onto.
-
So i HAVE to have a window or bitmap accociated with the CDC for it to work?
-
Yes, you need to create the memDC from an existing DC and then select a bitmap into the memDC.
Then when you use GDI functions using the memDC you are drawing on the bitmap you've selected into it.