Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4075520
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:18:32+00:00 2026-05-20T17:18:32+00:00

I have a TListView component in a form. It’s quite long and I want

  • 0

I have a TListView component in a form. It’s quite long and I want user to able scroll it, if mouse is over the component and wheel is scrolled. I do not find any OnMouseWheel, OnMouseWheelDown or OnMouseWheelUp event for TListView object. How can I do that?

Regards,
evilone

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:18:32+00:00Added an answer on May 20, 2026 at 5:18 pm

    Here’s my code to do this:

    type
      TMyListView = class(TListView)
      protected
        function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; override;
        function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; override;
      end;
    
    type    
      TMouseWheelDirection = (mwdUp, mwdDown);
    
    function GenericMouseWheel(Handle: HWND; Shift: TShiftState; WheelDirection: TMouseWheelDirection): Boolean;
    var
      i, ScrollCount, Direction: Integer;
      Paging: Boolean;
    begin
      Result := ModifierKeyState(Shift)=[];//only respond to un-modified wheel actions
      if Result then begin
        Paging := DWORD(Mouse.WheelScrollLines)=WHEEL_PAGESCROLL;
        ScrollCount := Mouse.WheelScrollLines;
        case WheelDirection of
        mwdUp:
          if Paging then begin
            Direction := SB_PAGEUP;
            ScrollCount := 1;
          end else begin
            Direction := SB_LINEUP;
          end;
        mwdDown:
          if Paging then begin
            Direction := SB_PAGEDOWN;
            ScrollCount := 1;
          end else begin
            Direction := SB_LINEDOWN;
          end;
        end;
        for i := 1 to ScrollCount do begin
          SendMessage(Handle, WM_VSCROLL, Direction, 0);
        end;
      end;
    end;
    
    function TMyListView.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean;
    begin
      //don't call inherited
      Result := GenericMouseWheel(Handle, Shift, mwdDown);
    end;
    
    function TMyListView.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean;
    begin
      //don't call inherited
      Result := GenericMouseWheel(Handle, Shift, mwdUp);
    end;
    

    GenericMouseWheel is quite nifty. It works for any control with a vertical scroll bar. I use it with tree views, list views, list boxes, memos, rich edits, etc.

    You’ll be missing my ModifierKeyState routine but you can substitute your own method for checking that the wheel event is not modified. The reason you want to do this is the, for example, CTRL+mouse wheel means zoom rather than scroll.

    For what it’s worth, it looks like this:

    type
      TModifierKey = ssShift..ssCtrl;
      TModifierKeyState = set of TModifierKey;
    
    function ModifierKeyState(Shift: TShiftState): TModifierKeyState;
    const
      AllModifierKeys = [low(TModifierKey)..high(TModifierKey)];
    begin
      Result := AllModifierKeys*Shift;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TListView and TPopupMenu, and I want to show a context menu
I want to design one simple form with Microsoft Visual Studio, I have one
basically I want to encapsulate a simple component from code that I already have.
Let's say you have a form with a component that displays data from a
I have two forms using a ListView component. In the first form it works
In jQueryMobile, I have written a data-role=listview component and I want to filter the
I'm working with TListView and I have successfully populated each item's caption and first
I have listview control.There is an option to remove selected items.After the user removes
I have listview having customized some textview and one imageview. When I long click
I have ListView in my project which has ListItems as in the form of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.