Results 1 to 5 of 5

Thread: A question about bit masks

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Location
    Oregon
    Posts
    64

    A question about bit masks

    What I'm ultimately attempting to do is determine if a box is checked in an a tree view. I was using something to the effect of
    Code:
    if (tvi.state == INDEXTOSTATEIMAGEMASK(2))
    But that doesn't work if it has any other properties, like children items because it has flags determining weather it's expanded and so on. So how can I just compare "bits 12-15" as that's what MSDN says determines the state image.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Try
    Code:
    if ((tvi.state & INDEXTOSTATEIMAGEMASK(2))== INDEXTOSTATEIMAGEMASK(2))
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    And a value with a known bitmask: it sets bits on only if the bits are both 1's in both operands. You should end up with the result equalling the original bit mask -

    Just like crtptctctc..etc showed you. If I had a name like that I think I'd like 'Joe' better - it's easier to spell.

    If you code in C or C++ you have to know about &, |, ^, <<, >>
    and exactly what they do.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Why is crptcblade hard to spell?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Location
    Oregon
    Posts
    64
    Crtpcblade, thanks that worked perfectly

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