Control ID's

This is a discussion on Control ID's within the Windows Programming forums, part of the Platform Specific Boards category; Hey, I'm trying to go check the state of over 100 check boxes. They all are named IDC_CHECK1 - IDC_CHECK121. ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    112

    Control ID's

    Hey, I'm trying to go check the state of over 100 check boxes. They all are named IDC_CHECK1 - IDC_CHECK121. Is there a way I can do this in a for loop, since checking each one would really suck.

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    if the ids are defined sequentially I don't see why not. Find out where they are defined. most likely resource.h. and see if you can't make sure they are numbered in such a way as to referenced in a for loop. Oh and by the way, that's a lot of freakin' check boxes!
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Ensure your control id's are consecutive numbers (or at least regularly spaced).

    eg
    Code:
    #define IDC_CNTRL01 100
    #define IDC_CNTRL02 101
    #define IDC_CNTRL03 102
    better still, use an enum to set the id constants:

    Code:
    enum {IDC_CNTRL01=100,IDC_CNTRL02,IDC_CNTRL03};
    And then:
    Code:
    int i;
    for (i=IDC_CNTRL01;i<IDC_CNTRL03;++i)
      {
      //do stuff
      }
    edit: ...and FillYourBrain was way ahead of me here...but I do like to make it pretty
    Last edited by Ken Fitlike; 09-07-2002 at 09:57 PM.

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    112
    oh, ok. So in your sample code i can refer to the checkboxes with i, right?

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    yes - the id's of the checkboxes are available through 'i'.

    BTW, ditto on that's a hell of a lot of checkboxes; perhaps looking at some other method to achieve your goal may be an idea.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    112
    lol, don't worry its just for some retarded game i started cause i was bored. Just to see how many check boxes you can click in 10 seconds.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. (Multiline) Edit Control Limit
    By P4R4N01D in forum Windows Programming
    Replies: 9
    Last Post: 05-17-2008, 12:56 PM
  2. Setting Control IDs
    By Nurfina in forum Windows Programming
    Replies: 8
    Last Post: 04-14-2007, 07:09 PM
  3. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  4. A pop up window with controls, unknown control IDs
    By earth_angel in forum Windows Programming
    Replies: 5
    Last Post: 08-19-2005, 08:57 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM

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