ComboBox control using win32 API (in c++)

Started by
2 comments, last by Endurion 19 years, 8 months ago
I've figured out how to draw all the standard controls using api in c++, but i can't seem to find a way to make a combo box. There are plenty of tutorials on the net that teach how to make a combo box, but all of them are oriented towards MFC or dialogs, something i'd like to stay away from since i prefer to make and draw my programs from scratch. Is there even a way to do it in API? I think i remember hearing somewhere that i might have to group an edit, a command button and a list box, but if that's true i don't really know how. Any information you could provide about a Combobox in API, the messages it works off of, and ways of retrieving/sending data with it, would be greatly appreciated. Thanx in advance -Ack Packet
Advertisement
For Win32 API stuff, MSDN is your friend.

You can create a combo box like you create any other control, using CreateWindow with the appropriate window class ("COMBOBOX") and style.

This should have all you need to know about actually using the combo box once you've created it.

You could of course, 'roll your own' combo box by hacking together a bunch of other different controls, like list boxes and edit boxes etc, but for the vast majority of cases, there really isn't any point, the basic combo box (or the extended combo box 'comboboxex') should be more than sufficient.
In short, you need to call CreateWindowEx and pass "COMBOBOX" for the lpClassName parameter.

All the documentation you need is here

EDIT: Dammit, beaten to the punch. [smile]
Everything that's in MFC is based on the WinAPI. So you can do everything with pure WinAPI.

As ComboBoxes are standard controls you can use CreateWindow with the class name "COMBOBOX".

The combo messages start with CB_xxx (CB_ADDSTRING,CB_SETCURSEL) and its notification messages with CBN_xxx.

[Edit: beaten twice, dang office meetings]

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement