[Lazarus] TCoolBar improvements

Juha Manninen juha.manninen62 at gmail.com
Sun Apr 27 17:58:53 CEST 2014


On Sun, Apr 27, 2014 at 3:36 PM, Vojtěch Čihák <vojtech.cihak at atlas.cz> wrote:
> I still cannot reproduce. I don't know why it happens, in the code is used
> only crDefault, crHSplit and crDrag.

Strange. How about others, can anybody reproduce the cursor issues?


> I see. I'll try to do something with it.

Please consider using AlignControls. It gets called by LCL always at
the right time when positioning is needed. You don't need to call the
positioning code anywhere else from your code. It would be the optimal
solution also performance-wise.
For dragging it may require extra state flags but should be doable.


> Coincidentaly, before two hours I installed Delphi7 Personal Edition to Wine
> and their implementation of TCoolBar isn't perfect too. For example, I can
> drag control away from band (on the second attempt). Also, when I put button
> on CoolBar it creates new band (it's OK) but it resizes the button to the
> full width of the CoolBar, which is pretty ugly. I tried to have more bands
> side by side in design time and in run time and I don't know how to it. II
> can only have each band on new line. Maybe it's possible only from code. But
> I believe it's possible somehow otehrwise the property Break shoudln't make
> sense.

Yes, I mentioned the bugs in Delphi's Coolbar in our issue report note:
  http://bugs.freepascal.org/view.php?id=25026#c70092
It is very bad. If you look at the code you understand how they
struggled to integrate a COM-control at design time.
I think the Windows CoolBar works quite well at run-time, the problems
are at design-time.


> On the other hand, TControlBar works fine in Delphi. That's where we loose
> yet. :D
> I'll try to improve both.

Your thoughts are going the same route as mine when I initially made TCoolBar.
First I though TControlBar was made after TCoolBar to solve the
COM-control related issues. No, then I learned it is an older
component, made already before Windows had a CoolBar COM-control.

I tried to learn the code of TControlBar, and maybe imitate its design
(not copying code, just design) but it was a bad idea.
It (also) is an absolute mess. I refactored some big functions into
smaller ones and removed many "with"-blocks to understand it better.
No...
Then I debugged the code but still could not really understand it. Uhhh...
I wasted some time with it. For me it is amazing to see how poor
quality code there is in parts of Delphi libraries. In general their
design is very good but there are some really dark corners.

What more, Delphi's TControlBar has lots of code compared to its features.
It has more or less the same features than our TCoolBar has now, but
maybe 10 times more code.

My plan was to share code between TCoolBar and TControlBar in LCL. It
would make sense because they are so similar.
I implemented TCoolBar first because I needed it for my Delphi porting
exercises and it is used more commonly than TControlBar.
If you improve TControlBar, consider sharing code between them. It may
require moving one or both of the components to another unit, which is
OK.

Juha




More information about the Lazarus mailing list