Sign in to follow this  
AckPacket

ComboBox control using win32 API (in c++)

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this