From: Robby on
Hello,

I would like to ask, what is the data type of wParam when used in the
following fragment:

other code.........

case WM_MOUSEWHEEL:
if (iDeltaPerLine == 0)
break;

iAccumDelta += (short) HIWORD (wParam);

other code .......

Is it of unsigned long integer >>> 0 - 4,294,967,295 ?

Anyone please!

--
Best regards
Robert
From: Robby on
Hi,

My question would of eventually lead up to how can the HIWORD of wParam =
-120.

I believe that I figured out why. If I may post my solouion to make sure
that this is correct.

An signed Short = 0 - 32767 = 01111111 11111111

the msb of a short = the sign flag, if it is 0 then value is positive, if 1
then all bits are reversed and 1 is added to the value.

So when I run the program and I turn the mouse whell, wParam contains:
4287102976 which is equal to 11111111100010000000000000000000.

The HIWORD of this 32 bit value is obtained by shifting 16 bits to the right
and we get the following value: 00000000000000001111111110001000

When you type cast it to a short the msb signs this value as a negative and
we get the following value:

(0000000001110111) + 1

Thereby making this value negative and equaling to: -120

If there is any error in the way I have comprehended this please someone
advise me.

Thankyou.

--
Best regards
Robert


"Robby" wrote:

> Hello,
>
> I would like to ask, what is the data type of wParam when used in the
> following fragment:
>
> other code.........
>
> case WM_MOUSEWHEEL:
> if (iDeltaPerLine == 0)
> break;
>
> iAccumDelta += (short) HIWORD (wParam);
>
> other code .......
>
> Is it of unsigned long integer >>> 0 - 4,294,967,295 ?
>
> Anyone please!
>
> --
> Best regards
> Robert
From: David Webber on

"Robby" <Robby(a)discussions.microsoft.com> wrote in message
news:8B3B0BE3-B32A-43B4-9642-E3C3B6EAE43A(a)microsoft.com...

> Hi,
>
> My question would of eventually lead up to how can the HIWORD of wParam =
> -120.

You're essentially right, but it doesn't look like the simplest way of
saying it!

First it is easier to think in hexadecimal where each digit represents
exactly four binary digits (and which is easy to use in C++). You have

wParam = 0xff880000;

If you write

WORD w = HIWORD(wParam);

then w = 0xff88;

Think of signed integers as being cyclic, with (-1) always being the number
with all bits set.

So

BYTE(-1) is 0xff
WORD(-1) is 0xffff
UINT(-1) is 0xffffffff

and so on. So WORD(-120) is 0xffff - 119 = 0xffff-0x0077 = 0xff88

[IMPORTANT: the representation of negative integers depends on the size of
the integer, and you have to be careful. WORD(BYTE(-1)) will be be 0x00ff
and not the same as WORD(-1) whereas WORD(BYTE(1)) and WORD(1) are the
same.]

Dave

--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm



From: Robby on
Thanks David I appreciate your conclusive feedback!

--
Best regards
Robert


"David Webber" wrote:

>
> "Robby" <Robby(a)discussions.microsoft.com> wrote in message
> news:8B3B0BE3-B32A-43B4-9642-E3C3B6EAE43A(a)microsoft.com...
>
> > Hi,
> >
> > My question would of eventually lead up to how can the HIWORD of wParam =
> > -120.
>
> You're essentially right, but it doesn't look like the simplest way of
> saying it!
>
> First it is easier to think in hexadecimal where each digit represents
> exactly four binary digits (and which is easy to use in C++). You have
>
> wParam = 0xff880000;
>
> If you write
>
> WORD w = HIWORD(wParam);
>
> then w = 0xff88;
>
> Think of signed integers as being cyclic, with (-1) always being the number
> with all bits set.
>
> So
>
> BYTE(-1) is 0xff
> WORD(-1) is 0xffff
> UINT(-1) is 0xffffffff
>
> and so on. So WORD(-120) is 0xffff - 119 = 0xffff-0x0077 = 0xff88
>
> [IMPORTANT: the representation of negative integers depends on the size of
> the integer, and you have to be careful. WORD(BYTE(-1)) will be be 0x00ff
> and not the same as WORD(-1) whereas WORD(BYTE(1)) and WORD(1) are the
> same.]
>
> Dave
>
> --
> David Webber
> Author MOZART the music processor for Windows -
> http://www.mozart.co.uk
> For discussion/support see
> http://www.mozart.co.uk/mzusers/mailinglist.htm
>
>
>
>
 | 
Pages: 1
Prev: GetFileVersionInfo example
Next: LVM_SETVIEW