Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 未绘制自定义FireMonkey组件_User Interface_Paint_C++builder_Firemonkey_C++builder 10.2 Tokyo - Fatal编程技术网

User interface 未绘制自定义FireMonkey组件

User interface 未绘制自定义FireMonkey组件,user-interface,paint,c++builder,firemonkey,c++builder-10.2-tokyo,User Interface,Paint,C++builder,Firemonkey,C++builder 10.2 Tokyo,在C++Builder 10.2 Tokyo中工作,我试图在运行时以编程方式将自定义组件添加到FireMonkeyTForm 自定义组件不是作为包安装的,也不是在IDE中注册的(因为这会使项目变得太复杂),它只是TPanel的一个子类 但是,在运行应用程序时,不会绘制组件及其子组件。我在Windows和Android上对此进行了测试,并尝试了多次修改,比如明确设置宽度和高度 我怎样才能解决这个问题 下面是我代码的相关部分: __fastcall TForm1::TForm1(TComponent

在C++Builder 10.2 Tokyo中工作,我试图在运行时以编程方式将自定义组件添加到FireMonkey
TForm

自定义组件不是作为包安装的,也不是在IDE中注册的(因为这会使项目变得太复杂),它只是
TPanel
的一个子类

但是,在运行应用程序时,不会绘制组件及其子组件。我在Windows和Android上对此进行了测试,并尝试了多次修改,比如明确设置宽度和高度

我怎样才能解决这个问题

下面是我代码的相关部分:

__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm3D(Owner)
{
    mkView = new MKView(this);
    mkView->Align = TAlignLayout::Client;
    mkView->Enabled = true;
    mkView->Visible = true;
    mkView->Parent = this;
}

__fastcall MKView::MKView(TComponent *Owner)
    : TPanel(Owner)
{
    this->OnMouseDown = MKView_OnMouseDown;

    TLabel1 = new TLabel(this);
    TLabel1->Text = "Here I am!";
    TLabel1->Enabled = true;
    TLabel1->Visible = true;
    TLabel1->Parent = this;
    TLabel1->OnMouseDown = MKView_OnMouseDown;
}

TForm3D似乎无法与标准FireMonkey组件配合使用,因为它是为渲染FireMonkey 3D组件而设计的,并使用OnRender()而不是OnPaint()。我在OpenGL环境中使用了TForm3D,但在切换到标准TForm后,现在正在绘制组件。

在运行时动态创建组件与在设计时将其放置在表单上没有区别。当在运行时加载时,存储在DFM中的设计时对象将动态创建,与您所显示的类似(尽管您应该在设置其他属性之前设置父属性)。所以,还有其他东西在阻止你的对象出现。顺便说一句,不要设置
this->OnMouseDown
,而是覆盖虚拟
MouseDown()
方法。