Skip to main content
gamedev.net
🔒 Locked

CDC::BitBlt problem

Started by Zeke Jul 29, 2002 at 5:19 AM 1 replies 800+ views
Original Post
Zeke
Zeke
Ive got a dialog box that when a particular button is pressed another dialog box pops up but i want this dialog box to be invisible so i figured that before its created get an image of the desktop where this dialog box will appear and then draw that image onto the dialog box when it does appear here is my code for doing so:
  
//grab a dc compatible with the desktop dc

CClientDC* pDeskCDC=new CClientDC(NULL);

//and another one to blit to (to store for WM_PAINT)

pDC=new CDC;
pDC->CreateCompatibleDC(NULL);
//get dimensions of this dialog so we get the right part of

//the desktop window

RECT Rect;
GetWindowRect(&Rect);

int xPos=Rect.left;
int yPos=Rect.top;
int iWidth=Rect.right-xPos;
int iHeight=Rect.bottom-yPos;
//blit the rect specified above from the dekstop to

//my memory dc to be used in OnPaint

pDC->BitBlt(0,0,iWidth,iHeight,pDeskCDC,xPos,yPos,SRCCOPY);

//test that it has actually copied it

for(int y=0;y<iHeight;y++)
{
	for(int x=0;x<iWidth;x++)
	{
                //find color of pixels in memory dc

		COLORREF color=pDC->GetPixel(x,y);

		DWORD Red=GetRValue(color);
		DWORD Green=GetGValue(color);
		DWORD Blue=GetBValue(color);

                //find color of pixels in desktrop dc

                //i.e. the color the above pixels should be

		color=pDeskCDC->GetPixel(x,y);

		Red=GetRValue(color);
		Green=GetGValue(color);
		Blue=GetBValue(color);
	}
}

  
The problem is the dekstop pixels are the correct color but the pixels of the memory dc are all black showing me that the BitBlt() didnt work even though it returns a success. Can anyone tell me what im doing wrong? Thanks for your time
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Tornado
Tornado
You can't just draw into the DC. You first need to create a bitmap and select it into the DC.
So after you create the new DC, call CreateCompatibleBitmap() to create a new bitmap as the same size as the desktop, and SelectObject() it into the new DC.
Then you can blit to it


Goblineye Entertainment
The road to success is always under construction

[edited by - Tornado on July 29, 2002 6:52:50 AM]
Goblineye EntertainmentThe road to success is always under construction
Zeke
Zeke
ooohh well then no wonder it wasnt working seen as i was doing it completely wrong .

Thanks very much
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.