In response to JuhaManninen's call to arms, I dove into Mantis. I've found a bug that I feel I'm right on the verge of fixing, I'm just stuck at the last moment and need some help :-)
All the pertinent details are in:
http://bugs.freepascal.org/view.php?id=19982Turns out we've a bug in TCustomGrid - there's some whitespace that only appears under certain circumstances, and I don't think we're dealing with that. Ignore my comment in the bugtracker - I'm not going to bed until this is busted :-)
I've got the scrollbar now correctly sizing when white space appears. Problem is, this now means the scrollbar doesn't fully represent the grid - it represents the grid + the whitespace. When I then move the scrollbar, there's a chance there won't be any whitespace left on the screen, and so maybe the scrollbar isn't needed anymore.
So, in Procedure TCustomGrid.WMHScroll(Var message: TLMHScroll);, when we receive SB_ENDSCROLL, I'm now recalculating if we need the scrollbar or not.
And I've stepped through the code. It works. Horizontal scrollbar is now correctly calculated to be hidden, and when I call UpdateSBVisibility, I can confirm that the following function is called with the correct values.
function ShowScrollBar(Handle: HWND; wBar: Integer; bShow: Boolean): Boolean;
Problem is, the
sodding scrollbar doesn't vanish. However, if I then click anywhere on the grid, the scrollbar immediately vanishes.
I'm thinking this perhaps has something to do with me sending one message (whatever the scrollbar hide message is) while in the middle of processing another (SB_ENDSCROLL).
Does this sound plausible to anyone? Doesn't to me, but I can't think of any other reason the scrollbar is remaining visible...
I've included a screendump showing some relevant debug info...
Here's the code I'm currently calling in Procedure TCustomGrid.WMHScroll(Var message: TLMHScroll);
SB_ENDSCROLL:
begin
ResetSizes;
UpdateSBVisibility;
Invalidate;
Exit;
end;