From 478688e0f120e132a04f262c1d120c6a5a911d09 Mon Sep 17 00:00:00 2001 From: zeljan1 Date: Tue, 3 Jun 2025 18:09:30 +0200 Subject: [PATCH] Qt5,Qt6: fixed TListBox.TopIndex. issue #41688 --- lcl/interfaces/qt5/qtwsstdctrls.pp | 9 +++++++++ lcl/interfaces/qt6/qtwsstdctrls.pp | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/lcl/interfaces/qt5/qtwsstdctrls.pp b/lcl/interfaces/qt5/qtwsstdctrls.pp index a1c6a1e3b4..040526d461 100644 --- a/lcl/interfaces/qt5/qtwsstdctrls.pp +++ b/lcl/interfaces/qt5/qtwsstdctrls.pp @@ -580,8 +580,17 @@ end; Returns: Nothing ------------------------------------------------------------------------------} class function TQtWSCustomListBox.GetTopIndex(const ACustomListBox: TCustomListBox): integer; +var + QtListWidget: TQtListWidget; + AQtPoint: TQtPoint; begin Result := 0; + if not WSCheckHandleAllocated(ACustomListBox, 'GetTopIndex') then + Exit; + QtListWidget := TQtListWidget(ACustomListBox.Handle); + AQtPoint.x := 0; + AQtPoint.y := 0; + Result := QtListWidget.IndexAt(@AQtPoint); end; {------------------------------------------------------------------------------ diff --git a/lcl/interfaces/qt6/qtwsstdctrls.pp b/lcl/interfaces/qt6/qtwsstdctrls.pp index 9aec958dd1..7c2a59806a 100644 --- a/lcl/interfaces/qt6/qtwsstdctrls.pp +++ b/lcl/interfaces/qt6/qtwsstdctrls.pp @@ -580,8 +580,17 @@ end; Returns: Nothing ------------------------------------------------------------------------------} class function TQtWSCustomListBox.GetTopIndex(const ACustomListBox: TCustomListBox): integer; +var + QtListWidget: TQtListWidget; + AQtPoint: TQtPoint; begin Result := 0; + if not WSCheckHandleAllocated(ACustomListBox, 'GetTopIndex') then + Exit; + QtListWidget := TQtListWidget(ACustomListBox.Handle); + AQtPoint.x := 0; + AQtPoint.y := 0; + Result := QtListWidget.IndexAt(@AQtPoint); end; {------------------------------------------------------------------------------