PDA

Click to See Complete Forum and Search --> : why is not it so


abdul
Aug 27th, 2001, 04:06 PM
Again, I want to take a screenshot of my desktop and then put that on my window but you can look at the attachment and it is all messed up

Here is the code I am using:

case WM_PAINT:
parenthwnd = GetParent(hwnd);
winhdc = BeginPaint(hwnd, &ps);
parenthdc = GetDC(parenthwnd);
//-----------------------
for(x=0;x<GetSystemMetrics(SM_CXSCREEN);x++)
{
for(y=0;y<GetSystemMetrics(SM_CYSCREEN);y++)
{
SetPixel(winhdc, x,y, GetPixel(parenthdc, x,y));
}
}

EndPaint(hwnd, &ps);
ReleaseDC(parenthwnd, parenthdc);
return 0;



It also takes about 3 to 5 seconds to paint the messed up desktop picture onto the window. What is wrong with that?


I could not post the whole picture because it was too big but I am getting the same thing on the whole window

Vlatko
Aug 27th, 2001, 04:23 PM
I've an app like thet some 2 months ago but i used
GetDesktopWIndow to get the hwnd then GetDC to get the dc of the desktop window. Why are you using GetParent, BeginPaint or SetPixel. Just use BitBlt to copy the contents of the dc to your window or image box.

abdul
Aug 27th, 2001, 06:51 PM
ok, I did what you said using this code:


parenthwnd = GetDesktopWindow();
winhdc = GetDC(hwnd);
parenthdc = GetDC(parenthwnd);

BitBlt(winhdc, 0,0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), parenthdc, 0,0, SRCCOPY);

ReleaseDC(parenthwnd, parenthdc);
ReleaseDC(hwnd, winhdc);



This code just gives the same result as the above code and it also freezes. How can I get the exact picture of the desktop?

abdul
Aug 27th, 2001, 07:14 PM
Never mind, I just got it working but I have problem keeping the picture visible because whenever I recieve a WM_PAINT message it just erases the picture on my window so... do I use a static picture box control and put the picture in there. Will this method work?

Vlatko
Aug 28th, 2001, 08:18 AM
Yes putting it in a picture box would solve the problem.