Reputation: 158
When hovering the mouse over a control that has a hint, that hint is shown (ShowHint
is True).
For some reason, TListView.BeginUpdate prevents the hint from being shown, even though the control has nothing to do with the listview.
Reproduction:
var
DoOnce: Boolean = False;
procedure TForm1.Button2Click(Sender: TObject);
procedure Setup;
var
I: Integer;
begin
// problem occurs even when NOT created by code
// this is just to make reproduction easier
for I := 1 to 3 do
with TButton.Create(Form1) do begin
Parent := Form1;
Hint := IntToStr(I);
ShowHint := True;
Top := 8;
Left := 8 + I * (Width + 8);
end;
ListView1.ViewStyle := vsReport;
end;
begin
if not DoOnce then begin
DoOnce := True;
Setup;
end;
with Timer1 do begin
Interval := 250;
Enabled := not Enabled;
Form1.Caption := BoolToStr(Enabled, True);
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
with Form1.ListView1.Items do begin
BeginUpdate;
Sleep(1);
EndUpdate;
end;
end;
When the timer is enabled, hovering the mouse over the buttons will not show their hints (exception: if a button has shown its hint -- when the timer was disabled -- the hint will still be shown; this however applies only to the LAST button to show its hint)
Since the timer's code does not access the buttons in any way, I do not understand this behavior. Can anyone explain what is happening and how to fix this?
(In case this helps: this is a MRE, in actual code the listview is updated via Queue from a thread at 250ms intervals)
EDIT:
this is cause by SendMessage(Handle, WM_SETREDRAW, 0, 0);
in TListItems.SetUpdateState.
but why does a listview code affect other unrelated controls...
Upvotes: 0
Views: 215