CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Andrew Truckle Guest

    [RESOLVED] Hexadecimal values

    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


  2. #2
    Join Date
    May 1999
    Location
    Croatia, Europe
    Posts
    7

    Re: Hexadecimal values

    You get bit by flags&(1<<(bit)), set bit by flags|=1<<(bit); and clear bit by flags&=~(1<<(bit));


    - Goran.

  3. #3
    Join Date
    May 1999
    Location
    Sydney, Australia
    Posts
    420

    Re: Hexadecimal values


    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured