[问题] Control has no parent window

楼主: noodleT (面T)   2015-04-10 21:34:01
使用 BCB 制作元件 TMyOpengl 时,继承 TPanel
想在使用者建立元件时取得自己的 Handel
于是在
__fastcall TMyOpengl::TMyOpengl(TComponent* Owner){
hDC = GetDC(this->Handle);
}
到目前为止都可以编译、安装元件
但使用者拖曳元件至 Form 时就会跳出


请问有没有解决的方法?
不然就要使用者自己输入指令再去做设定(这样有点不完美)
作者: TobyH4cker (Toby (我要当好人))   2015-04-13 01:33:00
写在constructor的程式码是在design time就会执行试试放 this->Caption = "FOO"; 再拉到form上就知因此你还是写个public function Initialize()在里面做你想做的事吧!

Links booklink

Contact Us: admin [ a t ] ucptt.com