Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


CDC::BitBlt problem

This topic is 5979 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;
//get dimensions of this dialog so we get the right part of

//the desktop window

RECT 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


//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



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

Share this post

Link to post
Share on other sites
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]

Share this post

Link to post
Share on other sites
ooohh well then no wonder it wasnt working seen as i was doing it completely wrong .

Thanks very much

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!