This line:
LONG l=(LONG)TableDraw(lParam);
stores a 64 bit pointer value into a 32 bit integral variable! You're probably losing information.
Hint: never use C-style type casts! They tend to hide dramatical errors from your sight. Without the typecast, the compiler would have issued an error message, and told you what is wrong.
Rule of thumb: if the compiler tells you something about types not fitting, then
- either one of the types is badly chosen (fix: change type of variable)
- or the statement does not use the correct variables (fix: find the correct variable to use)
- or the statement doesn't make sense and actually contains a semantical error that needs to be fixed. (fix: whatever it takes to correct the semantics)
Either way, casting the type merely shuts up the compiler, but it won't resolve the actual problem!
P.S.: SetWindowLong() has been superseded by the SetWindowLongPtr() function to make it independent of the target platform (32 or 64 bit).
P.P.S.: If you can't avoid type casts (e. g. with the Windows API and it's LPARAM/WPARAM/LRESULT types) you should still prefer static_cast or reinterpret_cast over C-style. Then you get at least some checks and corresponding error messages.