Board index » cppbuilder » OnChange Event - Array of TTrackBar

OnChange Event - Array of TTrackBar


2007-04-27 06:46:27 PM
cppbuilder26
Hello,
I have an array of TTrackBars and I try to define the OnChange event for
each TTrackBar.
Unfortunately, I always get 0, if I ask for the Position of the TTrackBar in
the myOnChange function.
Here is my corresponding Code. Can anybody tell me, what I'm doing wrong?
Thanks a lot, and Kind Regards, Marbod.
TTrackBar *TrackBar[10];
for (int i = 0; i < 10; i++)
{
TrackBar[i] = new TTrackBar(ScrollBox);
TrackBar[i]->Parent = ScrollBox;
TrackBar[i]->OnChange = myOnChange;
}
void __fastcall TMyForm::myOnChange(TObject *Sender)
{
Label3->Caption = TrackBar(Sender)->Position;
}
 
 

Re:OnChange Event - Array of TTrackBar

"Marbod Hopfner" < XXXX@XXXXX.COM >wrote in message
Quote
Label3->Caption = TrackBar(Sender)->Position;
That is not a proper type cast. It should be like this instead:
Label3->Caption = ((TTrackBar*)Sender)->Position;
Or this:
Label3->Caption = static_cast<TTrackBar*>(Sender)->Position;
Gambit
 

Re:OnChange Event - Array of TTrackBar

thanks a lot, each solution works fine :-) !
Kind Regards, Marbod.
 

{smallsort}