From 99bfbbbed5ead6a4e4f103c439236784c851d26f Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 19 Oct 2014 19:02:18 -0400 Subject: [PATCH] Simplified the code a bit. --- wintable/main.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/wintable/main.c b/wintable/main.c index ac3dd94..b5ca5ba 100644 --- a/wintable/main.c +++ b/wintable/main.c @@ -47,27 +47,22 @@ static void drawItems(struct table *t, HDC dc) abort(); y = 0; for (i = 0; i < 100; i++) { + RECT rsel; + HBRUSH background; + // TODO check errors // TODO verify correct colors + rsel.left = r.left; + rsel.top = y; + rsel.right = r.right - r.left; + rsel.bottom = y + tm.tmHeight; + background = (HBRUSH) (COLOR_WINDOW + 1); if (t->selected == i) { - RECT rsel; - + background = (HBRUSH) (COLOR_HIGHLIGHT + 1); SetTextColor(dc, GetSysColor(COLOR_HIGHLIGHTTEXT)); - rsel.left = r.left; - rsel.top = y; - rsel.right = r.right - r.left; - rsel.bottom = y + tm.tmHeight; - FillRect(dc, &rsel, (HBRUSH) (COLOR_HIGHLIGHT + 1)); - } else { - RECT rsel; - + } else SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT)); - rsel.left = r.left; - rsel.top = y; - rsel.right = r.right - r.left; - rsel.bottom = y + tm.tmHeight; - FillRect(dc, &rsel, (HBRUSH) (COLOR_WINDOW + 1)); - } + FillRect(dc, &rsel, background); SetBkMode(dc, TRANSPARENT); TextOutW(dc, r.left, y, L"Item", 4); y += tm.tmHeight;