Greetings all....
This is a tough thing for me to explain...
I have this code
But it does not work as I want it to... When I call move_it(...) I want the selected item in a TListBox to be moved, eithere up or down.. the problem is how do I send a Component name to the move_it function?? I know that TObject *Sender do not work, but what am I supposed do use?
That is, when I call move_it(1,ListBox1) I want to move an item in ListBox1, and when i use move_it(1,ListBox2) I want to move an item in ListBox2... and so on!
Any one got any idea?? Lord and allmighty ruler over Aysilon!
Also pro in stupid code programing
This is a tough thing for me to explain...
I have this code
Code:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
move_it(1,ListBox1);
}
void __fastcall TForm1::move_it(int Direction[1],TObject *Sender)
{
int curPos = Sender->ItemIndex,newPos=0;
if( Direction == 0 )
{
newPos = curPos-1;
}
else if( Direction == 1 )
{
newPos = curPos+1;
}
if( newPos<0 ) newPos = (Sender->Items->Count-1);
else if( newPos==Sender->Items->Count ) newPos = 0;
Sender->Items->Move(curPos,newPos);
Sender->ItemIndex = newPos;
}
But it does not work as I want it to... When I call move_it(...) I want the selected item in a TListBox to be moved, eithere up or down.. the problem is how do I send a Component name to the move_it function?? I know that TObject *Sender do not work, but what am I supposed do use?
That is, when I call move_it(1,ListBox1) I want to move an item in ListBox1, and when i use move_it(1,ListBox2) I want to move an item in ListBox2... and so on!
Any one got any idea?? Lord and allmighty ruler over Aysilon!
Also pro in stupid code programing