I gratefully used this code in my application. It works fine with normal grid. When I enabled columns, I noticed some issues:
1. The title row is no more autosized.
2. Following string causes arithmetic overflow error in case of hidden column:
RowHeights[aRow] := maxRowHeight+2;
For hidden column (e.g. StringGrid1.Columns[2].Visible:=False;) column width is 0 (ColWidths[2]=0).
In that case maxRowHeight stays equal to MaxInt.
I've add check for ColWidths[aCol]>0 as a workaround, while not sure this will work for all systems.
(Windows 10, Lazarus 2.2.4)