How to enable scrollbars at design time #78

Question
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);
var
  XPoint: TPoint;
begin
  XPoint := ClientToScreen(GetClientRect.BottomRight);
  if XPoint.x < Msg.Pos.X then
    Msg.Result := HTVSCROLL
  else
  if XPoint.y < Msg.Pos.Y then
    Msg.Result := HTHSCROLL
  else
    inherited;
end;
Original resource: The Delphi Pool
Author: Serge Gubenko
Added: 2009/08/12
Last updated: 2009/08/12