Solved

horizontly scroll my headers, when I scroll my listbox using the scroll bar of the listbox

Posted on 1998-08-27
2
309 Views
Last Modified: 2010-04-15
I am adding columnar data to a listbox with fixed pitch font. Now I need to put headers to describe the columns. How do I horizontly scroll my headers, when I scroll my listbox using the scroll bar of the listbox?
0
Comment
Question by:rferrell
2 Comments
 
LVL 4

Accepted Solution

by:
emmons earned 100 total points
Comment Utility
1: This should be in the Windows section, not the C section.
2: If you add a handler for scroll message in the list box, and then send a scroll message to the header whenever the body scrolls, you should be able to keep them in synch.

0
 
LVL 8

Expert Comment

by:Answers2000
Comment Utility
My alternative solutions

1. Switch to ListView control (CListCtrl in MFC) if using 32 bit windows.  This may unfortunately avoid some significant code rewriting

or

2. Make the listbox owner draw (LBS_OWNERDRAWFIXED style) and handle the WM_DRAWITEM messages

In Draw item test if the item being drawn is the top visible line, if it is draw the headers instead of the real item.  You will loose a line from the listbox as a result of this, so insert extra dummy items.

This isn't a very good solution but can be made to work reasonably well.

or

3. Create a header control above the listbox (i.e. don't actually put the headers in the list).  When you scroll the list box, update the header control to match


#1 or #3 are the best solutions in my view, and involve the least code.  If you are in Win32 you really should consider #1 as the ListView control is much better for this kind of thing than the ListBox.


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

772 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

9 Experts available now in Live!

Get 1:1 Help Now