Solved

Hide horizontal scrollbar in a TListView

Posted on 2001-06-12
7
882 Views
Last Modified: 2010-04-06
How to hide the (optional)horizontal scrollbar in a TListView?
0
Comment
Question by:bengore
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 8 hours left to enroll

623 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