How to Create Winapi Listbox

Written by alexander gokhfeld
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Create Winapi Listbox
WinAPI interface allows users to add .NET controls in user applications. (Photodisc/Photodisc/Getty Images)

Microsoft Windows Application Programming Interface (WinAPI) allows you to use .NET form controls, including the ListBox form control for choosing options in the user applications. The ListBox control gives you the ability to present a selection of the application objects on the Windows Forms. The WinAPI functions are available through a set of the Windows Forms parameters. You simplify the adding of the application messages to the dialogue boxes by using WinAPI parameters on the .NET forms.

Skill level:


  1. 1

    Click the "Start" button in Windows and select "Microsoft Visual Studio."

  2. 2

    Click "Open" and select C++ program in which you want to create WinAPI ListBox control.

  3. 3

    Add the following code after the "public void Main()" line to create the "L" ListBox control in your program:

    private HandleRef BuildWindowCore(HandleRef hwndParent) override


    HWND handle = CreateWindowEx(0, L"LISTBOX", L

    // This is a Win32 L listbox.


    // list box height and width

    (HWND) hwndParent.Handle.ToPointer(),

    // WinAPI lparam

    return HandleRef(this, IntPtr(handle));

    // clear hwnd to free the memory

    private void DestroyWindowCore(HandleRef hwnd) override


  4. 4

    Click the "File," "Save" to add the ListBox control to your C++ program.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.