Combo Box Problems

Started by
2 comments, last by ADnova 20 years, 11 months ago
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.
Advertisement
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");

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.
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.

This topic is closed to new replies.

Advertisement