Click to See Complete Forum and Search --> : Hexadecimal values


Andrew Truckle
May 16th, 1999, 09:23 AM
I want to use DWORD variable to contain several flags instead of having several seperate bool variables. Can someone tell me what the hex values are to use for each bit in the DWORD variable?

Perhaps a short example?

Cheers

Goran Mitrovic
May 16th, 1999, 06:21 PM
You get bit by flags&(1<<(bit)), set bit by flags|=1<<(bit); and clear bit by flags&=~(1<<(bit));


- Goran.

sally
May 17th, 1999, 04:12 AM
const DWORD option1 = 0x0000001;
const DWORD option2 = 0x0000002;
const DWORD option3 = 0x0000004;
const DWORD option4 = 0x0000008;
const DWORD option5 = 0x0000010;
const DWORD option6 = 0x0000020;
const DWORD option7 = 0x0000040;
const DWORD option8 = 0x0000080;
// etc

class CSomeClass
{
DWORD m_option;
};

bool CSomeClass::SomeFunction( const DWORD p_testOptions )
{
return ( m_option & p_testOptions ) ? true : false;
}




Sally

Sally
May 17th, 1999, 04:12 AM
const DWORD option1 = 0x0000001;
const DWORD option2 = 0x0000002;
const DWORD option3 = 0x0000004;
const DWORD option4 = 0x0000008;
const DWORD option5 = 0x0000010;
const DWORD option6 = 0x0000020;
const DWORD option7 = 0x0000040;
const DWORD option8 = 0x0000080;
// etc

class CSomeClass
{
DWORD m_option;
};

bool CSomeClass::SomeFunction( const DWORD p_testOptions )
{
return ( m_option & p_testOptions ) ? true : false;
}




Sally