Solved

Hide horizontal scrollbar in a TListView

Posted on 2001-06-12
7
856 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can't connect to Outlook via TOutlookApplication component 15 118
Thread safe  opinion 7 126
delphi parse string to params 3 97
drawing animated level bar based on numbers 3 86
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

929 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

14 Experts available now in Live!

Get 1:1 Help Now