具有自定义风格的Delphi项目
I want to create a Delphi project with a custom Style, like the below image.
As you can see, the MainForm is transparent, and there are some components inside of it.
How can I create this transparent MainForm?
P.S:I want to create VCL project and i drawn this image by Photoshop.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您使用的是FireMonKey,因为您没有指定VCL或FMX。
您实际上不需要为此创建一种样式。更简单的方法是:
true
trectangle
放在表单上,并使其与最左右
和将颜色等调整为您的喜好。trectangle
放在您的表单上,并将对齐设置为client
。然后,您可以调整不透明度
透明度的属性,fill
color> color
的属性,然后stroke> stroke
<< 代码>边框。trectangle
上设置保证金左
值来完成。现在,这应该看起来像您希望提供的东西,您可以禁用表单的边界。我们还需要做1件事,以避免将控件显示为透明。我们需要在表单上放置一个布局。不是矩形。如果将控件放置在矩形上,则控件也将是透明的。如果您希望控件具有相同的透明值,则将其放在矩形上。否则请执行以下操作:
tlayout
放在表单上。不是矩形。要做的最后一件事是实现窗口拖动。假设您禁用了边框,则您的用户将无法移动窗口,因为没有边框可以拖动。在组件的Mousedown事件中,您希望拖动启动添加以下代码:
现在应该完成。
编辑:发布此答案后,我举了一个示例:
Assuming you're using Firemonkey since you dont specify VCL or FMX.
You don't really need to create a style for this. Rather a simpler way would be to:
True
TRectangle
on the form and make it align toMost left
and adjust the color etc to your liking.TRectangle
on your form and set the alignment toClient
. You can then adjust theOpacity
property for transparency, thefill
property forcolor
and then thestroke
for theborder
.margin left
value on the secondTRectangle
you placed.Now this should look like you what want it to be provided you disabled the border of the form. There is 1 more thing we need to do to avoid having the controls show as transparent. We need to place a layout on the form. Not the rectangle. If you place the controls on the rectangle with opacity the controls will also be transparent. If you want the controls to have the same transparency value place it on the rectangle. Otherwise do the following:
TLayout
on the form. Not the rectangle.margin left
property of the layout to the width of the left rectangle you placed + the margin value of the client rectangle you placed to compensate for the little space.One last thing to do is implement window drag. Assuming you disabled the border, your users will not be able to move the window at all since there is no border to drag. On the MouseDown event of the component you want the drag to start add the following code:
You should be all done now.
EDIT: I made an example after posting this answer: FMX Semi Transparent Form