一.8 g- `: ~, g; g& f5 K AnsiString nameString("TButton");& M( A) m7 o# A; S0 B TButton * button; for(int i=0; i < ComponentCount; i++), @, a/ m; H' L {* b* d1 R$ _( N //Check to see if the component is a TButton if (Components->ClassNameIs(nameString))5 d7 ]5 Z0 T+ L3 G- M* @( V1 Z% x {# f$ ~6 a6 Y3 e6 Y: @" | //cast the component to a TButton *. n3 T& Y6 Q5 i/ S" a- {$ s button = (TButton *)Components;- V7 W! ?! s S" E button->Font->Name = "Courier"; ......
二.8 U- t X1 B7 ]% t 我想动态创建和静态创建都没有太大区别,只要它属于你的MainForm。( new TButton(this) ).4 ~" Z$ d: y, C f 用一个需循环4 U! g& j& R$ V4 t+ [ TButton* button;: x' c5 J6 v p. P for(int i=0;i<MainForm->ComponentCount;i++){ if((button= dynamic_cast<TButton*>(MainForm->Components)) != NULL ) button->Caption="Button";4 q8 \* j: p' N m% z5 R& P }. C/ n2 p* s: q- h
| 欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |