Solved

Win32 API ListBox Control

Posted on 2007-11-15
9
5,519 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
  • 5
  • 4
9 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
They will say that Win98 and Win2000 are totally deprecated. ;)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

743 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

17 Experts available now in Live!

Get 1:1 Help Now