How to use one event handler for multiple radio buttons

Hello.. To begin I have this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
.
..
...
typedef struct
{
   CHAR runes[6];
}Runes;

Runes list[] =
{
   TEXT{"El"},
   TEXT{"Eld"},
   TEXT{"Tir"},
   TEXT{"Nef"},
   TEXT{"Eth"},
   .
   ..
   ...
   etc.
}


..and the list is big enough I will not continue and get to the point.. Now I do want to make a Group of Radio Buttons that work together setting the WS_GROUP, (but) instead of writing tons of lines like this:

1
2
3
4
5
6
7
8
9
..
...
   r1 = CreateWindowA("button", ...);
   r2 = CreateWindowA("button", ...);
   r3...
   r4.....
   ....
   ....
   r33


I want to create a function that uses only one time the Macro to create a window, and use maybe a loop which uses the names from the struct above for all 33 buttons. Otherwise this is a pain to write 33 times same thing even if I copy and paste, I just don't like the idea of having 33 same lines and occupy the space for no reason. Anyone could help in this problem ?
Thanks..
Last edited on
The variables r1...r33 should also be an array or a vector. Then you should be able to use a loop.
All the parameters of the CreateWindow() call are, as you know, 'variables'. I do for loops all the time for multiple controls. The operable term is 'Control Arrays'. Do you need an example?
The key parameter of the CreateWindow() call in the situation you are describing is the HMENU parameter.

#define RADIO_BUTTON 1500
...
...
for...
RADIO_BUTTON + i


Ahh Okay I understand now.. Okay okay.. thanks freddie1 :)
Topic archived. No new replies allowed.