Recently I got many user reports about EOutOfResources happened at arbitrary time. Deep investigation showed that this exception is raised on GDIError. The error was returned by GDI in attempt to set size of a bitmap to very very large value (some million pixels). This bitmap is used in VCL Styles engine (StyleAPI.inc), and its size was suggested by TVclStyleScrollBarsHook hook established in VirtualTrees.pas.
I'm not sure why Delphi is silent about this problem, but it's clear that not all code branches in TVclStyleScrollBarsHook.GetHorzScrollBarSliderRect and TVclStyleScrollBarsHook.GetVertScrollBarSliderRect assign values to the returning result, leaving TRect unintialized if scrollbar is not visible or not enabled.
Fix is below:
function TVclStyleScrollBarsHook.GetHorzScrollBarSliderRect: TRect;
var
P: TPoint;
BarInfo: TScrollBarInfo;
begin
if FHorzScrollBarWindow.Visible and FHorzScrollBarWindow.Enabled then
begin
...
end
+ else
+ Result := TRect.Empty;
end;
function TVclStyleScrollBarsHook.GetVertScrollBarSliderRect: TRect;
var
P: TPoint;
BarInfo: TScrollBarInfo;
begin
if FVertScrollBarWindow.Visible and FVertScrollBarWindow.Enabled then
begin
...
end
+ else
+ Result := TRect.Empty;
end;