Forum > KOL
[KOL] Listbox Scrollbar
JoniDS:
Is it possible to "hide" listbox scrollbars or get control of their paint event?
Thanks
yuriy_sydorov:
You can set Options property of listbox to hide scrollbars and enable owner drawn items.
JoniDS:
I think when you are talking about de LoNoHideScroll, right?
But wether i put yes or no, scrollbar always appears.
I've looked at source code and testing i managed to hide the scroll bar if i removed WS_VSCROLL from the newlistbox function. Of course it will now never show no matter what i put in Lonohidescroll.
--- Code: ---function NewListbox( AParent: PControl; Options: TListOptions ): PControl;
var Flags: Integer;
begin
Flags := MakeFlags( @Options, ListFlags );
Result := _NewControl( AParent, 'LISTBOX', WS_VISIBLE or WS_CHILD or WS_TABSTOP
or WS_BORDER or WS_VSCROLL
or LBS_NOTIFY or Flags , True, @ListActions );
with Result.fBoundsRect do
begin
Right := Right + 100;
Bottom := Top + 200;
end;
Result.fColor := clWindow;
Result.fLookTabKeys := [ tkTab, tkLeftRight ];
end;
--- End code ---
Is this because SetWindowLong doesn't allows to change WS_VSCROLL property after window has been created?
Using the following code still shows the scrollbar :
--- Code: ---procedure TForm1.ListBox1Show(Sender: PObj);
var
style : integer;
begin
style := GetWindowLong(listbox1.handle, GWL_STYLE) xor WS_VSCROLL;
SetwindowLong(Listbox1.Handle,GWL_STYLE, style );
SetWindowPos(Listbox1.handle, Listbox1.handle,Listbox1.left, listbox1.Top, listbox1.Width, listbox1.height,SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER or SWP_FRAMECHANGED);
end;
--- End code ---
yuriy_sydorov:
I misread loNoHideScroll option.
Removing WS_VSCROLL is the only way to hide scroll bar.
Use this in form's FormCreate event:
--- Code: ---listbox1.Style:=listbox1.Style and not WS_VSCROLL;
--- End code ---
u-boot:
I know this is an old topic but i think it must be updated.
--- Quote from: yury_sidorov on February 06, 2009, 04:15:51 pm ---
--- Code: ---listbox1.Style:=listbox1.Style and not WS_VSCROLL;
--- End code ---
--- End quote ---
This "solution" causes following Error:
Error: Incompatible types: got "TListBoxStyle" expected "LongInt"
Definition of TListBoxStyle:
TListBoxStyle = (lbStandard, lbOwnerDrawFixed, lbOwnerDrawVariable, lbVirtual);
Navigation
[0] Message Index
[#] Next page