Solved

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

Posted on 1998-08-27
2
313 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
ID: 1252331
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
ID: 1252332
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Microsoft vcsetup.exe and vcssetup.exe 8 413
Can case within switch statement specify range of values ? 3 76
Computer slow / BSOD 10 43
Why isn't object file created? 6 42
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use structures 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.

895 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

18 Experts available now in Live!

Get 1:1 Help Now