Yeah, but it''s a pain in the ass to keep things in sync.
The user might click down on the button, move the mouse off of the button, and then click up.
The user might click down on the button, move the mouse off of the button, and then move the mouse back on the button and then click up.
The user might click down somewhere else entirely, and then move the mouse on the button and click up.
The user might click down on the button, move the mouse off and click up. He then could click down somewhere else and move the mouse over the button and click up.
Here''s how to solve it:
LRESULT CALLBACK expandProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){ int id; static int state = 0; int x; int y; RECT rect; id = GetWindowLong (hWnd, GWL_ID); switch (msg) { case WM_LBUTTONDOWN: state = 1; break; case WM_LBUTTONUP: if (state == 0) break; x = LOWORD(lParam); y = HIWORD(lParam); GetClientRect (hWnd, &rect); if (x > rect.right || y > rect.bottom) state = 0; if (x < 0 || y < 0) state = 0; if (state == 0) break; toggleExpandable (Top[id - 5000]); adjustRows (Top[1], 0); state = 0; return 0; break; } return CallWindowProc (buttonProc, hWnd, msg, wParam, lParam);}
Now I just have to get my static state variable to be unique for each button in this class.