What happens to WPARAM, LPARAM, and LRESULT when they travel between 32-bit and 64-bit windows?
The integral types
LRESULT are 32 bits wide on 32-bit systems
and 64 bits wide on 64-bit systems.
What happens when a 32-bit process sends a message to a 64-bit window
or vice versa?
There’s really only one choice when
converting a 64-bit value to a 32-bit value: Truncation.
When a 64-bit process sends a message to a 32-bit window,
are truncated to 32 bits.
Similarly, when a 64-bit window returns an
to a 32-bit sender, the value is truncated.
But converting a 32-bit value to a 64-bit value introduces a choice:
Do you zero-extend or sign-extend?
The answer is obvious if you remember
the history of
or if you just look at the header file.
WPARAM is zero-extended,
If you remember that
WPARAM used to be a
LRESULT used to be
then this follows from the fact that
WORD is an unsigned type
(therefore zero-extended) and
LONG is a signed type
Even if you didn’t know that, you could look it up in the header file.
typedef UINT_PTR WPARAM; typedef LONG_PTR LPARAM; typedef LONG_PTR LRESULT;
UINT_PTR is an unsigned type (therefore zero-extended)
LONG_PTR is a signed type (therefore sign-extended).