Page 1 of 1

Posted: Thu Feb 07, 2002 5:05 pm
by BackupUser
Restored from previous forum. Originally posted by webmatze.

How do I get the Low-order word or the High-order word of wParam / lParam used by the Window Callback Procedure?
Is this possible with PureBAsic?

In C++ I can use

Code: Select all

width = LOWORD(lParam)
to get the new width of a window after a #WM_SIZE event.

matze

Registered Purebasic User.
Using Windows XP on an AMD System...

Posted: Thu Feb 07, 2002 5:25 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.

Hi,

Code: Select all

HighWordlParam.w = lParam >> 16
LowWordlParam.w = PeekW(@lParam)
Bye,

El_Choni

Posted: Thu Feb 07, 2002 5:34 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
HighWordlParam.w = lParam >> 16
LowWordlParam.w = PeekW(@lParam)
As a procedure it would be:

Code: Select all

Procedure HiWord(Var)
  ProcedureReturn Var >> 16
EndProcedure
 
Procedure LoWord(Var)
  ProcedureReturn PeekW(@Var)
EndProcedure
So you can use it like:


width = LoWord(lParam)


Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.

Edited by - franco on 07 February 2002 17:36:43

Posted: Thu Feb 07, 2002 5:41 pm
by BackupUser
Restored from previous forum. Originally posted by webmatze.

Thanks!

This helps me a lot!

Registered Purebasic User.
Using Windows XP on an AMD System...

Posted: Thu Feb 07, 2002 8:37 pm
by BackupUser
Restored from previous forum. Originally posted by michaelj.

Okay, I gotta respond to this ;o)

You should try to be consistent at least. One way or the other. Here's both ways, with both values:

Code: Select all

; Simple bitwise test.

var.l = 4293844428

lo1 = var & 65535
hi1 = var >> 16

lo2 = PeekW(@var)
hi2 = PeekW(@var+2)

MessageRequester("Number test - Original = "+Hex(var), "hi="+Hex(hi1)+", lo1="+Hex(lo1)+", hi2="+Hex(hi2)+", lo2="+Hex(lo2), 0)
End
There seems to be a bug with Hex() in that, no matter how I run it, lo2 & hi2 will always display a full long value. lo1 and hi1 work as expected *UNLESS* I specify them with type (ie, lo1.w, hi1.w) in which case they exhibit the same behaviour. That's one for Fred I think !

(And we could really do with line continuation ability !!)

Hope this helps.


Michael.
(Registered PureBasic user)

Edited by - michaelj on 07 February 2002 20:38:52

Posted: Thu Feb 07, 2002 10:47 pm
by BackupUser
Restored from previous forum. Originally posted by fred.

Bitwise usually done with hex numbers:

loword.l = value & $FFFF ; (Only the 16 first bits)

Fred - AlphaSND

Posted: Fri Feb 08, 2002 8:14 pm
by BackupUser
Restored from previous forum. Originally posted by michaelj.
Bitwise usually done with hex numbers:

loword.l = value & $FFFF ; (Only the 16 first bits)

Fred - AlphaSND
Hi Fred,

I wasn't sure how to specify hex numbers, so thanks for passing that on (I almost put 0xffff ;0).

Surely though, whatever happens, a word should never return more than 65535 ? It seems that somehow, variable values can change size depending on how they're processed ?????

Regards,

Michael.
(Registered PureBasic user)