简体   繁体   English

Delphi TCoolBar-CoolBand对齐

[英]Delphi TCoolBar - CoolBand alignment

Is it possible to align the CoolBands to the left side of the CoolBar? 是否可以将CoolBand对准CoolBar的左侧? Means when the CoolBar (Form) is resized and the CoolBands move to the row below, the Band should be aligned to the left side of the Bar (instead to the right). 意味着当调整CoolBar(窗体)的大小并且CoolBands移动到下面的行时,Band应该与Bar的左侧(而不是右侧)对齐。 Similar the menu behaviour, when the items doesn't fit into one row anymore. 当菜单项不再适合一行时,类似于菜单行为。

Furthmore is it possible to save the adjustment of the Bands? 还有可能节省频段的调整吗?

If you set the MinWidth property of each band and set the CoolBar AutoSize property to True, it wraps automatically once a band is at its MinWidth. 如果您设置每个波段的MinWidth属性并将CoolBar AutoSize属性设置为True,则当波段处于其MinWidth时,它将自动包装。

Edit : The above is still correct, but should be expanded upon - new info from comments section. 编辑 :上面仍然是正确的,但应扩展-评论部分的新信息。 The Coolbar tries to always fill the width of the control, so your last band stretches to take up space. Coolbar尝试始终填充控件的宽度,因此您的最后一个频段会拉伸以占用空间。 If you add MaxWidth constraints to the banded controls, they align to the right as the band wraps and stretches. 如果将MaxWidth约束添加到带区控件,则它们在带环绕和拉伸时会向右对齐。 The best solution here is to set your MinWidth to whatever you need but to let the CoolBar determine the max width. 最好的解决方案是将MinWidth设置为所需的值,但让CoolBar确定最大宽度。

Save the adjustment? 保存调整? Do you mean the exact placement of each coolband? 您是指每个冷却带的确切位置吗? If so, I don't think you can store it directly, no. 如果是这样,我认为您不能直接存储它。 But it should be trivial to reproduce the layout. 但是复制布局应该是微不足道的。 Store the Break and Width properties of each Band and apply them in order. 存储每个Band的Break和Width属性,并按顺序应用它们。 I think your best strategy would be to resize the form (or TCoolBar), apply Break for each band and then Width for each band (loop twice). 我认为您最好的策略是调整窗体(或TCoolBar)的大小,对每个带应用Break,然后对每个带应用Width(循环两次)。

If that doesn't work, you could try calling the Windows message directly. 如果这不起作用,则可以尝试直接调用Windows消息。 This will allow you to set both properties at the same time. 这将允许您同时设置两个属性。

uses
  CommCtrl;
...
var
  Info: TRebarBandInfo;
...
  ZeroMemory(@Info, SizeOf(Info));
  Info.cbSize := SizeOf(Info);
  Info.fMask := RBBIM_SIZE + RBBIM_STYLE;
  Info.cx := 400; // Your desired width
  Info.fStyle := RBBS_BREAK + OldStyle;
  SendMessage(Coolbar.Handle, RB_SETBANDINFO, 0, Integer(@Info));

That should work, but will require that you make OldStyle above equal to the existing style. 那应该可以,但是要求您使OldStyle等于现有样式。 That in turn will require that you either duplicate much of the code in TCoolBar.UpdateItem, or send the message RB_SETBANDINFO first. 反过来,这将要求您要么复制TCoolBar.UpdateItem中的许多代码,要么首先发送消息RB_SETBANDINFO。 Painful, so try assigning Break and then Width. 很痛苦,因此请尝试先分配“中断”再分配“宽度”。

In the Delphi Windows SDK helpfile, check Rebar Reference for info on all the messages if you need them. 在Delphi Windows SDK帮助文件中,如果需要,请在“钢筋参考”中查看所有消息的信息。 On mine, the help URL (for help viewer) is ms-help://embarcadero.rs2009/ShellCC/platform/commctls/rebar/reflist.htm 在我的网站上,帮助URL(用于帮助查看器)是ms-help://embarcadero.rs2009/ShellCC/platform/commctls/rebar/reflist.htm

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

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