When a group of values have been or'd together, how do you retrieve the original values. This is the case with GetMenuState. It returns a mask of or'd constants and I need to test for only one. I would appreciate just a hint in the right direction instead of telling exactly how. I think you would have to NOR the values out of it but i can't figure out how.
Posted on 2002-03-26 10:13:09 by rdaneel
Just a hint, eh?
Well, the solution is in your question "I need to TEST for one"

Posted on 2002-03-26 10:28:15 by eGo
The problem with any logic is that it is destructive, in the case of an XOR, you can retrieve the original if you have the result and the modifier (similar is true for addition & subtraction), but OR is completely destructive.

???? or 1111 = 1111, no matter what the state of each individual ? was to start with.

What eGo is suggesting is that the constants all occupy individual bits, so there is no overlap and hence no overwriting of data.

If you check the constants you will probably find they all occupy only 1 bit (1h, 2h, 4h, 8h, 10h, 20h, 40h, etc.).
Perform a logical and (which is what test does), with the constant you are checking for, and the zero flag will be set if it is not there.

Posted on 2002-03-26 10:53:40 by Mirno