|
결혼 포인터로 넘기면 됩니다.
------------------------------------------------------
void __fastcall TForm2::ObjectSend(TObject *Obj);
void __fastcall TForm2::ObjectSend(TControl *Obj);
void __fastcall TForm2::ObjectSend(TTreeView *tree);
void __fastcall TForm2::ObjectSend(TTreeNode *node);
TControl은 TObject 상속을 받았고
빌더에 있는 컨트롤들은 모두 TControl 상속 받았습니다.
또 빌더의 WindowControl들은 TWinControl 을 상속받았구요
만약에 다양한 컨드롤들 넘기고 싶다면 상위 클래스로 변환해 넘기면 됩니다.
void __fastcall TForm2::Button1Click(TObject *Sender)
{
ObjectSend((TControl*)treeview,1);
.....
ObjectSend((TControl*)treenode,2);
}
void __fastcall TForm2::ObjectSend(TControl *control, int ctrlType)
{
if(ctrlType==1)
{
TTreeView *tree=(TTreeView *)control;
//...
}
else if(ctrlType==2)
{
TTreeNode *Node=(TTreeNode *)control;
}
....
}
박상일 님이 쓰신 글 :
: radiogroup, label, Button 등의 컴포넌트를 인자로 넘길수 있는 방법좀 가르쳐 주세요
: 예로
: void __fastcall TForm2::ObjectSend(????? *Obj)
: {
: int i;
: String Str;
: i = Obj->ItemIndex;
: Str = Obj->Caption;
: }
:
: 이런식으로 해서 함수 호출할때는
: ObjectSend(RadioGroup1);
: ObjectSend(Label1);
: ObjectSend(Button1);
: 모두 가능하도록 하는 ?????는 없을까요??
|