c++ - How does "BeginPaint" function know the update region - windows programming? -


i'm new windows programming , have question painting windows, beginpaint function

when reading on msdn says that

start painting operation calling beginpaint function. function fills in paintstruct structure information on repaint request. current update region given in rcpaint member of paintstruct.

my question when handle wm_paint message in wndproc , start calling beginpaint function, didn't provide function data particular message received or update region needs painted, so how function fill paintstruct including invalid rect "rcpaint member" ?!

    case wm_paint:     {         paintstruct ps;         hdc hdc = beginpaint(hwnd, &ps);         // painting occurs here, between beginpaint , endpaint.         endpaint(hwnd, &ps);     } 

and when referenced beginpaint function on msdn, says

an application should not call beginpaint except in response wm_paint message

my guess may function gets information internally windows requesting information , last wm_paint message sent window passed it's handle "`hwnd'" first parameter function. correct ?

thanks in advance.

i doubt documented anywhere it's implementation detail doesn't concern programmers, i'm pretty sure update region internal data structure stored along hwnd. can tell because there several functions operate on update region based on hwnd: [in]validaterect, [in]validatergn, getupdatergn, beginpaint, etc.


Comments