Hi everyone. I am trying to generate a certain number of sliders on my CDialog, that certain number is not fixed. I managed to make the sliders appear fine by doing this:

for certain length{
[INDENT]CSliderCtrl *tracker = new CSliderCtrl();
tracker->Create(WS_CHILD | WS_VISIBLE,
CRect(left, top, right, bottom), this, i);[/INDENT]
}

However when I try to get the results of each slider, it only returns the int position of the last slider:

for certain length{
[INDENT]int f = tracker->GetPos();
Change f to fString;
MessageBox(fString);[/INDENT]
}

Is the only around this to use arrays? I tried to set up an array of sliders but it's not working. I don't think I understand what I need to do to program it. Any help is appreciated! Thanks.

>>Is the only around this to use arrays?
Or linked lists -- yes. I would think something like below will work. You will probably want to declare the pointer in the class header file instead of the *.cpp file as shown below so that it doesn't disappear when the function terminates.

CSliderCtrl *tracker = new CSliderCtrl[numControls];
for(int i = 0; i < numControls; i++)
{
       tracker[i].Create(WS_CHILD | WS_VISIBLE,
          CRect(left, top, right, bottom), this, i);
}

Thank you very much!! I never knew you could do that. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.