简体   繁体   English

Delphi tbutton图片位置

[英]Delphi tbutton image position

In delphi xe 8 tbutton's image has aligning for "left, center, right and bottom" but when i select "center" align for the image, the image is aligning in the middle of button and stays behind the caption在 delphi xe 8 tbutton 的图像中,“左、中、右、下”对齐,但是当我为图像选择“居中”对齐时,图像在按钮中间对齐并保持在标题后面

What i wanna do is align the image right before the caption text (like it should)我想要做的是在标题文本之前对齐图像(就像它应该的那样)

I dont know why delphi tbutton doesnt do that, is it a bug?我不知道为什么 delphi tbutton 不这样做,这是一个错误吗? Or delphi team wants to drive us crazy?还是德尔福团队想把我们逼疯? It should be so easy but just aligning a button image causing problem?应该很简单,但只是对齐按钮图像会导致问题吗?

Is there a way to align image nicely in the center with the caption?有没有办法在中心很好地将图像与标题对齐?

like in the picture below如下图所示

在此处输入图片说明

The text in the button is one thing the image is another.按钮中的文本是一回事,图像是另一回事。 You could hack this if you align the image to the left, and align the text in the middle.如果将图像向左对齐,并将文本居中对齐,则可以破解此问题。 If needed add extra blank spaces in front of the text.如果需要,在文本前添加额外的空格。

找到了解决方案,它是 bitbtn,它非常简单,它总是在我眼前,显然 bitbtn 也是 OS 按钮的包装器,它可以满足我的要求,而且它还有画布,因此可以在上面绘图

You can replace the TButton with a TBitBtn, and use the margin property of TBitBtn to align images nicely.您可以用 TBitBtn 替换 TButton,并使用 TBitBtn 的边距属性很好地对齐图像。

The Margin property sets the distance between the edge of the button and glyph, in pixels. Margin 属性设置按钮边缘和字形之间的距离,以像素为单位。

More info here: https://wiki.lazarus.freepascal.org/TBitBtn更多信息在这里: https : //wiki.lazarus.freepascal.org/TBitBtn

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM