Thread: Windowsx.h

  1. #1
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916

    Windowsx.h

    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?
    Away.

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> or is entirely antiquitated?

    Yup.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    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.

  4. #4
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Yeah, basically, windowsx.h is only a bunch of macros. Nothing that you couldn't do without it.

  5. #5
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    Actually, for the WM_MOUSEMOVE message (and WM_LBUTTONUP, among others), windowsx.h has the following macros that are useful:
    Code:
    #define GET_X_LPARAM(lp)                        ((int)(short)LOWORD(lp))
    #define GET_Y_LPARAM(lp)                        ((int)(short)HIWORD(lp))
    The MSDN with MSVC++ 6.0 states that you can get the coordinates of the mouse like so:
    Code:
    xPos = LOWORD(lParam);  // horizontal position of cursor 
    yPos = HIWORD(lParam);  // vertical position of cursor
    Which is incorrect, since these coordiantes can be negative (for example, when capturing the mouse).

    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.

  6. #6
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Please don't bump old threads.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need some help with windowsx.h compile error.
    By chadsxe in forum C++ Programming
    Replies: 2
    Last Post: 03-24-2006, 02:55 PM