I'm trying to hide or eliminate the scrollbar of a horizontal DBCtrlGrid
component.
I use the following code:
SetScrollRange(dbctrlgrid1.Handle, SB_HORZ, 0, 0, false);
It works fine!
BUT if I change the current record (on AfterScroll event, for example), it
appears again!
The other problem is that if I hide the scrollbar, the new space is empty
(no resizes).
Please, forgive my poor English. I'm from Spain.
PD: I'm using Delphi 7 Pro and Xp
The only reliable way to hide the scrollbar of a control that actually needs
one is to derive a new class from the control class and handle the
WM_NCCALCSIZE message. Example for a TDBGrid to hide both scrollbars:
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;
If you only want to hide the horizontal scrollbar change scrollstyles to
equal WS_HSCROLL only. This approach works for every control that uses the
standard window scrollbars.
--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be