是否可以在设计时直观地设计自定义组件?
我正在尝试用 Delphi 制作自己的组件。我在开始组件开发时遇到困难。
我想制作一个复合控件,即由几个其他控件组成的控件,例如地址表单或类似的东西。
我从 TWinControl 下降。这会被认为是正确的选择吗?
最主要的是,我看不到在 D2010 中以可视化方式设计组件的方法。这可能吗?例如,将一些文本框拖放到您的组件上,就像使用表单一样。我希望我不必将所有视觉方面的代码手动编码到我自己的组件中。
此外,delphi 组件开发上的任何好的链接都将非常感激 - 特别是复合控件。这些文档不是 A1,这是一场斗争。我已经搜索了很多,但我仍然一事无成。
I am venturing into making my own components in Delphi. I'm having difficulty getting started with component development.
I want to make a composite control ie a control made up of several other controls, eg like an address form or something like that.
I am descending from TWinControl. Would that be considered to be the correct choice?
The main thing is, I cannot see a way to visually design the component in D2010. Is this possible? eg drop some text boxes onto your component, as you would with a form. I'm hoping I don't have to hand code all the visual aspects to my own components..
Also any good links on delphi component dev would be very much appreciated - esp for composite controls. The docs are not A1, its a struggle. I searched a lot already, I'm still going nowhere fast.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您正在制作具有多个控件的内容(例如地址表单),您可能会考虑将其制作为框架而不是控件。框架可以像窗户一样设计并重复使用。
If you're making something with multiple controls such as an address form, you might consider making it a frame instead of a control. Frames can be designed like windows, and re-used.
您必须在代码中描述它才能编译,但是您可以首先使用一种技巧以可视方式设计组件。
在窗体上放置一个 TPanel,并让它代表基本控件。排列子控件,然后从文本视图获取属性。 GExperts 添加了一个菜单选项,可以将表单上的控件转换为代码以自动生成它们,使这一步变得更加容易。
You'll have to describe it in code to compile, but you can use a trick to design the component visually at first.
Put a TPanel on the form, and let that stand for the base control. Arrange your sub-controls, then get the properties from text view. GExperts adds a menu option that will convert controls on a form to code to generate them automatically, making this step a lot easier.
阅读我的博客文章 使用框架作为视觉组件 - 不要忘记你的弹簧。
这非常简单:将所有内容放在框架上,将其注册为组件,注册分支,并且不要忘记在设计时“Visible=False”被忽略。
我昨天刚刚在 DelphiLive! 的会前研讨会上解释了这一点。会议 :-)
--jeroen
Read my bog article on using Frames as Visual Components - don't forget your spring.
It is very easy: put everything on your Frame, register it as a component, register the sprig, and don't forget that at design time 'Visible=False' is being ignored.
I just explained this yesterday during my preconference workshop at the DelphiLive! conference :-)
--jeroen