mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 23:59:24 +02:00
Win32: fix TListView losing focus after EndUpdate. Issue #40786.
(cherry picked from commit 88827aa909
)
This commit is contained in:
parent
7de8a80ca0
commit
ab817f24ee
@ -1019,6 +1019,7 @@ end;
|
|||||||
class procedure TWin32WSCustomListView.EndUpdate(const ALV: TCustomListView);
|
class procedure TWin32WSCustomListView.EndUpdate(const ALV: TCustomListView);
|
||||||
var
|
var
|
||||||
ColIndex : Integer;
|
ColIndex : Integer;
|
||||||
|
WasFocused: Boolean;
|
||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(ALV, 'EndUpdate')
|
if not WSCheckHandleAllocated(ALV, 'EndUpdate')
|
||||||
then Exit;
|
then Exit;
|
||||||
@ -1032,6 +1033,10 @@ begin
|
|||||||
// column resizing, but this way we we can really enforce it).
|
// column resizing, but this way we we can really enforce it).
|
||||||
// ShowWindow() itself does not force an immediate redraw,
|
// ShowWindow() itself does not force an immediate redraw,
|
||||||
// so it won't flicker at all.
|
// so it won't flicker at all.
|
||||||
|
|
||||||
|
// If parent of the listview is not the form itself, then
|
||||||
|
// hiding it may cause it to loose focus. Issue #40786
|
||||||
|
WasFocused := ALV.Focused;
|
||||||
ShowWindow(ALV.Handle, SW_HIDE);
|
ShowWindow(ALV.Handle, SW_HIDE);
|
||||||
for ColIndex := 0 to TCustomListViewAccess(ALV).Columns.Count - 1 do
|
for ColIndex := 0 to TCustomListViewAccess(ALV).Columns.Count - 1 do
|
||||||
if ALV.Column[ColIndex].AutoSize
|
if ALV.Column[ColIndex].AutoSize
|
||||||
@ -1040,6 +1045,8 @@ begin
|
|||||||
SendMessage(ALV.Handle,WM_SETREDRAW,WPARAM(True),0);
|
SendMessage(ALV.Handle,WM_SETREDRAW,WPARAM(True),0);
|
||||||
if ALV.Visible then
|
if ALV.Visible then
|
||||||
ShowWindow(ALV.Handle, SW_SHOW);
|
ShowWindow(ALV.Handle, SW_SHOW);
|
||||||
|
if WasFocused and ALV.CanSetFocus then
|
||||||
|
ALV.SetFocus;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TWin32WSCustomListView.GetBoundingRect(const ALV: TCustomListView): TRect;
|
class function TWin32WSCustomListView.GetBoundingRect(const ALV: TCustomListView): TRect;
|
||||||
|
Loading…
Reference in New Issue
Block a user