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

"Extracting" the scrollbar from a listbox

10 views
Skip to first unread message

Stephane Grobety

unread,
Apr 30, 1999, 3:00:00 AM4/30/99
to
Hi all,

I'm trying to write YA new and improved Listbox with a lot of features
(columns with alignement, bitmap and check box support, tooltip text
expansion, autosearch and more) but I'm having one probleme I can't find any
way to solve: I need to extract the vertical scrollbar from the listbox and
put it in a nearby control (that is, I need to change it's parent) so that
it won't scroll horizontaly. The probleme is: I can't find any way to do
this or even get the window handle of the scrollbar.

Any idea ?

TIA,
Stephane

Peter Below (TeamB)

unread,
Apr 30, 1999, 3:00:00 AM4/30/99
to
Stephane,

the scrollbar of a listbox or form or other control is not a control, it is
simply a part of the windows non-client area. It is displayed if the window
has the WS_VSCROLL or (for a horizontal scrollbar) WS_HSCROLL window style.
There is an API function to hide and show a scrollbar: ShowScrollbar.

Peter Below (TeamB) 10011...@compuserve.com)
No replies in private e-mail, please, unless explicitly requested!


Stephane Grobety

unread,
May 3, 1999, 3:00:00 AM5/3/99
to
> Stephane,
>
> the scrollbar of a listbox or form or other control is not a control, it
is
> simply a part of the windows non-client area. It is displayed if the
window
> has the WS_VSCROLL or (for a horizontal scrollbar) WS_HSCROLL window
style.
> There is an API function to hide and show a scrollbar: ShowScrollbar.
>
> Peter Below (TeamB) 10011...@compuserve.com)
> No replies in private e-mail, please, unless explicitly requested!
>

Peter,
Thanks for the answer. You mean that the scrollbar in a listbox has actually
no window handle of it's own ?

And about the ShowScrollbar function, it seems that, no matter what I do,
the delphi wrapper around the listbox control insists on adding the
scrollbar each time I remove it (or rather, each time I reopen the form). Do
you know a way around this other than cutting and pasting the recreatewindow
methode ?

Peter Below (TeamB)

unread,
May 3, 1999, 3:00:00 AM5/3/99
to
In article <7gjo2h$3j...@forums.borland.com>, Stephane Grobety wrote:
> You mean that the scrollbar in a listbox has actually
> no window handle of it's own ?
>
Exactly.

> And about the ShowScrollbar function, it seems that, no matter what I do,
> the delphi wrapper around the listbox control insists on adding the
> scrollbar each time I remove it (or rather, each time I reopen the form).

It is the listbox controls itself, not the poor Delphi wrapper (which is
completely innocent here). The listbox has been written by MS in a way that
makes it decide itself when it needs a scrollbar and when not. Trying to
change its mind is an exercise in futility <g>. Base your control on a
drawgrid or write it from scratch based on TCustomControl.

Stephane Grobety

unread,
May 4, 1999, 3:00:00 AM5/4/99
to
Thank you Peter,

> > You mean that the scrollbar in a listbox has actually
> > no window handle of it's own ?
> >
> Exactly.

I was afraid so. Thanks.

> > And about the ShowScrollbar function, it seems that, no matter what I
do,
> > the delphi wrapper around the listbox control insists on adding the
> > scrollbar each time I remove it (or rather, each time I reopen the
form).
>
> It is the listbox controls itself, not the poor Delphi wrapper (which is
> completely innocent here). The listbox has been written by MS in a way
that
> makes it decide itself when it needs a scrollbar and when not. Trying to
> change its mind is an exercise in futility <g>. Base your control on a
> drawgrid or write it from scratch based on TCustomControl.

Actually, by looking at the wrapper source code, I found a way around this:
Overriding the CreateParam methode of the TCustomListBox control and add:

inherited CreateParams(Params);
with Params do
Style := Style and not (WS_HSCROLL or WS_VSCROLL);

Did the trick...


Thank you,
Stephane

Scott Mattes

unread,
May 4, 1999, 3:00:00 AM5/4/99
to
Now, if we could specify left or right for the vertical scrollbar and
top or bottom for the horizontal scrollbar. And, while I dream, how
about the up/down buttons both being at either the top/bottom or
right/left instead of one at each?

Stephane Grobety wrote:
>
> Hi all,


>
> I'm trying to write YA new and improved Listbox with a lot of features
> (columns with alignement, bitmap and check box support, tooltip text
> expansion, autosearch and more) but I'm having one probleme I can't find any
> way to solve: I need to extract the vertical scrollbar from the listbox and
> put it in a nearby control (that is, I need to change it's parent) so that
> it won't scroll horizontaly. The probleme is: I can't find any way to do
> this or even get the window handle of the scrollbar.
>

> Any idea ?
>
> TIA,
> Stephane

--
---------------------------------
Scott Mattes
ICQ: 18330579
Work: Scott....@Wang.com
Home: SMa...@Erols.com
Web: www.erols.com/smattes

0 new messages