summaryrefslogtreecommitdiff
path: root/wintable/test.c
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-01-07 19:41:31 -0500
committerPietro Gagliardi <[email protected]>2015-01-07 19:42:00 -0500
commitad6caaf3721ba457252b67d0a271e6e55f9b6f9f (patch)
treea8d5777704fbcb35776ae97ddffede79619d42b1 /wintable/test.c
parentb3c0a7acaf5bb779d6ccfc165399fe9415b7d203 (diff)
Image cells now use notifications to get their bitmaps. Also split (almost) each cell type into a separate drawing function called from the main drawCell().
Diffstat (limited to 'wintable/test.c')
-rw-r--r--wintable/test.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/wintable/test.c b/wintable/test.c
index 1ffad26..f09d609 100644
--- a/wintable/test.c
+++ b/wintable/test.c
@@ -3,14 +3,13 @@
// #qo LIBS: user32 kernel32 gdi32 comctl32 uxtheme ole32 oleaut32 oleacc uuid msimg32
-HBITMAP testbitmap;
-void mkbitmap(void);
-
#include "main.h"
HWND tablehwnd = NULL;
BOOL msgfont = FALSE;
+HBITMAP mkbitmap(void);
+
BOOL mainwinCreate(HWND hwnd, LPCREATESTRUCT lpcs)
{
tablehwnd = CreateWindowExW(0,
@@ -77,7 +76,7 @@ LRESULT CALLBACK mainwndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
_swprintf(text, L"mainwin (%d,%d)", nm->row, nm->column);
return (LRESULT) text;
case tableColumnImage:
- return (LRESULT) testbitmap;
+ return (LRESULT) mkbitmap();
case tableColumnCheckbox:
; // TODO
}
@@ -88,7 +87,8 @@ LRESULT CALLBACK mainwndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
free((void *) (nm->data));
break;
case tableColumnImage:
- // do nothing
+ if (DeleteObject((HBITMAP) (nm->data)) == 0)
+ panic("(test program) error deleting cell image");
break;
}
return 0;
@@ -161,10 +161,11 @@ COLORREF iconpix[] = {
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1B050A11, 0x4000102, 0x0, 0x0,
};
-void mkbitmap(void)
+HBITMAP mkbitmap(void)
{
BITMAPINFO bi;
void *ppvBits;
+ HBITMAP b;
ZeroMemory(&bi, sizeof (BITMAPINFO));
bi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
@@ -174,8 +175,9 @@ void mkbitmap(void)
bi.bmiHeader.biBitCount = 32;
bi.bmiHeader.biCompression = BI_RGB;
bi.bmiHeader.biSizeImage = 16 * 16 * 4;
- testbitmap = CreateDIBSection(NULL, &bi, DIB_RGB_COLORS, &ppvBits, 0, 0);
- if (testbitmap == 0)
+ b = CreateDIBSection(NULL, &bi, DIB_RGB_COLORS, &ppvBits, 0, 0);
+ if (b == 0)
panic("test bitmap creation failed");
memcpy(ppvBits, iconpix, bi.bmiHeader.biSizeImage);
+ return b;
}