Archived

This topic is now archived and is closed to further replies.

ADnova

Combo Box Problems

Recommended Posts

Hello... I''ve just started testing some Windows programming, using the Win32 API (no MFC). I added a simple dialog box resource to my program, with a few static text fields and two combo boxes (dropdown list style). I used the "Data" property to populate the combo boxes, but when I run the program the options in "Data" do not dislpay. For one combo box, the entries are (seperated by semicolons as help suggests): COM1;COM2;COM3;COM4; They appear if I use the "test" button on the toolbar in the resource editor, but again, not when running the program. I''ve made sure that the drop-down area is large enough to display all the members. Any ideas on why they might not be displaying when running the actual program? Thank you for any help.

Share this post


Link to post
Share on other sites
Actually no, I''ve never gotten the data property in the resource editor to work. But, I think it is better to populate the combo box programmatically. When handling INITDIALOG message, send the combo box a message:
SendDlgItemMessage(dlg, IDC_MYCOMBO, CB_ADDSTRING, 0, (LPARAM)"String to add");


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
just for clarification purposes, here''s what msdn has to say about the subject at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcresed/html/vcurfaddingdatatocomboboxcontrol.asp :

Note You cannot add values to Win32 projects using this procedure (the Data property is grayed out for Win32 projects). Because Win32 projects do not have libraries that add this capability, you must add values to a combo box with a Win32 project programmatically.


grayed out? i guess maybe they fixed it (finally!) in .NET.

Share this post


Link to post
Share on other sites
Excellent, it works now.
Thank you very much.

Adding values to the combo box programmatically works great. I had searched on MSDN first, and found the same page as AP.
The Data property was not grayed out though, although it still didn''t work. I''m using Visual C++ .NET if it makes any difference.

Anyway, thanks again.

Share this post


Link to post
Share on other sites