«« Site Rescued »»

While the site is still going to move from its current host, a new site will now take its place. More Info.

The new site may have less content, but the core will now remain. And it will now play nicely with phones! Keep an eye on the DelphiDabbler Blog for news.

» Help

How to enable scrollbars at design time

   
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

« Return to contents »