Solved

Hide horizontal scrollbar in a TListView

Posted on 2001-06-12
7
849 Views
Last Modified: 2010-04-06
How to hide the (optional)horizontal scrollbar in a TListView?
0
Comment
Question by:bengore
  • 4
  • 2
7 Comments
 
LVL 8

Expert Comment

by:Cesario
Comment Utility
Hi bengore,

AFAIK, you can hide both scrollbar.

Derive a new control from TTreeview and override its CreateParams method like this:

procedure tNoScrollbarsTreeview.createparams(var params: TCreateParams);
begin
  inherited;
  params.style := params.style or TVS_NOSCROLL;
end;

Best Regards

Cesario
0
 

Author Comment

by:bengore
Comment Utility
I don't want to make a new component. Is there no possibility to make the changes in the FormCreate procedure like:
SetWindowsStyle(Listbox.Handle, TVS_NOSCROLL) or some other Windows API function?
0
 
LVL 8

Expert Comment

by:Cesario
Comment Utility
Hi bengore,

no its not possible. The Listview manage the Scrollbars and will show them automaticly.

I hope some other Experts here can help you.

Best Regards

Cesario
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 8

Expert Comment

by:TOndrej
Comment Utility
try this:

ShowScrollBar(MyListView.Handle, SB_HORZ, False);
0
 
LVL 8

Expert Comment

by:Cesario
Comment Utility
Hi TOndrej,

it works but if you scroll down the Scrollbar appears again. ( that is window :-) )

Cesario
0
 
LVL 8

Accepted Solution

by:
TOndrej earned 70 total points
Comment Utility
Hi Cesario,

you can hide it again... a very raw example:

  TForm1 = class(TForm)
    ListView1: TListView;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    FListViewWndProc: TWndMethod;
    procedure ListViewWndProc(var Message: TMessage);
  public
  end;

implementation

{$R *.DFM}

procedure TForm1.ListViewWndProc(var Message: TMessage);
begin
  ShowScrollBar(ListView1.Handle, SB_HORZ, False); // hide horiz scrollbar
  FListViewWndProc(Message); // process message
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ListView1.Items[0].Left := 300;
  FListViewWndProc := ListView1.WindowProc; // save old window proc
  ListView1.WindowProc := ListViewWndProc; // subclass
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  ListView1.WindowProc := FListViewWndProc; // restore window proc
  FListViewWndProc := nil;
end;

This will hide the horizontal scrollbar again and again whenever it receives *any* message, which is an overkill, normally you would only hide it after receiving specific messages making the scrollbar visible. I don't know which these are... As I said, this example is very raw.
0
 
LVL 8

Expert Comment

by:Cesario
Comment Utility
Cool solution :_)))

Cesario
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now