I'm reading an outdated programming book, "Teach Yourself Windows 95 Programming in 21 Days." It sucks, but whatever. The book advocates using #include <windowsx.h>, but it mentions that it helps with portability between Win16 and Win32, which I don't care about, since Win3.1 is quite dead now. It also mentions using "Message Crackers," a term which may be made up by the author. Anyway, is windowsx.h still used, or is entirely antiquitated?
>>> or is entirely antiquitated?
windowsx.h contains lots of other macros in addition to message crackers which themseleves are very handy. The best way to get familiar with any header is open it up and take a look. :)
For example, a 'traditional' message handler would be one giant switch with a case statement for each handled message. With message crackers the effect is more or less the same but the code is considerably more readable.
But, if you have no use for message crackers or the other macros in windowsx.h then there is no need to include it.
Here's an old msdn article that may be of some interest regarding the use of message crackers.
Yeah, basically, windowsx.h is only a bunch of macros. Nothing that you couldn't do without it.
Actually, for the WM_MOUSEMOVE message (and WM_LBUTTONUP, among others), windowsx.h has the following macros that are useful:
The MSDN with MSVC++ 6.0 states that you can get the coordinates of the mouse like so:
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
Which is incorrect, since these coordiantes can be negative (for example, when capturing the mouse).
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
The MSDN online states you can use the two macros shown above in windowsx.h, or the MAKEPOINTS macro (which converts a value that contains the x- and y-coordinates of a point into a POINTS structure). Unfortunately, most code uses the POINT structure (no S at the end), so the macros in windowsx.h are the most useful in this case.
Please don't bump old threads.