Solved

Win32 API ListBox Control

Posted on 2007-11-15
9
5,540 Views
Last Modified: 2013-12-14
I need a listbox control that has multiple, variable width columns.  MSDN's documentation shows that the listbox control has a LBS_MULTICOLUMN style flag.  It even has messages you can send to the control to size the columns.  But nowhere in the documentation do I see how to specify the number of columns, or even how to address a specific column to either size it or get its data.  I'd be willing to accept having to do it on a row-by-row basis, but I don't even see documentation on how to do that.  All I see are basic LBS_ADDSTRING and LBS_GETSEL messages.

How do I control a listbox with the LBS_MULTICOLUMN style?
0
Comment
Question by:cuziyq
[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
  • 5
  • 4
9 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20290251
you cannot control the MultiColumn, it is calculated (width and number of columns) using the existing items' strings. You have no chance to handle it.
The closer to what you need is an MFC owner-drawn control. Have a look to this:
http://www.codeproject.com/useritems/Multicolumn_ComboBox.asp
http://www.codeproject.com/combobox/mccombobox.asp
0
 
LVL 14

Author Comment

by:cuziyq
ID: 20290328
Any chance you know how it gets calculated?  For example, if I concatenate all the info on each line into a string with tabs in it, would it understand that?  Also, I am assuming the widths of the columns must be changed manually since there is a LB_SETCOLUMNWIDTH message.  Can the columns be of varying widths?
0
 
LVL 14

Author Comment

by:cuziyq
ID: 20290363
Also, I know that there is a ListView control available from the common controls library that is much more flexible, but the documentation says it requires XP or better to work.  I'd like to make this program work with Windows 2000 if I can.  Additionally, I do not want to use MFC
0
Independent Software Vendors: 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!

 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20290446
I don't know why I am assuming you needed a multicolumn combobox.
LB_SETCOLUMNWIDTH fixes the column width in a multicolumn list for all columns, cannot set them individually.

>> I know that there is a ListView control available from the common controls library that is much more flexible, but the documentation says it requires XP or better to work
That't not true, I have worked with listview controls since Win98 (I think it works with Win95 too). But working without MFC or other equivalent library is a pain.


0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20290462
Have a look to this article about using listview control with pure WinAPI:
http://www.codeproject.com/listctrl/listview.asp
0
 
LVL 14

Author Comment

by:cuziyq
ID: 20290501
According to MSDN Documentation:

"ComCtl32.dll version 6, delivered with Microsoft Windows XP and later versions of the operating system, implements list-view features."  http://msdn2.microsoft.com/en-us/library/bb774735.aspx

Is this not correct?  Or is it something that MFC "faked" until they finally decided to include it in the API for windows XP?
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 250 total points
ID: 20290668
as far as I remember (there are almost 10 years!!!) I could use Listview with VS 6.0, have a look to this antique question (1999) talking about Listview, several years before XP:
http://www.experts-exchange.com/Programming/System/Windows__Programming/Q_10156028.html
0
 
LVL 14

Author Comment

by:cuziyq
ID: 20290832
You know what, Jaime.  You are totally right.  That line in the MSDN documentation if a flat out lie.  Looking at the documentation for the individual LVM_*messages, most of them say Win95!  I think I am gonna post a complaint to the poor M$ schlub that but that line in there.

Thanks a lot for your help.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20290912
They will say that Win98 and Win2000 are totally deprecated. ;)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Just about everyone has an old PC laying around.  Ask anyone in the IT industry, whether they are a professional or play in it as a hobby.  From outdated Desktops to cheap "throwaway" laptops, they are all around and not as hard to "fix up" as you m…
Windows 7 does not have the best desktop search built in. This is something Windows 7 users have struggled with. You type something in, and your search results don’t always match what you are looking for, or it doesn’t actually work at all. There ar…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

733 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