What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [help] Windows widths and heights...

[help] Windows widths and heights...
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: [help] Windows widths and heights...
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.
Javascript 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.
Javascript 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! :D

This post was edited on 01-06-2010 at 06:51 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
01-06-2010 06:51 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[help] Windows widths and heights... - by whiz on 01-06-2010 at 06:15 PM
RE: [help] Windows widths and heights... - by Mnjul on 01-06-2010 at 06:25 PM
RE: [help] Windows widths and heights... - by Spunky on 01-06-2010 at 06:26 PM
RE: [help] Windows widths and heights... - by Mnjul on 01-06-2010 at 06:28 PM
RE: [help] Windows widths and heights... - by whiz on 01-06-2010 at 06:33 PM
RE: [help] Windows widths and heights... - by Matti on 01-06-2010 at 06:51 PM
RE: [help] Windows widths and heights... - by whiz on 01-06-2010 at 07:09 PM
RE: [help] Windows widths and heights... - by Spunky on 01-06-2010 at 07:15 PM
RE: [help] Windows widths and heights... - by whiz on 01-06-2010 at 07:21 PM
RE: [help] Windows widths and heights... - by Spunky on 01-06-2010 at 07:26 PM
RE: [help] Windows widths and heights... - by whiz on 01-06-2010 at 07:31 PM
RE: [help] Windows widths and heights... - by Spunky on 01-06-2010 at 07:37 PM
RE: [help] Windows widths and heights... - by whiz on 01-06-2010 at 07:55 PM
RE: [help] Windows widths and heights... - by Spunky on 01-06-2010 at 08:13 PM
RE: [help] Windows widths and heights... - by whiz on 01-06-2010 at 08:53 PM
RE: [help] Windows widths and heights... - by T-PO on 01-06-2010 at 09:17 PM
RE: [help] Windows widths and heights... - by Eljay on 01-06-2010 at 09:31 PM
RE: [help] Windows widths and heights... - by whiz on 01-06-2010 at 09:49 PM
RE: [help] Windows widths and heights... (solved for now) - by matty on 01-06-2010 at 11:10 PM
RE: [help] Windows widths and heights... (solved for now) - by whiz on 01-07-2010 at 02:04 PM
RE: [help] Windows widths and heights... (solved for now) - by matty on 01-07-2010 at 04:00 PM
RE: [help] Windows widths and heights... (solved for now) - by whiz on 01-07-2010 at 04:51 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On