Solved

Win32 API ListBox Control

Posted on 2007-11-15
9
5,547 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
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!

 
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

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!

Question has a verified solution.

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

As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
Sometimes a user will call me frantically, explaining that something has gone wrong and they have tried everything (read - they have messed it up more and now need someone to clean up) and it still does no good, can I help them?!  Usually the standa…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

705 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