Re: lo/hi word
- Posted by Elliott Sales de Andrade <quantum_analyst at hotmail.com> Jul 01, 2002
- 419 views
Hello Don, I think this problem is caused by the sign bit being in the wrong place. When the number is 32-bits the sign bit is bit number 31. When you take the lower 16 bits Eu doesn't care about the sign bit because it is in the wrong place. There are no such things as shorts, which are 16 bits. So to fix it you will probably need to subtract 32768. the only other way is to mve the sign bit from 15 to 31. It's easier to just subtract 32768. >From: Don Phillips <Graebel at hotmail.com> >Subject: lo/hi word > > >During testing (thus far) I ran across something interesting. One of >the messages I am sending to one of my windows is goofing up. Basically >(the short of it) is that the return value is a *signed* packed 32 bit >value. The lo 16 bits being the X coord and the high 16 bits the Y >coord. > >However every combination (of both Win32Libs and my own) word unpackers >incorrectly return positive values. > >Example (bugus): >PackedPos = SendMessage, {hWnd, WM_GETPOS, Pos, 0} ) >XCoord = lo_word( PackedPos ) >?XCoord > >And where I *should* get (when scrolling or something) >-2, -1, 0, 1, 2 ... > >I get >65534, 65535, 0, 1, 2 ... > >Which means when I draw its about 65k pixels too far to the right... >I am unsure of how to force these 16 bits to signed values besides the >obvious [ Check value if above 32768, if so subtract 65536 ]. >Would like to just peek4s them out if possible. > >Don > > > > _________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com