Have you considered correcting the original source and submitting a patch to the bug-tracker? Or at least asking in the mailing list WTH this was done so?
Currently no — I tested my solution only on
WinXP. ”Tomorrow” I will check on
Win7 and
Win10.
There may be some other reason we know nothing about ... although I can't see it.
Probably there is no reason to do this ”strange” calculations. Items can have any height, not only that calculated by the component itself. And the items can have different height, one bigger than other. Somebody who wrote this code didn't know that, or just implement ”dirty” solution for now.
The size of the checkbox is known — it is retrieved using the method from the
ThemeServices object. On the other hand, checkbox offsets in the item are hardcoded in the source code. No problem to calculate the correct area occupied by the checkbox graphic and use it in several widgetset methods (in the painting method and in the message handling method).
As to why ... well, just a wild guess but maybe someone thought that this being a quasi-tabular stle of control the user should be able to "check" the box by clicking on the text or something like that?
You have a good imagination.
But IMO this is a bug, not a feature. The strange is, that the entire area on the left of the area for text is used to toggle the checkbox. Not the area of the visible checkbox (painted by the
ThemeServices), but entire area (high as whole item).
I just used the subclassing, overriden the
WndProc method and commented out the code in the widgetset, which is responsible for handling left button messages (and toggling the checkbox). But I wrote my code in the way that the user can toggle the checkbox only by clicking in the visual checkbox area — not above, not below and not next to it, just directly on the button graphic. This is intuitive — the user will be happy.
It was the only (and fast) way to completely cover the default handler of such a messages. I don't have time to look for bugs and come up with solutions to eliminate them — the deadline is approaching…
Strange. Have you tried following the message path to see what it's doing and where?
No, currently I have no time for this. Especially that the message callback for
TCheckListBox is overriden in the widgetset itself anyway. There's some magic going on.