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:
Click the "Start" button in Windows and select "Microsoft Visual Studio."
Click "Open" and select C++ program in which you want to create WinAPI ListBox control.
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.
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER 0, 0, 30, 70,
// list box height and width
// WinAPI lparam
return HandleRef(this, IntPtr(handle));
// clear hwnd to free the memory
private void DestroyWindowCore(HandleRef hwnd) override
Click the "File," "Save" to add the ListBox control to your C++ program.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for