quote:
Originally posted by MSDN
lParam
The low-order word of lParam specifies the new width of the client area.
The high-order word of lParam specifies the new height of the client area.
This is where bitwise operations come in handy. To get the low-order word, you need to get the first word from the number. A word is an unsigned number of 2 bytes or 16 bits. The maximum word value is thus 1111 1111 1111 1111 in binary or 65,535 in decimal or FFFF in hexadecimal. We can now use the & operator to do a bitwise AND operation. The AND operator takes two bits and returns 1 if both bits are 1, otherwise it gives 0. Applying this bit by bit on lParam and 0xFFFF, you'll get 0 for all bits further than bit 16 and bits 1 to 16 will give you the original bits from lParam in that position. This gives you the low-order word.
js code:
var width = lParam & 0xFFFF;
For the height, we need to get the other 16 bits. This can be done by shifting the bits of lParam 16 bit positions to the right using the bitwise right-shift operator >>. For example: bit 20 will be shifted to bit 4 for example and bits 1 to 16 will be discarded. This gives you the high-order word.
js code:
var height = (lParam >> 16);
If you want to be really sure that you're only getting 16 bits, you can do an & 0xFFFF operation on the result to discard any bits after bit 32. This won't be necessary for WM_SIZE since Windows promises you to only give you 32 bits.
Built-in operators are always lots faster than another call to GetWindowRect, so you better use them!