Solved

Hide horizontal scrollbar in a TListView

Posted on 2001-06-12
7
868 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
ID: 6181447
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
ID: 6182011
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
ID: 6182042
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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 8

Expert Comment

by:TOndrej
ID: 6182160
try this:

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

Expert Comment

by:Cesario
ID: 6182201
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
ID: 6182325
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
ID: 6182379
Cool solution :_)))

Cesario
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, MySQL Query 4 167
DBGrid or StringGrid ? 6 105
Why  'Host Connection unavailable/Socket Error #113 No route to host' 6 54
Delphi problems to abort a printjob 9 25
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 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