Forcing bits
-
What bitwise operator/combination would I use to force a bit...??? Would the following yield the result im looking for..?
1 & 0 = 1
1 & 1 = 1Basically I wanna ensure the WS_VISIBLE bit is always set. dwStyle & WS_VISIBLE would accomplish this yes...??? Thanx "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
-
What bitwise operator/combination would I use to force a bit...??? Would the following yield the result im looking for..?
1 & 0 = 1
1 & 1 = 1Basically I wanna ensure the WS_VISIBLE bit is always set. dwStyle & WS_VISIBLE would accomplish this yes...??? Thanx "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
dwStyle |= WS_VISIBLE;
/ravi Let's put "civil" back into "civilization" http://www.ravib.com ravib@ravib.com
-
What bitwise operator/combination would I use to force a bit...??? Would the following yield the result im looking for..?
1 & 0 = 1
1 & 1 = 1Basically I wanna ensure the WS_VISIBLE bit is always set. dwStyle & WS_VISIBLE would accomplish this yes...??? Thanx "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
I believe that you use the (dwStyle & WS_VISIBLE) to test if WS_VISIBLE bit is set in dwStyle, which might help you with what you want. However a better way to do this is to use the OR operator ( it's the | : shift+\) the OR operation results in true if any of the arguments was true and false if none were true. ie 1 or 1 = 1 1 or 0 = 1 0 or 1 = 1 0 or 0 = 0 while the AND (&) is only true if both arguments were true. Since WS_VISIBLE is always true, the | operator with dwStyle and WS_VISIBLE will always force the bit you are interested in to true. The usage should be along the lines of: dwStyle= dwStyle | WS_VISIBLE; This will make sure that the flag bit is forced to true while the rest of the bits are unmodified (since WS_VISIBLE has only one bit turned to true). exp: dwStyle 1001110101110111 WS_VISIBLE 0000000010000000 Binary OR (|) 1001110111110111 this is called the Binary OR since it compares bits and results in bits, & is Binary AND too. && and || are the logical operators and compare the arguments bit by bit by return only true or false. Please correct me if I'm wrong, it's been quite a while :) ... -- Young Basic programmers never die... they just GOSUB and never RETURN.
-
dwStyle |= WS_VISIBLE;
/ravi Let's put "civil" back into "civilization" http://www.ravib.com ravib@ravib.com
Thanx "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
-
I believe that you use the (dwStyle & WS_VISIBLE) to test if WS_VISIBLE bit is set in dwStyle, which might help you with what you want. However a better way to do this is to use the OR operator ( it's the | : shift+\) the OR operation results in true if any of the arguments was true and false if none were true. ie 1 or 1 = 1 1 or 0 = 1 0 or 1 = 1 0 or 0 = 0 while the AND (&) is only true if both arguments were true. Since WS_VISIBLE is always true, the | operator with dwStyle and WS_VISIBLE will always force the bit you are interested in to true. The usage should be along the lines of: dwStyle= dwStyle | WS_VISIBLE; This will make sure that the flag bit is forced to true while the rest of the bits are unmodified (since WS_VISIBLE has only one bit turned to true). exp: dwStyle 1001110101110111 WS_VISIBLE 0000000010000000 Binary OR (|) 1001110111110111 this is called the Binary OR since it compares bits and results in bits, & is Binary AND too. && and || are the logical operators and compare the arguments bit by bit by return only true or false. Please correct me if I'm wrong, it's been quite a while :) ... -- Young Basic programmers never die... they just GOSUB and never RETURN.
Thanx "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
-
What bitwise operator/combination would I use to force a bit...??? Would the following yield the result im looking for..?
1 & 0 = 1
1 & 1 = 1Basically I wanna ensure the WS_VISIBLE bit is always set. dwStyle & WS_VISIBLE would accomplish this yes...??? Thanx "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
http://www.codeproject.com/cpp/bitbashing.asp
CPUA 0x5041 Sonork 100.11743 Chicken Little "So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies Within you lies the power for good - Use it!