diff --git a/wintable/accessibility.h b/wintable/accessibility.h index 15a7aa8..6783353 100644 --- a/wintable/accessibility.h +++ b/wintable/accessibility.h @@ -1,7 +1,7 @@ // 24 december 2014 struct tableAcc { - IAccessibleVtbl *vtbl; + const IAccessibleVtbl *vtbl; ULONG refcount; struct table *t; IAccessible *std; @@ -20,8 +20,7 @@ static HRESULT STDMETHODCALLTYPE tableAccQueryInterface(IAccessible *this, REFII if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDispatch) || IsEqualIID(riid, &IID_IAccessible)) { - // TODO figure out what pointer to use here - TA->vtbl->AddRef(TA); + IAccessible_AddRef(this); *ppvObject = (void *) this; return S_OK; } @@ -218,9 +217,10 @@ static struct tableAcc *newTableAcc(struct table *t) ta = (struct tableAcc *) tableAlloc(sizeof (struct tableAcc), "error creating Table accessibility object"); ta->vtbl = &tableAccVtbl; - ta->vtbl->AddRef(ta); + // TODO + IAccessible_AddRef((IAccessible *) ta); ta->t = t; - hr = CreateStdAccessibleObject(t->hwnd, OBJID_CLIENT, &IID_IAccessible, &std); + hr = CreateStdAccessibleObject(t->hwnd, OBJID_CLIENT, &IID_IAccessible, (void *) (&std)); if (hr != S_OK) // TODO panichresult panic("error creating standard accessible object for Table"); @@ -234,16 +234,23 @@ static struct tableAcc *newTableAcc(struct table *t) static void freeTableAcc(struct tableAcc *ta) { ta->t = NULL; - ta->vtbl->Release(ta); + // TODO + IAccessible_Release((IAccessible *) ta); } HANDLER(accessibilityHandler) { if (uMsg != WM_GETOBJECT) return FALSE; - if (((DWORD) lParam) != OBJID_CLIENT) + // OBJID_CLIENT evaluates to an expression of type LONG + // the documentation for WM_GETOBJECT says to cast "it" to a DWORD before comparing + // https://msdn.microsoft.com/en-us/library/windows/desktop/dd373624%28v=vs.85%29.aspx casts them both to DWORDs; let's do that + // its two siblings only cast lParam, resulting in an erroneous DWORD to LONG comparison + // The Old New Thing book does not cast anything + // Microsoft's MSAA sample casts lParam to LONG instead! + if (((DWORD) lParam) != ((DWORD) OBJID_CLIENT)) return FALSE; - *lResult = LresultFromObject(&IID_IAccessible, wParam, t->ta); + *lResult = LresultFromObject(&IID_IAccessible, wParam, (LPUNKNOWN) (t->ta)); // TODO check *lResult return TRUE; } diff --git a/wintable/checkboxes.h b/wintable/checkboxes.h index 6e62621..75ad9f4 100644 --- a/wintable/checkboxes.h +++ b/wintable/checkboxes.h @@ -131,7 +131,6 @@ static void redrawCheckboxRect(struct table *t, LPARAM lParam) { struct rowcol rc; RECT r; - POINT pt; rc = lParamToRowColumn(t, lParam); if (rc.row == -1 && rc.column == -1) diff --git a/wintable/draw.h b/wintable/draw.h index 98c1402..1b861db 100644 --- a/wintable/draw.h +++ b/wintable/draw.h @@ -140,7 +140,6 @@ static void drawCell(struct table *t, HDC dc, struct drawCellParams *p) static void draw(struct table *t, HDC dc, RECT cliprect, RECT client) { intptr_t i, j; - int x = 0; HFONT prevfont, newfont; struct drawCellParams p; diff --git a/wintable/main.h b/wintable/main.h index ff86c35..235467b 100644 --- a/wintable/main.h +++ b/wintable/main.h @@ -1,5 +1,8 @@ // 7 january 2015 +// TODO remove +#include + // TODO // - should tablePanic be CALLBACK or some other equivalent macro? and definitely export initTable somehow, but which alias macro to use? // - make panic messages grammatically correct ("Table error: adding...") @@ -185,7 +188,7 @@ printf("destroy\n"); static void deftablePanic(const char *msg, DWORD lastError) { - fprintf(stderr, "Table error: %s (last error %d)\n", msg, lastError); + fprintf(stderr, "Table error: %s (last error %I32u)\n", msg, lastError); fprintf(stderr, "This is the default Table error handler function; programs that use Table should provide their own instead.\nThe program will now break into the debugger.\n"); DebugBreak(); } diff --git a/wintable/util.h b/wintable/util.h index 4dd73d6..164ca72 100644 --- a/wintable/util.h +++ b/wintable/util.h @@ -5,7 +5,7 @@ typedef BOOL (*handlerfunc)(struct table *, UINT, WPARAM, LPARAM, LRESULT *); static BOOL runHandlers(const handlerfunc list[], struct table *t, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult) { - handlerfunc *p; + const handlerfunc *p; for (p = list; *p != NULL; p++) if ((*(*p))(t, uMsg, wParam, lParam, lResult))