This is an Image of a RightToLeft TCoolBar. You will see that everything is Mirrored. Because it is MSWindows I am using RightToLeftLayout and not BiDiMode. Under MSWindows, BiDiMode has been obsolete for a long time.
Ok, but BiDiMode must be used for this component because it is essentially custom drawn.
Delphi's CoolBar is only a wrapper for the Windows COM component. It desperately tries to communicate with the actual component using messages. If you look at its source code, it is quite a mess. It never worked properly. For example at design-time you can move the associated controls away from their bands which is quite fundamental flaw.
In my custom drawn solution an overridden AlignControls relocates the controls. It prevents them moving, no other logic is needed for that. Clean, right?
I guess Borland realized how problematic this Windows COM component was. That's why they made (or bought) ControlBar which solves similar problems than CoolBar but is pure Pascal.
I wanted to understand how the the layout algorithm in ControlBar works. For some reason its code is also a big mess. For example it uses nested "with" statements, both of them referring to variables of same type but different instance. Uhhh!
I used a feature found in Cody package to explode those "with" statements, then I refactored the code to split the nearly 1000 line functions into smaller pieces. Still, even after debugging the code I did not understand how it worked!
My diagnosis is that it has a big amount of useless code, originally made for some other purpose.
Maybe they bought it from some hacker who then disappeared, and then nobody dared to touch the code. It has bugs that still have not been fixed in the 10+ years.
Delphi has lots of good design and code, but it also has some horribly low quality code.
That is why it bothers me sometimes that everything in LCL must be compatible with VCL, including bugs. No, we can do better.
Juha