|
폼에 있는 TEdit는 전부 찾아버리는군요.
연구를 해봐야겠네요..
감사합니다. 즐거운 주말보내세요^^
외랑 님이 쓰신 글 :
: 이렇게 해보시길 권해봅니다. 참고하세요..
: void __fastcall TForm1::Button1Click(TObject *Sender)
: {
: Func->EditPrint(Sender); //함수호출, 버튼 인자를 넘기고
: }
:
: /* 쩡이 님이 테스트 하실려고 한 거겠지요??? 그래서 전 주석처리...
: void __fastcall TFunc::EditPrint(TObject *Sender)
: {
: TButton *pButton= (TButton *) Sender; //호출한 버튼 알아내고
: TForm *pForm = (TForm *) pButton->Parent; //버튼의 부모인 폼을 알아내고
: pForm->Caption= IntToStr(1234);
: }
: */
:
: /// 이 함수를 만들려고 하신 거겠지요??
: void __fastcall TFunc::EditPrint(TObject *Sender)
: {
: TForm *pForm= (TForm*)(((TButton *)Sender)->Parent); //폼알아내기 한줄요약, 에러발생
: //에러내용 : E2034 - Cannot convert 'TWinControl * const' to 'TForm *'
: /// --> 괄호의 묶음을 잘 살펴보세요..
:
: for(int i=0; i<pForm->ComponentCount; i++) // Form에는 컨트롤이 있겠지요? 없으면 말구..
: {
: /// TEdit control이 있는지 찾아봅시다 TEdit *로 cast 가능한 컨트롤이 있나 확인해 보자구요
: TEdit *EditCtl = dynamic_cast<TEdit *>(pForm->Components[i]); // Form이 가진 컴포넌트중..
: if(EditCtl) EditCtl->Text = "Found TEdit"; /// NULL이 아니라 있다면 내용을 바꾸어봅시다
: }
: }
|