3

I want to display something in the bottom right of a TDBGrid, but I don't want to overwrite the scrollbars.

Is there a nice way of determining if the scrollbars are visible? (and their size)

Alister
  • 6,527
  • 4
  • 46
  • 70

1 Answers1

10

Probably the best approach is to use the ClientRect property, which gives the client rectangle of the control in its own coordinates (which implies that Left and Top are always 0). The "client rectangle" is the part of the control which is not border and scroll bar.

For comparison, the BoundsRect property is the full rectangle of the window in the parent window's coordinate system.

For example,

Screenshot of a control with a scrollbar, and its BoundsRect and ClientRect values.

and

pnSnowman.SetBounds(
  DBGrid1.Left + DBGrid1.ClientWidth - pnSnowman.Width - 8,
  DBGrid1.Top + DBGrid1.ClientHeight - pnSnowman.Height - 8,
  pnSnowman.Width,
  pnSnowman.Height
);

results in

Control with snowman in its bottom-right corner.

Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384