From 2b826c43d9094cbe5baff98c950fa1d04c6b8a58 Mon Sep 17 00:00:00 2001 From: zeljko Date: Mon, 28 Apr 2014 07:10:35 +0000 Subject: [PATCH] Qt: return correct size of QScrollBar when widget isn't mapped yet.issue #26084 git-svn-id: trunk@44831 - --- lcl/interfaces/qt/qtwinapi.inc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index 3adf4c2aaf..00cfa05b11 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -3430,6 +3430,7 @@ function TQtWidgetSet.GetScrollBarSize(Handle: HWND; BarKind: Integer): integer; var w: TQtWidget; ScrollBar: TQtScrollBar; + ASize: TSize; begin {$ifdef VerboseQtWinAPI} writeln('Trace:> [WinAPI GetScrollBarSize] Handle: ' + dbghex(Handle),' BarKind: ',BarKind); @@ -3439,14 +3440,13 @@ begin w := TQtWidget(Handle); - {TODO: find out what to do with TCustomForm descendants } {$IFDEF QTSCROLLABLEFORMS} if (w is TQtMainWindow) and Assigned(TQtMainWindow(w).ScrollArea) then w := TQtMainWindow(w).ScrollArea; {$ENDIF} if w is TQtAbstractScrollArea then begin - if BarKind in [SM_CXVSCROLL, SM_CYVSCROLL] then + if BarKind in [SB_VERT, SM_CXVSCROLL, SM_CYVSCROLL] then ScrollBar := TQtAbstractScrollArea(w).verticalScrollBar else ScrollBar := TQtAbstractScrollArea(w).horizontalScrollBar; @@ -3457,10 +3457,23 @@ begin ScrollBar := nil; if ScrollBar <> nil then begin - if BarKind in [SM_CXHSCROLL, SM_CYVSCROLL] then - Result := ScrollBar.getWidth - else - Result := ScrollBar.getHeight; + if ScrollBar.getOrientation = QtVertical then + begin + if not ScrollBar.testAttribute(QtWA_Mapped) then + begin + ScrollBar.sizeHint(@ASize); + Result := ASize.cx; + end else + Result := ScrollBar.getWidth; + end else + begin + if not ScrollBar.testAttribute(QtWA_Mapped) then + begin + ScrollBar.sizeHint(@ASize); + Result := ASize.cy; + end else + Result := ScrollBar.getHeight; + end; end; end;