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

  • Home
  • SEARCH
  • 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 104283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:15:26+00:00 2026-05-11T01:15:26+00:00

I need to allow the vertical scrollbar in a multiselect listbox (VB6) however, when

  • 0

I need to allow the vertical scrollbar in a multiselect listbox (VB6) however, when the control is disabled, I can’t scroll.

I would think there is an API to allow this, but my favorite VB6 site (MVPS VB.NET) does not have a way.

I toyed with pretending it was disabled, and ignore the clicks… but to do that with VB6 code is really ugly… so if this is a solution, I need an API to ignore the clicks.

Thanks for your help.

  • 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. 2026-05-11T01:15:26+00:00Added an answer on May 11, 2026 at 1:15 am

    I came up with the following code, which hides all of the gnarly details behind a class. Basically, I implemented greg’s idea of using overlaying another scrollbar on top of the disabled list box’s scrollbar. In my code, I dynamically create another ListBox control (resized so that only its scrollbar is visible), and use its scrollbar to scroll the actual ListBox. I also specifically avoided using the Windows API (except for the call to GetSystemMetrics that I used to figure how how wide a scroll bar is on the system). The nice thing about using another ListBox’s scrollbar is that it will be themed properly (a ListBox uses the OS’s theme when it displays it’s scrollbar, but a VB.Scrollbar doesn’t, so it would look out-of-place). Another advantage of using a second ListBox to scroll the first list box is that it’s really easy to implement the scrolling logic (just set the first ListBox’s TopIndex property to the second ListBox’s TopIndex property whenever the second one is scrolled).

    I also set it up to be as low-impact as possible (you only have to call a single function in your Form_Load event to make it work).

    Usage

    1. Add CustomScrollingSupport.cls and ListBoxExtras.bas to your project.

    2. In your form’s Form_Load event, add the following line:

      AddCustomListBoxScrolling Me

      This will make every VB.ListBox on the form support scrolling even while they are disabled. If you only want to add this functionality to a select number of ListBox’s, you can call AddCustomScrollingSupport instead, passing in a specific ListBox control.

    Interesting Note

    In an older version of this code, I wasn’t calling the ZOrder method on the second listbox (the one that provides the scrollbar) to make sure it would appear on top of the first listbox. This meant the second listbox was actually behind the first listbox; the interesting thing is that the scrolling on the second ListBox still worked when the first ListBox was disabled! Apparently, when the first ListBox is disabled, any mouse and keyboard events that would have gone to that ListBox ‘bleed through’ to the second ListBox, so scrolling support still does work. I’m not sure if this is a bug or by design (I mean, you could argue that it makes sense that controls behind a disabled control would be able to receive events…). However, I found the scrolling to be slightly jerky at times, so I decided to add .ZOrder 0 to make the second listbox render on top of the first one. This has the drawback that you see the frame border for the second listbox (to the left of the scroll bar), which you wouldn’t see if it was hidden behind the first listbox, but the scrolling is smoother.


    CustomScrollingSupport.cls

    This class wraps up the logic necessary to add ‘custom scrolling support’ (for lack of a better name) to a VB.ListBox control. It should not be used directly, instead use the one of the Add* methods in the ListBoxExtras.bas module (I’ll provide the code for that module later in the post).

    Option Explicit  Private Declare Function GetSystemMetrics Lib 'user32' (ByVal nIndex As Long) As Long Private Const SM_CXVSCROLL = 2 Private Const SM_CXFRAME = 32  Private m_runningScrollers As Collection Private WithEvents m_list As VB.listbox Private WithEvents m_listScroller As VB.listbox  '--------------------------------------------------------------' ' Bind                                                         ' '                                                              ' '   Adds custom scrolling support to a ListBox control.        ' '   Specifically, it allows the ListBox to be                  ' '   scrolled even when it is disabled.                         ' '                                                              ' '   Parameters:                                                ' '                                                              ' '   + list                                                     ' '       the ListBox control to add custom scrolling support to ' '                                                              ' '   + runningScrollers                                         ' '       a Collection of CustomScrollingSupport objects. Passed ' '       in so that this object can remove itself from the list ' '       when it is terminated.                                 ' '                                                              ' '--------------------------------------------------------------'  Public Sub Bind(ByVal list As VB.listbox, runningScrollers As Collection)      Set m_list = list     Set m_runningScrollers = runningScrollers      'Create another ListBox loaded with the same number of entries as the real listbox'     Set m_listScroller = m_list.Container.Controls.Add('VB.ListBox', list.Name & '_scroller')     LoadScrollerList      Dim nScrollbarWidth As Long     nScrollbarWidth = GetSystemMetricScaled(SM_CXVSCROLL, m_list) + _                       GetSystemMetricScaled(SM_CXFRAME, m_list)      'Display the other listbox (the 'scroller'), just wide enough so that only its scrollbar is visible'     'and place it over the real listboxs scroll bar'     With m_listScroller         .Left = m_list.Left + m_list.Width - nScrollbarWidth         .Top = m_list.Top         .Height = m_list.Height         .Width = nScrollbarWidth         .Enabled = True         .Visible = True         .ZOrder 0     End With  End Sub  Private Sub m_listScroller_Scroll()     'If the master list has changed, need to reload scrollers list'     '(not ideal, but there is no ItemAdded event that we could use to keep the lists in sync)'     If m_list.ListCount <> m_listScroller.ListCount Then         LoadScrollerList     End If      'Make any scrolling done on the scroller listbox occur in the real listbox'     m_list.TopIndex = m_listScroller.TopIndex  End Sub  Private Sub Class_Terminate()      Dim scroller As CustomScrollingSupport     Dim nCurrIndex As Long      If m_runningScrollers Is Nothing Then         Exit Sub     End If      'Remove ourselves from the list of running scrollers'      For Each scroller In m_runningScrollers         nCurrIndex = nCurrIndex + 1         If scroller Is Me Then             m_runningScrollers.Remove nCurrIndex             Debug.Print m_runningScrollers.Count & ' scrollers are running'             Exit Sub         End If     Next  End Sub  Private Sub LoadScrollerList()      Dim i As Long      m_listScroller.Clear     For i = 1 To m_list.ListCount         m_listScroller.AddItem ''     Next  End Sub  Private Function GetSystemMetricScaled(ByVal nIndex As Long, ByVal ctrl As Control)     GetSystemMetricScaled = ctrl.Container.ScaleX(GetSystemMetrics(nIndex), vbPixels, ctrl.Container.ScaleMode) End Function 

    ListBoxExtras.bas

    This module contains two utility methods:

    AddCustomScrollingSupport adds custom scrolling functionality to an individual VB.ListBox control

    AddCustomListBoxScrolling adds custom scrolling functionality to every VB.ListBox control on a given Form

    Option Explicit  Public Sub AddCustomScrollingSupport(ByVal list As VB.listbox)      Static runningScrollers As New Collection      Dim newScroller As CustomScrollingSupport     Set newScroller = New CustomScrollingSupport      runningScrollers.Add newScroller     newScroller.Bind list, runningScrollers  End Sub  Public Sub AddCustomListBoxScrolling(ByVal frm As Form)      Dim ctrl As Control     For Each ctrl In frm.Controls          If TypeOf ctrl Is VB.listbox Then             AddCustomScrollingSupport ctrl         End If      Next  End Sub 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 146k
  • Answers 146k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The iPhone SDK is not exactly identical to any paricular… May 12, 2026 at 8:57 am
  • Editorial Team
    Editorial Team added an answer I don't think it's the case that 1<<32 wraps (otherwise,… May 12, 2026 at 8:57 am
  • Editorial Team
    Editorial Team added an answer Facebook does do some weird stuff - I read that… May 12, 2026 at 8:57 am

Related Questions

I'm currently working on an internal sales application for the company I work for,
I imagine this is pretty dead-simple, but somehow I haven’t been able to get
On an ASP.NET GridView, I have a field that prints a string from the
I've been using ghostscript to do pdf to image generation of a single page

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.