TButton的缺陷 [英] TButton deficiencies
问题描述
TButton具有 Style
属性。当此属性设置为 bsSplitButton
时,按钮右侧将显示一个下拉箭头:
TButton in Delphi XE2 has a Style
property. When this property is set to bsSplitButton
then a drop-down arrow is displayed on the right side of the button:
但是,这滴下拉区域有一些不便之处:
However, this drop-down area has some inconveniences:
-
在很多情况下,它太窄了,下拉区域的静态宽度是仅11个像素。
In many cases it is too narrow, the static width of the drop-down area is only 11 pixels.
当鼠标指针悬停在下拉区域上时,仅针对该下拉区域没有明确的悬停指示。
There is no explicit hover indication just for the drop-down area when the mouse pointer hovers over the drop-down area.
如何实现TButton的后代来解决这种不便?后代应具有 DropDownWidth
属性,该属性应具有当鼠标悬停在下拉区域上时处理和更改下拉显示的属性。
How can a descendant of TButton be implemented which repairs this inconveniences? The descendant should have a DropDownWidth
property and a property which handles and changes the drop-down display when the mouse hovers over the drop-down area.
推荐答案
您的子孙必须调用 Button_SplitInfo
(或发送 BCM_SETSPLITINFO
)来调整分割宽度。下面是一个运行时示例用法,您可以在后代中集成类似的功能:
Your descendant must call Button_SplitInfo
(or send BCM_SETSPLITINFO
) to adjust the split width. Below is a run-time example usage, you can integrate similar functionality in your descendant:
procedure SetButtonSplitWidth(Button: TButton; Width: Integer);
var
Info: TButtonSplitinfo;
begin
if Button.Style = bsSplitButton then begin
Info.mask := BCSIF_SIZE;
Info.size.cx := Width;
Info.size.cy := 0;
Button_SetSplitInfo(Button.Handle, Info);
Button.Invalidate;
end;
end;
通话样本结果
SetButtonSplitWidth(Button2, 25);
是这样的:
请参见文档,了解您还可以做什么。没有任何功能可以修改本机按钮控件的悬停行为。为此,您最好不要从 TButton
开始。
See documentation for what else you can do. There's no functionality that modifies the hovering behavior for a native button control. For that, you would probably better not start from a TButton
.
这篇关于TButton的缺陷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!