Click to See Complete Forum and Search --> : Create ListBox,


rambovn
November 26th, 2007, 06:15 AM
Hallo,
Now I want to create a ListBox by using this command
hwndListBox = CreateWindow(ListBox, NULL, WS_CHILD | LBS_DISABLENOSCROLL | LBS_NOTIFY | WS_BORDER, x, 8, 70, 18, m_hwnd, NULL, g_hInst, NULL);

But then I received this error:
error C2065: 'ListBox' : undeclared identifier

I already changed ListBox to _T("ListBox") but it also didn't work, no error but no ListBox was created

Does anyone know which word is correct for my case? I am searching for many hours but I could not find it.
I do not use MFC and my Character Set is Unicode.

Thank you very much for any help

olivthill
November 26th, 2007, 06:25 AM
I don't know why it does not work for you. Maybe it would work with the name in lower case. Here is an example I have used successfully:
fname_hwnd = CreateWindow("listbox", "Foo",
WS_CHILD | WS_VISIBLE | WS_TABSTOP
| LBS_NOTIFY
| WS_VSCROLL | WS_BORDER,
rect.left, rect.top,
rect.right - rect.left,
rect.bottom - rect.top,
hwnd, (HMENU)(LSTBOX_FOONAME_ID),
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);

rambovn
November 26th, 2007, 06:44 AM
thank you very much, I don't know too, but I tried in the way you showed me, and it still didn't work :(

hwndListBox = CreateWindow(_T("listbox"), _T("foo"), WS_CHILD | LBS_DISABLENOSCROLL | LBS_NOTIFY | WS_BORDER, x, 8, 70, 18, m_hwnd, NULL, g_hInst, NULL);

Marc G
November 26th, 2007, 07:57 AM
Define didn't work. Compilation error? Runtime error?

rambovn
November 26th, 2007, 09:57 AM
Define didn't work. Compilation error? Runtime error?
I already knew what happened to my code, this was my mistake, olivthill was correct, the last time I forgot WS_VISIBLE, that's why it didn'T work.
Thank you for all of your help.