Windows 10 64 bit, Lazarus 4.0.
I just try to add editing capabilities to my custom listview within my Notepad++ (NPP) plugin.
I ran into two issues here:
1) "F2" key (for to engage an EditCaption) cannot be detected in Keydown or Keypress.
2) i get drawing artifacts when the listview editor is open and i mouse-hover along other items.
For to solve this i'd need to trigger my customdraw routines. But the painting event callback won't be called in this case.
Topic of this thread here is prob #2.
A bit more of details about it: in dark mode, the item's drawing is done via the Windows API managed by NPP. As this doesn't fit my needs at all, i'm using a comprehensive, fully working custom drawing of my listview.
This custom drawing does come out of effect when the listview's item editor is open, what does imply that the listview does not have the focus.
A listview item as it will be drawn now when hovering the mouse outside the item editor will unfortunately generate ugly artefacts; see image (and is, basically, completely different to the styling of my own custom drawing).
I try to enforce my appropriate custum draw here, but as the listview itself does not have the focus when the item editor is open, the custom draw routine will never be called.
procedure TMyListview.WndProc( var Message: TMessage );
....
if ((Msg = WM_MOUSEMOVE) Or (Msg = WM_MOUSEWHEEL)) then begin
if Msg = WM_MOUSEMOVE then begin
....
// Detect the appropriate condition / item where the mouse is over, and:
// Diverse tests and measures for to enforce a repaint of the item ("itm" here)
// - of course not all at once!! but one after another -:
// if some condition then begin ...
SendMessage(Handle, LVM_REDRAWITEMS, itm.Index, itm.Index);
outputdebugstring(pchar('-- trigger repaint ' + itm.Caption + ' index: ' + inttostr(itm.index) ));
Refresh;
Invalidate;
Self.Update;
Repaint;
SendMessage(Self.Handle, WM_ERASEBKGND, 1, 0);
bRect := Self.BoundsRect;
InvalidateRect(Self.Handle, @bRect, True);
InvalidateRect(Self.Handle, 0, True);
InvalidateRgn(Self.Handle, 0, True);
Application.ProcessMessages;
// --> A debug message within the custom draw event that it is reached won't never be seen
Of course: if i set the focus back to the listview, then the painting would work fine, but the editor will be closed immediately when hovering other items, and that's not what is wanted.
Any clever idea (how to tell the listview enforced to repaint a specifc item) would be very welcome .....