diff --git a/lcl/include/customlistbox.inc b/lcl/include/customlistbox.inc index e9918b0bf9..73469bfd1f 100644 --- a/lcl/include/customlistbox.inc +++ b/lcl/include/customlistbox.inc @@ -339,13 +339,15 @@ var begin with TheMessage.MeasureItemStruct^ do begin - if Self.ItemHeight <> 0 then - AHeight := Self.ItemHeight + // don't call GetItemHeight: causes errors on Windows due to recursion on control creation + if FItemHeight <> 0 then + AHeight := FItemHeight else begin Canvas.Font := Font; AHeight := Canvas.TextHeight('Hg'); end; - MeasureItem(Integer(ItemId), AHeight); + if FStyle = lbOwnerDrawVariable then + MeasureItem(Integer(ItemId), AHeight); if AHeight > 0 then ItemHeight := AHeight; end; diff --git a/lcl/interfaces/win32/win32wsstdctrls.pp b/lcl/interfaces/win32/win32wsstdctrls.pp index 203209bc26..289adb3463 100644 --- a/lcl/interfaces/win32/win32wsstdctrls.pp +++ b/lcl/interfaces/win32/win32wsstdctrls.pp @@ -853,15 +853,9 @@ begin end; class function TWin32WSCustomListBox.GetItemRect( - const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect - ): boolean; -var - Handle: HWND; + const ACustomListBox: TCustomListBox; Index: integer; var ARect: TRect): boolean; begin - Handle := ACustomListBox.Handle; - // The check for GetProp is required because of some division error which happens - // if call LB_GETITEMRECT on window initialization - Result := Assigned(GetProp(Handle, 'WinControl')) and (Windows.SendMessage(Handle, LB_GETITEMRECT, Index, LPARAM(@ARect)) <> LB_ERR); + Result := Windows.SendMessage(ACustomListBox.Handle, LB_GETITEMRECT, Index, LPARAM(@ARect)) <> LB_ERR; end; class function TWin32WSCustomListBox.GetScrollWidth(const ACustomListBox: TCustomListBox): Integer;