问题描述
我已经离开C ++几年来做AS3 / Flex工作。我已经习惯于能够创建一个组件,并把它放在设计模式非常小的困扰,我很难让我的头脑在C ++ Builder的做同样的事情的方式。
过去我已经为C ++ Builder编写了很多组件,但是没有一个是可视的。我现在想做的是为客户搜索创建一个组件,另一个用于订单处理,因为我想要在运行中创建一个新的实例。我不想做的是将每个组件像dbgrid和搜索字段手动放置在代码中。我想这样做(以及设置他们的属性)在设计模式。
如何解决这个问题?我浏览了其他Delphi组件的源代码,我注意到他们有dfm文件,这似乎是我需要的。我如何在C + + B uilder中这样做?我看到的唯一选择是添加一个新的形式,如果我想要一个dfm,但这不是我想要的,因为我的组件将基于TPanel。
有一种方法可以做到这一点,或者我不得不诉诸于在没有视觉引用的代码中做所有?
追求DFM的想法我今天早上做了一个测试,创建了一个基于TPanel的组件,并向其中添加了一个新表单,我在组件的构造函数中创建和父级。在设计模式下,我将表单边框设置为无,并在其上放置网格。这一切看起来确定,直到我把组件放在我的应用程序,在那一点,它看起来像一个标准看起来形式的面板,并且网格缺失。如果我运行应用程序面板显示如预期,无边框和一个网格。由于某些原因,DFM在设计模式中似乎被忽略。
如果你知道一个更好的方法做这件比使用组件,那么请给我一些指针。 >
任何帮助和建议将超越语言。
请查看(查找框架对象)。他们是子形式,你可以直观地设计,然后放在表格上。
I have been away from C++ for a couple of years now doing AS3/Flex work. I have gotten used to being able to create a component and place it in design mode with very little fuss and I am struggling to get my head around the C++ Builder way of doing the same thing.
I have written many components for C++ Builder in the past, but none of them have been visual. What I would like to do now is create a component for customer search and another for order processing because I want to be able to create a new instance of these on the fly. What I don't want to do is have to place each of the components like the dbgrid and search fields manually in code. I would like to do this (as well as set their properties) in design mode.
How do I go about this? I have browsed the source for other Delphi components and I notice they have dfm files which seems to be what I need. How do I do this in C++ Builder? The only option I see is to add a new form if I want a dfm, but this isn't what I want as my components will be based on TPanel.
Is there a way to do this or do I have to resort to doing it all in code with no visual reference?
Pursuing the DFM idea I did a test this morning where I created a component based on TPanel and added a new form to it which I create and parent in the constructor of the component. In design mode I set the form border to none and placed a grid on it. This all looks OK until I place the component in my application, at that point it looks like a panel with a standard looking form in it and the grid is missing. If I run the app the panel shows as expected, borderless and with a grid. The DFM appears to be ignored in design mode for some reason.
If you know a better way to do this than using components then please give me some pointers.
Any help and advice will be appreciated beyond words
You might want to have a look at frames (look for "Frame objects"). They are "subforms" you can design visually and then place on forms.
这篇关于如何在C ++ Builder中可视化地设计组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!