[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Problem with Rectangular slide bar on scroll bar of list box

Posted on 1999-01-11
Medium Priority
Last Modified: 2013-11-20
hello All

I have two List Boxes of type ClistBox.  One of the listboxes is just for titles while the other contains the data and a horizontal scroll bar.  I am trying to move the titles in the title listbox when the user clicks onto the scroll bar of the data listbox. The horizontal scroll bar is working when the user clicks on the arrow of the scroll bar but DOES NOT work when the user click drags the rectangular slide bar on the scroll bar.  The code is as follows:

CListBox            m_ctlTitleList;
CBrowseList            m_ctlPatientList;

The CbrowseList class code is as follows:

// brwslist.cpp : implementation file

#include "StdAfx.h"
#include "Patient.h"
#include "BrwsList.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;

// CBrowseList

       m_ctlTitle = NULL;



// CBrowseList message handlers

void CBrowseList::SetTitle( CListBox* aControl )
      m_ctlTitle = aControl;

void CBrowseList::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
      /*if (nSBCode == SB_THUMBTRACK)

      if (m_ctlTitle)                   
            if ((nSBCode == SB_THUMBPOSITION) || (nSBCode == SB_THUMBTRACK)) {
                  m_ctlTitle->SetScrollPos( SB_HORZ, nPos, TRUE );
            } else
                  m_ctlTitle->SendMessage( WM_HSCROLL, MAKEWORD(nSBCode, nPos), NULL);
/*      if ((nSBCode == SB_THUMBTRACK) || (nSBCode == SB_ENDSCROLL))
            return;            // eat it
      CListBox::OnHScroll(nSBCode, nPos, pScrollBar);

I look forward to a reply.

Best Regards

Question by:AsifMughal
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
  • 2

Expert Comment

ID: 1327500
When the ListControl receives a THUMBTRACK or THUMBPOSITION, it does not use their parameters (track position). Instead it calls GetScrollInfo with the flag set to TRACKPOS. In your case, the track pos of the real scroll bar for the second list is unchanged - that is why it does not scrolls even when receiving WM_*SCROLL messages.

You should use LVM_SCROLL messages.


Author Comment

ID: 1327501
Thanks for your reply.  I can't find any information on the GetScrollInfo and on the LVM_SCROLL message in any of the reference books. I would be grateful if you could send me some sample code or recommend any articles.

Thanks in advance



Accepted Solution

asker earned 300 total points
ID: 1327502
This is from the on-line help of VC++ 5.0 (but I think it should be avilable in any help or reference on Win32):

GetScrollInfo <Picture> <Picture> <Picture>

The GetScrollInfo function retrieves the parameters of a scroll bar, including the minimum and maximum scrolling positions, the page size, and the position of the scroll box (thumb).

BOOL GetScrollInfo(
HWND hwnd,  // handle of window with scroll bar
int fnBar, // scroll bar flag
LPSCROLLINFO lpsi // pointer to structure for scroll parameters



Identifies a scroll bar control or a window with a standard scroll bar, depending on the value of the fnBar parameter.


Specifies the type of scroll bar for which to retrieve parameters. This parameter can be one of the following values:




Retrieves the parameters for a scroll bar control. The hwnd parameter must be the handle of the scroll bar control.


Retrieves the parameters for the given window's standard horizontal scroll bar.


Retrieves the parameters for the given window's standard vertical scroll bar.


Points to a SCROLLINFO structure whose fMask member, upon entry to the function, specifies the scroll bar parameters to retrieve. Before returning, the function copies the specified parameters to the appropriate members of the structure.

The fMask member can be a combination of the following values:




Copies the scroll page to the nPage member of the SCROLLINFO structure pointed to by lpsi.


Copies the scroll position to the nPos member of the SCROLLINFO structure pointed to by lpsi.


Copies the scroll range to the nMin and nMax members of the SCROLLINFO structure pointed to by lpsi.

Return Values

If the function retrieved any values, the return value is nonzero.

If the function does not retrieve any values, the return value is zero.


The GetScrollInfo function enables applications to use 32-bit scroll positions. Although the messages that indicate scroll-bar position, WM_HSCROLL and WM_VSCROLL, provide only 16 bits of position data, the functions SetScrollInfo and GetScrollInfo provide 32 bits of scroll-bar position data. Thus, an application can call GetScrollInfo while processing either the WM_HSCROLL or WM_VSCROLL messages to obtain 32-bit scroll-bar position data.

The limitation on this technique applies to real-time scrolling of a window’s contents. An application implements real-time scrolling by processing the WM_HSCROLL or WM_VSCROLL messages that carry the SB_THUMBTRACK notification value, thereby tracking the position of the scroll box (thumb) as the user moves it. Unfortunately, there is no function to retrieve the 32-bit position scroll-box position as the user moves the scroll box. Because GetScrollInfo provides only the static position, an application can obtain only 32-bit position data before or after a scroll operation.

See Also



LVM_SCROLL <Picture> <Picture> <Picture>

The LVM_SCROLL message scrolls the content of a list view control. You can send this message explicitly or by using the ListView_Scroll macro.

wParam = (int) dx;  // amount of horizontal scrolling, in pixels or columns
lParam = (int) dy;  // amount of vertical scrolling, in pixels


Integer value that specifies the amount of horizontal scrolling.

If the view type of the list view control is icon view, small icon view, or report view, this value specifies the number of pixels to scroll. If the view type of the list view control is list view, this value specifies the number of columns to scroll.


Integer value that specifies the amount of vertical scrolling.

If the view type of the list view control is icon view, small icon view, or list view, this value specifies the number of pixels to scroll. If the view type of the list view control is report view, this value specifies the number of lines to scroll.

Return Values

Returns TRUE if successful or FALSE otherwise.

See Also



Hope this helps.



Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

649 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