Added mouse tracking code. Not used yet.
This commit is contained in:
parent
0c21608853
commit
9e66dc006e
|
@ -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,
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue