something with enum

This is a discussion on something with enum within the C Programming forums, part of the General Programming Boards category; ok part of this is win32 but the main part is C so i thought i would post here. here ...

  1. #1
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214

    something with enum

    ok part of this is win32 but the main part is C so i thought i would post here.
    here is my prob i have these global

    Code:
    enum Topic {RED , GREEN , BLUE , YELLOW , PINK , PURPLE};
    enum Topic Color;
    then further down in the program i have this

    Code:
    RED = SendMessage(hwndOptRed , BM_GETCHECK , 0 , 0);
    it should either get 1 or 0 from that but i am getting an error

    error C2106: '=' : left operand must be l-value

    im using VC++6

    thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,824
    Try
    Code:
    Color = SendMessage(hwndOptRed , BM_GETCHECK , 0 , 0);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    thanks, it worked but one thing
    if i do that say each time it will go up by 1 wont it, say if i do the next line

    Code:
    Color = SendMessage(hwndOptGreen , BM_GETCHECK , 0 , 0);
    will that store the value in GREEN?
    Last edited by Rare177; 10-02-2004 at 06:15 AM. Reason: upcase green

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,824
    I don't see what an enum is doing for you here.
    You could equally say
    Code:
    int foo;
    foo = SendMessage(hwndOptRed , BM_GETCHECK , 0 , 0);
    foo = SendMessage(hwndOptGreen , BM_GETCHECK , 0 , 0);
    What an enum adds is the ability to do this
    Code:
    Color = SendMessage(hwndOptGreen , BM_GETCHECK , 0 , 0);
    if ( Color == GREEN ) {
        // do stuff
    }
    But whether that makes any sense or not depends on your use SendMessage().
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I don't think you are properly understanding what an enumeration is. Its actually just a constrained data type. In other words it would be like having an int that only applies to numbers 0 - 5 in this instance. There is nothing magical as to how you process an enumeration, its just the same as any other base type. The main difference is that it is suppose to have a predictable range. Obviously when using enumerations, care must be taken so as to not get an out of range value.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A basic question on enum
    By MasterM in forum C++ Programming
    Replies: 2
    Last Post: 06-12-2009, 10:16 PM
  2. enum switchcase and windows message q
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 11-27-2006, 01:16 PM
  3. Conflicting enum issue
    By 7force in forum C Programming
    Replies: 1
    Last Post: 07-05-2006, 04:51 AM
  4. Switch case and enum help
    By SomeCrazyGuy in forum C++ Programming
    Replies: 9
    Last Post: 04-21-2005, 09:53 PM
  5. enum
    By JerryL in forum C++ Programming
    Replies: 5
    Last Post: 02-25-2004, 05:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21