Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listbox without MFC and COM 2

Status
Not open for further replies.

david71

Programmer
Aug 6, 2001
14
NL
Hi,

I would like a listbox with multiple colums, for example 1 column for name, and one column for address. I would like to sort this according column 'name' or according column 'address'. Who can give me some hints to do it without MFC and COM

Thank you and with kind regards,

David Reuvekamp
dreuvekamp@hotmail.com

My face is at the moment: :-(
I would like to have it so: :)
 
use style LBS_MULTICOLUMN John Fill
1c.bmp


ivfmd@mail.md
 
1.If you want to have the list box appear from the moment that your dialog will appear you add a listbox from design time and you will manipulate it through it's HWND (you can get one with:

GetDlgItem(hDlg,your_resource_identifier))
(you might need MAKEINTRESOURCE macro for resourceIDs conversions).

The with this HWND you can send messages (with SendMessage) like LB_ADDSTRING to add a new element. Check all posible LB_ messages from MSDN, add choose what you need.

If you will have to create it dinamically you wiil have to create it with Create window and specify some flags. One of the is indeed LBS_MULTICOLUMN as JohnFill says.
To see exactly what you need open your .rc file in a text editor and see what the resource designers add when you put a list box on the dioalog.

Hope this helps,

s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
hey BurtanI

didn't know, that items can be controlled like this. but why don't you just use a CList object and link it with DDX_Control? ain't that easier?

copton
 
-thereisnospoon

Of course it is easyer but david71 wanted no MFC involved.

This is the way controls are done in SDK programs. A lot more complicated but your code will be a little more faster and won't depend on MFC42.(I don't know if you need a separate liceence for it.)

Easier is not always the best way to do it. (Of course, we got to keep thinks as simple as we can.)
s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Hi, I have made a listbox. I used GetDlgItem. With the HWND I send messages like LB_ADDSTRING to add a new element. And this works!!. But, I cannot create columns with columnheaders like Name, Address, City.
It isn't possible (i think) to use LBS_MULTICOLUMNS, because this is used to divide a range to multiple columns, but in my case I have differt columns.

David

When I am in trouble there is always a way out. But who is the door ??
 
Normally the listbox control is not design to allow header names. You would need a control of type "List Control".
This is a window of class "SysListView32" with default styles WS_BORDER | WS_TABSTOP.
I do know know what messages can be sent to this type of window.

There are many workaround to this but all of them are pretty complicated:

1. Create an OwnDraw ListBox for you and for the first line you add you can color it with whatever color you want (usually RGB(192,192,192)).

2. Add a List Control and Send Messages to it. I don't know if you can find something in the SDK samples for MSDN but you may take a look.

You may look for some free code for both the solution on and to others free C++ code sites.

Hope this helps, s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top