重载TForm的虚拟函数CreateParams。
class TForm1 : public TForm
{
__published: // IDE-managed Components
TListBox *ListBox1;
private: // User declarations
protected:
void __fastcall CreateParams(TCreateParams&);//在头文件添加
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
void __fastcall TForm1::CreateParams(TCreateParams& Params)//在.cpp添加
{
TForm::CreateParams(Params);
Params.WndParent = NULL;
}
步骤:
1,在使用该功能的子窗体的头文件中添加:
protected:
void __fastcall CreateParams(TCreateParams&);
声明该函数;
2,在子窗体代码里添加函数代码:
void __fastcall TForm1::CreateParams(TCreateParams& Params)
{
TForm::CreateParams(Params);
Params.WndParent = NULL;
}