Solved

Win32 API ListBox Control

Posted on 2007-11-15
9
5,535 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
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Title # Comments Views Activity
hp mini 3 66
Visual Studio 2013 and Eclipse Neon 6 48
HTTPSendRequest with WinINet delays on first call 11 32
Exchange 2007 standard - defrag (eseutul /d) 10 57
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…
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…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

839 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