2014-12-08 09:01:41 -06:00
|
|
|
// 8 december 2014
|
|
|
|
|
|
|
|
static void draw(struct table *t, HDC dc, RECT cliprect, RECT client)
|
|
|
|
{
|
2014-12-08 09:40:51 -06:00
|
|
|
LRESULT i, n;
|
|
|
|
RECT r;
|
|
|
|
int x = 0;
|
|
|
|
|
|
|
|
n = SendMessageW(t->header, HDM_GETITEMCOUNT, 0, 0);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
SendMessage(t->header, HDM_GETITEMRECT, (WPARAM) i, (LPARAM) (&r));
|
|
|
|
r.top = client.top;
|
|
|
|
r.bottom = client.bottom;
|
|
|
|
FillRect(dc, &r, GetSysColorBrush(x));
|
|
|
|
x++;
|
|
|
|
}
|
2014-12-08 09:01:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
HANDLER(drawHandlers)
|
|
|
|
{
|
|
|
|
HDC dc;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
RECT client;
|
|
|
|
RECT r;
|
|
|
|
|
|
|
|
if (uMsg != WM_PAINT && uMsg != WM_PRINTCLIENT)
|
|
|
|
return FALSE;
|
|
|
|
if (GetClientRect(t->hwnd, &client) == 0)
|
|
|
|
panic("error getting client rect for Table painting");
|
2014-12-08 14:54:55 -06:00
|
|
|
if (uMsg == WM_PAINT) {
|
2014-12-08 09:01:41 -06:00
|
|
|
dc = BeginPaint(t->hwnd, &ps);
|
|
|
|
if (dc == NULL)
|
|
|
|
panic("error beginning Table painting");
|
|
|
|
r = ps.rcPaint;
|
|
|
|
} else {
|
|
|
|
dc = (HDC) wParam;
|
|
|
|
r = client;
|
|
|
|
}
|
|
|
|
draw(t, dc, r, client);
|
2014-12-08 14:54:55 -06:00
|
|
|
if (uMsg == WM_PAINT)
|
2014-12-08 09:01:41 -06:00
|
|
|
EndPaint(t->hwnd, &ps);
|
2014-12-08 14:54:55 -06:00
|
|
|
// this is correct for WM_PRINTCLIENT; see http://stackoverflow.com/a/27362258/3408572
|
2014-12-08 09:01:41 -06:00
|
|
|
*lResult = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|