How can I determine if scrollbars are visible?

The following code shows you how to determine if scrollbars are visible:

   BOOL bLastRowVisible, bLastColVisible;
   CRect rect = GetGridRect();
   CalcBottomRowFromRect(rect, bLastRowVisible);
   CalcRightColFromRect(rect, bLastColVisible);
   BOOL bVertScrollbar = GetTopRow() > GetFrozenRows() +1 || !bLastRowVisible;
      // TRUE if scrollbar is needed
   BOOL bHorzScrollbar = GetLeftCol() > GetFrozenCols() +1 || !bLastColVisible;
      // TRUE if scrollbar is needed