diff --git a/wintable/api.h b/wintable/api.h index fb0e1c0..bf259ad 100644 --- a/wintable/api.h +++ b/wintable/api.h @@ -14,6 +14,8 @@ static void addColumn(struct table *t, WPARAM wParam, LPARAM lParam) HANDLER(apiHandlers) { + intptr_t *rcp; + switch (uMsg) { case WM_SETFONT: // don't free the old font; see http://blogs.msdn.com/b/oldnewthing/archive/2008/09/12/8945692.aspx @@ -30,6 +32,13 @@ HANDLER(apiHandlers) addColumn(t, wParam, lParam); *lResult = 0; return TRUE; + case tableSetRowCount: + rcp = (intptr_t *) lParam; + t->count = *rcp; + // TODO refresh table in this way? + updateTableWidth(t); + *lResult = 0; + return TRUE; } return FALSE; } diff --git a/wintable/main.h b/wintable/main.h index d17f5d8..c8ba30c 100644 --- a/wintable/main.h +++ b/wintable/main.h @@ -12,14 +12,19 @@ // - collect all resize-related tasks in a single function (so things like adding columns will refresh everything, not just horizontal scrolls; also would fix initial coordinates) // - checkbox columns don't clip to the column width // - send standard notification codes +// - seriously figure out how we're going to update everything about the table in one place #define tableWindowClass L"gouitable" // start at WM_USER + 20 just in case for whatever reason we ever get the various dialog manager messages (see also http://blogs.msdn.com/b/oldnewthing/archive/2003/10/21/55384.aspx) +// each of these returns nothing unless otherwise indicated enum { // wParam - one of the type constants // lParam - column name as a Unicode string tableAddColumn = WM_USER + 20, + // wParam - 0 + // lParam - pointer to intptr_t containing new count + tableSetRowCount, }; enum { @@ -127,7 +132,6 @@ static const handlerfunc handlers[] = { static void initDummyTableStuff(struct table *t) { - t->count = 100; t->selectedRow = 2; t->selectedColumn = 1; } diff --git a/wintable/test.c b/wintable/test.c index 9e01a94..6d38bd1 100644 --- a/wintable/test.c +++ b/wintable/test.c @@ -12,6 +12,8 @@ HBITMAP mkbitmap(void); BOOL mainwinCreate(HWND hwnd, LPCREATESTRUCT lpcs) { + intptr_t c; + tablehwnd = CreateWindowExW(0, tableWindowClass, L"Main Window", WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL, @@ -36,6 +38,8 @@ BOOL mainwinCreate(HWND hwnd, LPCREATESTRUCT lpcs) panic("(test program) error creating lfMessageFont HFONT"); SendMessageW(tablehwnd, WM_SETFONT, (WPARAM) font, TRUE); } + c = 100; + SendMessageW(tablehwnd, tableSetRowCount, 0, (LPARAM) (&c)); SetFocus(tablehwnd); return TRUE; }