Help with using InvalidateRect API function to update only part of the screen
-
Hi, I am doing an entire screen capture INCLUDING THE MOUSE CURSOR. For GDI function calls, the mouse cursor is automatically hidden. Therefore, I have to get a handle of the current mouse cursor and use DrawIcon to draw it onto the screen. After the screen capture, I have to invalidate the area where the mouse cursor is drawn so the drawn mouse cursor won't stay on the screen. I am using InvalidateRect(NULL, NULL, TRUE) to redraw all the windows, but this results in a very serious screen flickering while capturing the screen. I cannot figure out how to invalidate only the area where the mouse cursor is drawn. Could you give me some pointers, tips, or samples how to achieve this with InvalidateRect function? Thank you very much for your help.
-
Hi, I am doing an entire screen capture INCLUDING THE MOUSE CURSOR. For GDI function calls, the mouse cursor is automatically hidden. Therefore, I have to get a handle of the current mouse cursor and use DrawIcon to draw it onto the screen. After the screen capture, I have to invalidate the area where the mouse cursor is drawn so the drawn mouse cursor won't stay on the screen. I am using InvalidateRect(NULL, NULL, TRUE) to redraw all the windows, but this results in a very serious screen flickering while capturing the screen. I cannot figure out how to invalidate only the area where the mouse cursor is drawn. Could you give me some pointers, tips, or samples how to achieve this with InvalidateRect function? Thank you very much for your help.
Well, that call to InvalidateRect will invalidate all windows causing WM_PAINT messages to be sent to all of them, since the HWND is NULL. And the TRUE for the bErase means that when each WM_PAINT handler calls BeginPaint (directly or by constructing a CPaintDC) the WM_ERASEBKGND message will be sent as well, causing much flicker. It sounds like you know where to draw the icon, so I would suggest that you have all the info you need to fill in these values - which window, a RECT corresponding to the icon location, and, depending on the nature of the window, perhaps FALSE for bErase, and things will be much smoother.