diff --git a/wintable/new/main.c b/wintable/new/main.c index f3ffec8..316c760 100644 --- a/wintable/new/main.c +++ b/wintable/new/main.c @@ -53,6 +53,8 @@ static void (*tablePanic)(const char *, DWORD) = NULL; #define panic(...) (*tablePanic)(__VA_ARGS__, GetLastError()) #define abort $$$$ // prevent accidental use of abort() +static BOOL (*WINAPI tableTrackMouseEvent)(LPTRACKMOUSEEVENT); + struct table { HWND hwnd; HWND header; @@ -153,13 +155,17 @@ static void deftablePanic(const char *msg, DWORD lastError) DebugBreak(); } -void initTable(void (*panicfunc)(const char *msg, DWORD lastError)) +void initTable(void (*panicfunc)(const char *msg, DWORD lastError), BOOL (*WINAPI tme)(LPTRACKMOUSEEVENT)) { WNDCLASSW wc; tablePanic = panicfunc; if (tablePanic == NULL) tablePanic = deftablePanic; + if (tme == NULL) + // TODO errorless version + panic("must provide a TrackMouseEvent() to initTable()"); + tableTrackMouseEvent = tme; ZeroMemory(&wc, sizeof (WNDCLASSW)); wc.lpszClassName = tableWindowClass; wc.lpfnWndProc = tableWndProc; @@ -183,7 +189,7 @@ int main(int argc, char *argv[]) icc.dwICC = ICC_LISTVIEW_CLASSES; if (InitCommonControlsEx(&icc) == 0) panic("(test program) error initializing comctl32.dll"); - initTable(NULL); + initTable(NULL, _TrackMouseEvent); mainwin = CreateWindowExW(0, tableWindowClass, L"Main Window", WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL, diff --git a/wintable/new/util.h b/wintable/new/util.h index fd6166a..d23ac27 100644 --- a/wintable/new/util.h +++ b/wintable/new/util.h @@ -89,3 +89,22 @@ static LONG columnWidth(struct table *t, intptr_t n) panic("error getting Table column width"); return r.right - r.left; } + +/* TODO: +http://blogs.msdn.com/b/oldnewthing/archive/2003/10/13/55279.aspx +http://blogs.msdn.com/b/oldnewthing/archive/2003/10/14/55286.aspx +we'll need to make sure that initial edge case works properly +(TODO get the linked article in the latter) +also implement retrack() as so, in the WM_MOUSEMOVE handler +*/ +static void retrack(struct table *t) +{ + TRACKMOUSEEVENT tm; + + ZeroMemory(&tm, sizeof (TRACKMOUSEEVENT)); + tm.cbSize = sizeof (TRACKMOUSEEVENT); + tm.dwFlags = TME_LEAVE; // TODO TME_NONCLIENT as well? + tm.hwndTrack = t->hwnd; + if ((*tableTrackMouseEvent)(&tm) == 0) + panic("error retracking Table mouse events"); +}