Create a component derived from TListbox and handle the displaying of the scollbar.
Example code just as interposed class.
The look can be adapted by designing and own style (with newer Delphi versions).
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TListBox = Class(StdCtrls.TListBox)
Constructor Create(AOwner: TComponent); override;
private
FHiddenScrollbar: Boolean;
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure WMMouseMove(var Message: TWMMouseMove); message WM_MOUSEMOVE;
published
public
Property HiddenScrollbar: Boolean Read FHiddenScrollbar;
End;
TForm3 = class(TForm)
ListBox1: TListBox;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
{ TListBox }
constructor TListBox.Create;
begin
inherited;
FHiddenScrollbar := true;
end;
procedure TListBox.CreateParams(var Params: TCreateParams);
VAR
Style: Integer;
BEGIN
inherited;
if FHiddenScrollbar then
Params.Style := Params.Style AND not WS_VSCROLL
else
Params.Style := Params.Style or WS_VSCROLL;
end;
procedure TListBox.WMMouseMove(var Message: TWMMouseMove);
var
p: TPoint;
begin
inherited;
GetCursorPos(p);
p := ScreenToClient(p);
if p.X > (Width - 20) then
begin
if FHiddenScrollbar then
begin
FHiddenScrollbar := false;
RecreateWnd;
end;
end
else
begin
if not FHiddenScrollbar then
begin
FHiddenScrollbar := true;
RecreateWnd;
end;
end;
end;
end.
