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
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 ?
> 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.
> > 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
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