CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Create ListBox,

  1. #1
    Join Date
    Sep 2007
    Posts
    24

    Unhappy Create ListBox,

    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

  2. #2
    Join Date
    Jun 2005
    Posts
    1,255

    Smile Re: Create ListBox,

    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:
    Code:
      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);

  3. #3
    Join Date
    Sep 2007
    Posts
    24

    Re: Create ListBox,

    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);

  4. #4
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Create ListBox,

    Define didn't work. Compilation error? Runtime error?
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  5. #5
    Join Date
    Sep 2007
    Posts
    24

    Re: Create ListBox,

    Quote Originally Posted by Marc G
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured