I'm trying to design an abstraction layer for windows for various platforms. I decided to add a callback for when a window, or a section of it needs to be redrawn. I'm trying to make it fit into this callback type:
using paint_callback_t = std::function<void(int, int, unsigned int, unsigned int, void*, std::size_t)>;
Where the first 4 parameters are the X, Y coordinates in client space and the width and height of the region that needs to be painted. The problem is in Win32 API there is no obvious way to get the starting X and Y coordinates of a dirty region. When I use BeginPaint in the WM_PAINT case of the WndProc, it returns a device context with it's clipping already set so you can't paint outside the region and the rcPaint member of the PAINTSTRUCT is relative to the clipping space, meaning left and top are 0. GetClipBox also returns the same RECT starting at 0, 0.
Does anyone know how to achieve this? I'm guessing there is some way of maybe creating a Region and then intersecting with the original one to return the original one somehow? I'm really lost on how to achieve this and would appreciate any help.
It turns out the
rcPaintIS in client space. It's just that dragging the window offscreen performs a lot of full redraws of the visible client area. I made this test program to check the values:And this is an example of the messages I got:
Thank you for the help.