Qt: return correct size of QScrollBar when widget isn't mapped yet.issue #26084

git-svn-id: trunk@44831 -
This commit is contained in:
zeljko 2014-04-28 07:10:35 +00:00
parent 6f4e80d11d
commit 2b826c43d9

View File

@ -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;