Original Post
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:
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
//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);
}
}