Hexidecimal Stuff

Archives Forums/Win32 Discussion/Hexidecimal Stuff

Picklesworth(Posted 2005) [#1]
I need help with hexidecimals to change window style constants in Win32.

I know that Or is used to add two hex numbers together, and I think I know that Xor adds a hex onto another hex, but only if it is not already present on it...

What I am wondering, is if there is an easy way (note: I don't know the way at all) to figure out the different hex numbers that are combined into one... or something.
What I want is to assign the ES_READONLY constant onto a gadget's style constant thing, but only sometimes. I want to be able to remove it from that gaget's GWL_STYLE long whenever I want, and add it back on whenever I want... Xor and Or don't seem to provide this functionality.



Since that made no sense at all, please just tell me about modifying Hexidecimal numbers. If it's complicated, please tell me that instead to save our time because I could also do a very stupid solution which does what I want.


Snarkbait(Posted 2005) [#2]
use AND.

i.e.

say you have FF00A and you want to get rid of the A

FF00A AND FF000 = FF000

p.s. it's hexadecimal ;)

p.p.s. if you want to play around with hex\binary numbers, the windows calculator set to scientific mode is a wonderful thing.


Picklesworth(Posted 2005) [#3]
So I guess this works then?:
If mainHex And otherHex = otherHex
  mainHex = mainHex Xor otherHex
Else
  mainHex = mainHex Or otherHex
EndIf


Oh, and you don't need to tell me about the EM_SetReadOnly message, because I just discovered it.


Yan(Posted 2005) [#4]
I think you really need to read up on base16 and boolean operations. :o)

In the mean time...

To set a particular flag...
allFlags = allFlags OR wantedFlag
To clear a particular flag...
allFlags = allFlags AND ~wantedFlag
If you know that flag is already set, you can use XOR to clear it. If it isn't already set however, this will set it instead.
allFlags = allFlags XOR wantedFlag


[edit]
If you are using BMax, the bitwise operators are different :
AND = &
OR = |
XOR = ~
[edit]


Picklesworth(Posted 2005) [#5]
Great! Thanks.
What, exactly, does the ~ thing do?


Yan(Posted 2005) [#6]
The '~' inverts all the bits of the flag (bitwise complement).


AntonyWells(Posted 2005) [#7]
In bmax the | operator seems to be the correct way of combining them.

I.e


test( Lighting | ZBuffer | Chrome )

function test(Flags )
end function

instead of OR.

-edit - err, as someone already pointed out. Can I get a post delation, stat?


Picklesworth(Posted 2005) [#8]

Antony (Posted 2005-06-29 16:26:09)
In bmax the | operator seems to be the correct way of combining them.

I.e


test( Lighting | ZBuffer | Chrome )

function test(Flags )
end function

instead of OR.

-edit - err, as someone already pointed out. Can I get a post delation, stat?


Too late.
:D