Click to See Complete Forum and Search --> : PrintWindow problem
Chirieac
May 10th, 2008, 01:38 PM
Hi! I try to capture a window with the PrintWindow command. I have a timer that capture it every 1 sec. Everything works, but when I minimize the captured window and maximize it again the window itself doesn't update right anymore: it has the desktop wallpaper on it and the controls appears only when I move my mouse on them.
Here's my code:
RECT rect;
GetWindowRgnBox(hWnd, &rect);
HDC hSrcDC = GetDC(hWnd);
HDC hDestDC = CreateCompatibleDC(hSrcDC);
HBITMAP hBmp = CreateCompatibleBitmap(hSrcDC, rect.right, rect.bottom);
SelectObject(hDestDC, hBmp);
PrintWindow(hWnd, hDestDC, 0);
ReleaseDC(hWnd, hSrcDC);
DeleteDC(hDestDC);
Chirieac
May 11th, 2008, 03:41 PM
Please, help me! I need to make it work now...
Chirieac
May 12th, 2008, 11:23 AM
Please tell at least that there is no fix to that... but say something
Chirieac
May 12th, 2008, 12:16 PM
I've tried everything: RedrawWindow, UpdateWindow, InvalidateRect, InvalidateRgn, ShowWindow... but still after I minimize the window and show it again the problem is the same.
It works only with this: InvalidateRect(0, 0, TRUE), which repaints all the windows and make the screen to flicker.
InvalidateRect(myWindow, 0, TRUE) should work, but no...
Chirieac
May 12th, 2008, 05:41 PM
The only way is to capture the window only when is maximized. But how? If I make it like this:
WINDOWPLACEMENT wndPlace;
wndPlace.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hWnd, &wndPlace);
if (wndPlace.showCmd != SW_SHOWMINIMIZED)
{
CaptureWindow(hWnd);
}
will not work if I'll capture the window every 100 mliisec because until the window is fully maximize the capture function will be called. I must wait until the window is maximezed properly.
I think I'll use a hook for this. But there is a message that will tell me when the window has maximized itself? (not when it's start to maximize).
codeguru.com
Copyright 2007 Jupitermedia Corporation All Rights Reserved.