Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

TListBox question

Posted on 1998-03-18
6
Medium Priority
?
271 Views
Last Modified: 2010-04-04
hi

when the number of lines exceed the height of the list box, the vertical scroll bar appears. i want to trap the event when the user uses the mouse and clicks on the scroll bar. how do i do that? if this is not possible, how do i disable the vertical scroll bar?

Regards
keith
0
Comment
Question by:keithcsl
[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
6 Comments
 

Expert Comment

by:crexes
ID: 1360590
Hi,
There is a Windows API-call that I used once, when I was working with the scroll-bar to an application, BUT I'm afraid that I don't remember it - nice huh? :)
Anyway - now you KNOW that there is a way! Better that nothing :)

//crexes
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360591
You can trap WM_HSCROLL and WM_VSCROLL messages.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360592
You can trap WM_HSCROLL and WM_VSCROLL messages.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Expert Comment

by:d003303
ID: 1360593
You could disallow adding more items to the listbox by calculating the maximum items with the ItemHeight property. Of course this makes no sense if your question is a matter of a resizing form.
0
 
LVL 1

Accepted Solution

by:
Edo082297 earned 120 total points
ID: 1360594
Hello Keithcsl

I know that you can trap when the user clicks on a scrollbar by trapping WM_VSCROLL as mentioned above. Another viable alternative would be to check the x, y coordinates of the mousepoint at the time and check it agaist the Rect of the scrollbar (I have seen that somewhere but cannot recreate it quickly). So, my suggestion is to disable it as per the following. I have not tried compiling this :-).

In order to remove the vertical scrollbar from a TListBox component,  you must override its Paint method.  Inside the Paint method you must call the SetScrollRange API procedure to set the min and max scroll values to zero (this disables the scrollbar), and then call the inherited Paint.  The code below is a unit containing a new component called TNoVertScrollListBox that may do this :-).  You can copy the code into a file called NEWLISTBOX.PAS, and add it to the component library as a custom component.

unit NewListBox;

interface

uses
  WinTypes, WinProcs, Classes, stdctrls;

type
  TNoVertScrollListBox = class(TListBox)
  protected
    procedure Paint; override;

  end;

procedure Register;

implementation

procedure TNoVertScrollListBox.Paint;
begin
  SetScrollRange(Self.Handle, SB_VERT, 0, 0, False);

Regards all  inherited Paint;
end;

procedure Register;
begin
  RegisterComponents('[the page you want this control to appear on', [TNoVertScrollListBox]);
end;
end.

This code comes from a Borland TI with some modifications. If it compiles and works :-) then great, otherwise... you'll have to keep looking!

Regards,

Edo
0
 
LVL 1

Author Comment

by:keithcsl
ID: 1360595
Hi there

great stuff. i have not tried the code but i know which way to go.

Thanx
Keith
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

715 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