0

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.

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by roachic
0

>>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);
}
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.