如何在 C++ Builder 中直观地设计组件?

How can I visually design a component in C++ Builder?(如何在 C++ Builder 中直观地设计组件?)

本文介绍了如何在 C++ Builder 中直观地设计组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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 中直观地设计组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何在 C++ Builder 中直观地设计组件?

基础教程推荐