Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to hide DBCtrlGrid scrollbars

843 views
Skip to first unread message

Santy Concepción

unread,
Sep 30, 2003, 6:27:54 PM9/30/03
to
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'm from Spain.

PD: I'm using Delphi 7 Pro and Xp


Peter Below (TeamB)

unread,
Oct 1, 2003, 7:36:20 AM10/1/03
to
In article <3f7a0363$1...@newsgroups.borland.com>, Santy Concepción wrote:
> 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 :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be


0 new messages