adding items to a ListBox does not work

Hello all,

all I want to do is simply add a string to a list box.
When trying to add a string SendMessage() returned 0, but checking the number of list box entries (LB_GETCOUNT) said zero. The item was not added and is hence not displayed in the listbox. Has anyone an explanation for this?

I tried the following code:

HWND hwndList = GetDlgItem(hWnd, IDC_LISTBOX);
SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM) "I am a string");
int numberitems = SendMessage(hwndList, LB_GETCOUNT, 0, 0);

I use the MSVC 6. I created the list box with the built-in resource manager (by simply drag and drop).

Here is the excerpt from the generated .rc file:

CONTROL "List1",IDC_LISTBOX,"SysListView32",LVS_ALIGNLEFT |
WS_BORDER | WS_TABSTOP,69,61,191,91
[836 byte] By [EasyWriter] at [2007-11-19 19:43:50]
# 1 Re: adding items to a ListBox does not work
"SysListView32" is not a list box. It is a list control that supports different view styles (ie. Report, Small Icon, etc.). You're going to need to change the code you use to access the control by using LVM_ messages, or, change the control to a "listbox".
Mike Harnad at 2007-11-9 13:20:25 >
# 2 Re: adding items to a ListBox does not work
Hey Mike,

thanks for this hint. I changed the string from "SysListView32" to "listbox" and now it works. Thank you sooo much.

Christian
EasyWriter at 2007-11-9 13:21:26 >