...hide the scrollbars of a DBGrid?
|
Autor:
P. Below |
[ Print tip
] | | |
(*
Q:
I want to hide the vertical scrollbar on a dbgrid when the record count
exceed a number. How can I do that?
A:
Make a descendent of the TDBGrid class. Add a handler for the
WM_NCCALCSIZE message.
*)
type
TNoScrollDBGrid = class(TDBGrid)
private
procedure WMNCCalcSize(var Msg: TMessage);
message WM_NCCALCSIZE;
end;
procedure TNoScrollDBGrid.WMNCCalcSize(var Msg: TMessage);
const
Scrollstyles = WS_VSCROLL or WS_HSCROLL;
var
Style: Integer;
begin
Style := GetWindowLong(Handle, GWL_STYLE);
if (Style and Scrollstyles) <> 0 then
SetWindowLong(Handle, GWL_STYLE, Style and not Scrollstyles);
inherited;
end;
//This removes both scrollbars. If you want to remove only the vertical one
//change the scrollstyles constant accordingly.
|