将自定义控件添加到另一个自定义控件
我想要完成的是创建新的触摸键盘。
首先,我创建了从速度按钮派生的按钮。 完成后,现在我需要创建多个按钮并将它们布局在某个地方。这是我被卡住的地方。
我创建了一个从 TGraphicControl 派生的新组件(这应该是我的新触摸键盘),但我不知道如何将组件添加到画布。我实际上不知道是否应该将它们添加到画布或其他组件(例如面板)!?!
我的方法可以吗?
提前致谢。
What i am trying to accomplish is to create new touchkeyboard.
First i created buttons which i derive from speed buttons.
That done, now i need to create multiple buttons and layout them somewhere. This is were i get stuck.
I created a new component which i derive from TGraphicControl (this should be my new touchkeyboard), but i don't know how to add components to canvas. I actually don't know whether i'm supposed to add them to canvas or to some other component (eg. panel)!?!
Is my approach OK?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您要创建自定义视觉控件,则需要创建按钮并手动放置它们。例如:
您可以将按钮创建放入一个循环中,并根据每个按钮应在的位置放置它们。
(这是我凭空写下来的,而且我不再写很多 Pascal,所以可能会有一些小错误!但它应该可以帮助你开始。)
If you're creating a custom visual control, you need to create the buttons and position them manually. For example:
You can put the button creation into a loop and position each one according to where it should be.
(I wrote this off the top of my head, and I don't write a lot of Pascal anymore, so there may be some minor mistakes! But it should get you started.)
由于您的措辞以及面板、画布和自定义控件之间的混淆,我假设您是 Delphi 初学者。您需要了解框架: embarcadero docwiki 链接框架
框架允许您创建 GUI 的可重用部分。您可以使用 IDE“绘制”框架,然后可以将该复合控件(框架)放置到窗体或其他框架上。这是一个非常强大的功能,并且在概念上非常接近其他语言所称的“自定义控件”(非常接近 asp.net 或 WPF 所认为的自定义控件)。
在 Delphi 世界中,当您说“自定义控件”时,人们通常会期望您想要创建一个可重用的控件,将其放置在包中并安装在 IDE 中。这是一个相当高级的主题。如果这就是你想要的,那么我误解了这个问题,抱歉。
Because of your wording and confusion between Panel, Canvas and custom controls in general, I assume you're a Delphi beginner. You need to learn about frames: embarcadero docwiki link on frames
Frames allow you to create re-usable portions of GUI. You use the IDE to "draw" the frame, you can then place that composite control (the frame) onto forms or other frames. It's a very powerful feature and it's conceptually very close to what other languages call "custom controls" (very close to what asp.net or WPF consider a custom control to be).
In the Delphi world, when you say "custom control", people would normally expect you to want to create an reusable control that's placed in a package and it's installed in the IDE. It's an fairly advanced subject. If that's what you want then I misunderstood the question, sorry.