创建自定义表单设计器
我想在 Delphi 中创建一个自定义的“数据模块”,一个类似 TDataModule 的(可能是继承的)类,它将具有一个基于自定义网格的设计界面(每行一个组件,一些属性作为列)。 这可能吗? 我应该从哪里开始?
我目前使用的是 Delphi 2007。
I'd like to create a custom "datamodule" in Delphi, a TDataModule like (maybe inherited) class which would have a custom grid based design interface (one component per line, some properties as columns). Is this possible? Where should I start?
I'm currently using Delphi 2007.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
完全按照你的描述是不可能的。 您不能将可视化组件(例如网格)放置在数据模块上。 为此,您需要一个表格或框架。
如果我确实尝试像您所描述的那样,我会使用一个列表框来保存各个组件的列表,几个按钮和一个用于从列表中添加和删除组件的选择对话框,以及 TJvInspector 组件从 JVCL 修改属性。 这比尝试制作一个通用的网格来处理这种情况要容易得多。
It's not possible exactly as you describe it. You can't place visual components like a grid on a data module. You need a form or frame for that.
If I were to do try to something like you're describing, I'd use a list box to hold a list of individual components, a couple buttons and a selection dialog box for adding and deleting components from the list, and the TJvInspector component from the JVCL for modifying properties. That would be a lot easier than trying to make a one-size-fits-all grid to handle the situation.
正如 Nick Hodges 在这里指出的那样:
在 Delphi 中的 DataModule 上绘图
它将是很难在 TDataModule 后代上绘制。 也许并非不可能,但肯定不值得这么麻烦。
我会考虑从头开始设计一个全新的 TDataModule,这样您就可以完全控制它。 当然,可能需要做很多工作,但最终会得到回报。
您可以在 Classes.pas 单元中找到 TDataModule 类。 但这只是代码的运行时部分。 其他部分与IDE相关。 例如,对于 BDS 2006,您可以在“c:\Program Files\Borland\BDS\4.0\source\ToolsAPI\”中找到与 ToolsAPI 相关的单元。 您还可以从 TDataModule 派生您自己的数据模块,并将其注册到 RegisterCustomModule (DesignIntf.pas)。 我对这个问题了解不多,也许其他人知道。 正如我所说,做这样的事情并不容易。 但也许有了这些初步信息,您就可以找到您想要的东西。
As Nick Hodges pointer out here:
Drawing on a DataModule in Delphi
it would be difficult to paint on the TDataModule descendant. Not impossible probably, but not worth the trouble for sure.
I would consider designing a completely new TDataModule from scratch, so you would have complete control over it. Sure a lot of work probably, but in the end it would pay off.
You can find TDataModule class in the Classes.pas unit. But this is just the runtime part of the code. Other parts are IDE related. You can find units related to ToolsAPI in "c:\Program Files\Borland\BDS\4.0\source\ToolsAPI\" for BDS 2006 for instance. You can also derive you own data module from TDataModule and register it with RegisterCustomModule (DesignIntf.pas). I don't know much more on this subject, maybe others do. As I said it would not be easy to do something like that. But maybe with this initial information you can find what you want.
也许有可能。 XML 框架设计器的示例可以在页面 New IDE Building 中找到块。 这个例子适用于 Delphi 5,但它可能是一个很好的起点。
Maybe it is possible. An example of a XML Frame Designer can be found on the page New IDE Building Blocks. Well this example is for Delphi 5, but it might be a good starting point.