Author: Tomas Rutkauskas
I want to remove the scrollbar of a TListBox and control scrolling with a separate
scrollbar. Anyone has an idea how to remove it?
Answer:
This requires a somewhat dubious hack. Derive a new component from TListBox, like
this:
1 type2 TNoVScrolllistbox = class(TListBox)
3 private4 procedure WMNCCalcSize(var msg: TMessage); message WM_NCCALCSIZE;
5 end;
6 7 procedure TNoVScrolllistbox.WMNCCalcSize(var msg: TMessage);
8 var9 style: Integer;
10 begin11 style := GetWindowLong(handle, GWL_STYLE);
12 if (style and WS_VSCROLL) <> 0 then13 SetWindowLong(handle, GWL_STYLE, style andnot WS_VSCROLL);
14 inherited;
15 end;
This technique works for nearly any control that uses the standard window scrollbars.