These days i'd talked a couple of times about the port of an old Notepad++ plugin to Lazarus (3.) 64bit, Windows.
With the gui part (with special regards to the dark mode as from NPP's theme layer) i'm almost done.
Remains a small particular thing. In dark mode, TToolBar's dividers/separators and a dropdown button are unrecognizably painted.
See image attached.
I asked myself how to deal best with this. - Thoughts:
- Ignore it
- Take another (tool)button component (yes, those are)
- Inherit a "TToolButton2" via cloning the whole toolbutton code (yes, we can)
- Clone only the painting stuff within a form's "PaintButton" callback and change this one.
Some strong suggestions or recommendations here?
About the last approach i put a few toes into and noticed that mostly one is busy to replicate, mimic or "open" some intrinsic (private or protected) properties or functions.
About this, i reached my limits here:
type
TToolButtonOpener = class(ComCtrls.TToolButton);
.....
procedure THelloWorldDockingForm.ToolBar1PaintButton(Sender: TToolButton; State: integer);
var
Details: TThemedElementDetails;
.....
begin
.....
Details := TToolButtonOpener(Sender).GetButtonDrawDetail;
===> Exception "Invalid type cast", and then SIGSEV.
Similar with
toolbutton2 := TToolButtonOpener(Sender); // Sender is TToolButton
==> Why invalid type cast? And how else to invoke toolbutton's GetButtonDrawDetail ?
-------
About a side thought more maybe later.
aToolBar.OnPaintButton := nil; //ToolButton's paint asks for: if Assigned(FToolBar.OnPaintButton)
inherited; // Hope that here the button is painted. (But it won't).
// And now overpaint the desired parts only
// When finished, restore the OnPaintButton assignment:
aToolBar.OnPaintButton := ToolBar1PaintButton;