Board index » delphi » how to hide DBCtrlGrid scrollbars

how to hide DBCtrlGrid scrollbars


2003-10-01 06:27:54 AM
delphi55
Hi!
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 am from Spain.
PD: I am using Delphi 7 Pro and Xp
 
 

Re:how to hide DBCtrlGrid scrollbars

In article <3f7a0363$XXXX@XXXXX.COM>, Santy Concepción writes:
Quote
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 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 :
www.mers.com/searchsite.html
www.tamaracka.com/search.htm
groups.google.com
www.prolix.be