?
Solved

Win32 API ListBox Control

Posted on 2007-11-15
9
Medium Priority
?
5,561 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

752 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