Solved

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

Posted on 1998-08-27
2
318 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
[X]
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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

696 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