简体   繁体   中英

Delphi TCoolBar - CoolBand alignment

Is it possible to align the CoolBands to the left side of the 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). 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.

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. If you add MaxWidth constraints to the banded controls, they align to the right as the band wraps and stretches. The best solution here is to set your MinWidth to whatever you need but to let the CoolBar determine the max width.

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. 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).

If that doesn't work, you could try calling the Windows message directly. 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. That in turn will require that you either duplicate much of the code in TCoolBar.UpdateItem, or send the message RB_SETBANDINFO first. 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. On mine, the help URL (for help viewer) is ms-help://embarcadero.rs2009/ShellCC/platform/commctls/rebar/reflist.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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