Skip to main content
gamedev.net
🔒 Locked

Dialog Boxes

Started by omega_001 Feb 24, 2003 at 9:19 AM 1 replies 300+ views
Original Post
omega_001
omega_001
Does anyone know how to set the contents of a combo box stored in a dialog box template? I know how to set the text of an item such as an edit box (SetDlgItemText), but I cant find anything on how to set the contents of a combo box? Can anyone help? Also do you know how to retrieve information from a combox box as well? Thanks in advance, K p.s. I fully aware this isn''t an OpenGL question however some coders do use dialog boxes for configuration purposes and so trying a place like this should hopefully help.
variant
variant
Stupid Internet. I just finished a great post and it disappeared. Ok, second try.

Here is code for loading info into a combo box.


      
for(i=0;i<whatever;i++){
SendDlgItemMessage(hDlg,COMBO_ID,CB_ADDSTRING,0,(LPARAM)(LPSTR)SomeString);
SendDlgItemMessage(hDlg,COMBO_ID,CB_SETITEMDATA,i, SomeItemData);
}



You don't need to use any of the ...ITEMDATA commands, but they let you piggy back values onto your entries.

To clear the box:


      
SendDlgItemMessage(hDlg,COMBO_ID,CB_RESETCONTENT,0,0);


Also look into CB_GETCURSEL, and CB_GETITEMDATA. I think, but I'm not sure, that calling GetDlgItemText will return the text value of the currently selected item. I also believe that you need to use CB_HASSTRINGS in order to use the ITEMDATA commands correctly.


[edited by - variant on February 24, 2003 2:40:11 PM]
omega_001
omega_001
Thanks for the help.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.