如何控制另一靜態Form中的動態產生物件的屬性? |
答題得分者是:taishyang
|
khaupe
一般會員 ![]() ![]() 發表:28 回覆:25 積分:15 註冊:2003-06-30 發送簡訊給我 |
|
taishyang
站務副站長 ![]() ![]() ![]() ![]() ![]() ![]() 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
khaupe您好:
引言:我知道如何在Form2中改變edt的property{((TLabel*)Sender)->Color = 0x000080FF;}這句話有點怪怪的,是edt還是lbl 若是lbl的話可以參考下面的code //.h --Form2 class TForm2 : public TForm { __published: // IDE-managed Components TButton *Button1; void __fastcall FormShow(TObject *Sender); private: // User declarations public: // User declarations TLabel *lbl; __fastcall TForm2(TComponent* Owner); }; //.cpp--Fomr2 void __fastcall TForm2::FormShow(TObject *Sender) { lbl=new TLabel(this); lbl->Parent=Form2; lbl->Top=50; lbl->Left=50; lbl->Caption="I'm Here"; } //--------------------------------------------------------------------------- //.cpp--Form1 //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { Form2->lbl->Color = 0x000080FF; } //---------------------------------------------------------------------------順心 |
khaupe
一般會員 ![]() ![]() 發表:28 回覆:25 積分:15 註冊:2003-06-30 發送簡訊給我 |
引言: khaupe您好:引言:我知道如何在Form2中改變edt的property{((TLabel*)Sender)->Color = 0x000080FF;}這句話有點怪怪的,是edt還是lbl 若是lbl的話可以參考下面的code//.h --Form2 class TForm2 : public TForm { __published: // IDE-managed Components TButton *Button1; void __fastcall FormShow(TObject *Sender); private: // User declarations public: // User declarations TLabel *lbl; __fastcall TForm2(TComponent* Owner); }; //.cpp--Fomr2 void __fastcall TForm2::FormShow(TObject *Sender) { lbl=new TLabel(this); lbl->Parent=Form2; lbl->Top=50; lbl->Left=50; lbl->Caption="I'm Here"; } //--------------------------------------------------------------------------- //.cpp--Form1 //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { Form2->lbl->Color = 0x000080FF; } //---------------------------------------------------------------------------順心 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |