Notice Of Closure

Please note that this website is due to close down on 15th June 2020.

In the interim I will try to move as much content as possible over to my GitHub account. Thanks to everyone who has supported the site over the years.

» Help

How to enable scrollbars at design time

I'm writing a TCustomControl descendant that has scrollbars (WS_HSCROLL and WS_VSCROLL styles). Could anyone tell how to enable the control to receive WM_xSCROLL messages at design time?

Try to provide the WM_NCHITTEST message. In the handler, check if you are hitting on scrollbars and return HTVSCROLL or HTHSCROLL in the message result. Otherwise call inherited.

procedure TScrollCheck.WMNCHitTest(var Msg: TWMNCHitTest);
  XPoint: TPoint;
  XPoint := ClientToScreen(GetClientRect.BottomRight);
  if XPoint.x < Msg.Pos.X then
    Msg.Result := HTVSCROLL
  if XPoint.y < Msg.Pos.Y then
    Msg.Result := HTHSCROLL
Original resource: The Delphi Pool
Author: Serge Gubenko
Added: 2009-08-12
Last updated: 2009-08-12

« Return to contents »