在 运行 时间将创建的框架放置在面板中

Place the created frame in the panel in the run time

我知道如何在设计时创建框架并在 Delphi 的运行时将其放置在面板中。至于C++ Builder,由于我不熟悉C++脚本,所以看起来很难。请指教正确的做法?

提前致谢

解决方案与Delphi中的解决方案完全相同,您只需要改用C++语法即可。

像这样的东西应该可以工作:

/*
Assuming your frame is located in a unit called Frame1, and it's 
called TMyFrameType, this is what you should add your Form unit
cpp file.
*/

#include "Frame1.h"

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
  // This assumes you have a panel in this form called "ThePanelWhereIWantIt".
  // You could move the MyFrameInstance to the class definition, if you need to 
  // access it somewhere after in your form code, but this is trivial.
  TMyFrameType *MyFrameInstance;  
  MyFrameInstance         = new TMyFrameType(ThePanelWhereIWantIt);
  MyFrameInstance->Parent = ThePanelWhereIWantIt;
  MyFrameInstance->Align  = alClient;
}
//---------------------------------------------------------------------------