ComboBox Problem
sundar -- sundar@pacbell.net Friday, December 20, 1996 Environment: Win3.1,VC++1.52,MFC I have a drop-down combo in a dialog. In the drop-down combobox are a series of strings (entered using CComboBox.AddString()). Associated with these strings are some integer values (using the SetItemData(...) function) , which do not correspond directly to the indices but are some random values. My requirement is that ,when ever the user selects an item from the list box of the drop down comboBox, then the Edit box (of the drop down combo) should display the attached item value and not the selected string. I tried Subclassing the ComboBox and trapping the ComboBox CBN_CLOSEUP message. Then I retrieve the value associated with the selected string using the GetItemData(). I tried convert the data received into a text string and use the commands to set it in the Edit Window of the comboBox (for eg. SetWindowText()). However, this does'nt seem to help. Is this the way to do it or is there some other better method ? Any suggestions would be of help Thanks in advance, Sundar
Rail J. Rogut -- railro@earthlink.net Saturday, December 21, 1996 sundar wrote: > > Environment: Win3.1,VC++1.52,MFC > > I have a drop-down combo in a dialog. In the drop-down combobox are a > series of strings (entered using CComboBox.AddString()). Associated with > these strings are some integer values (using the SetItemData(...) > function) , which do not correspond directly to the indices but are some > random values. > My requirement is that ,when ever the user selects an item from > the list box of the drop down comboBox, then the Edit box (of the drop > down combo) should display the attached item value and not the selected > string. > I tried Subclassing the ComboBox and trapping the ComboBox > CBN_CLOSEUP message. Then I retrieve the value associated with the > selected string using the GetItemData(). I tried convert the data > received into a text string and use the commands to set it in > the Edit Window of the comboBox (for eg. SetWindowText()). However, this > does'nt seem to help. Is this the way to do it or is there some other > better method ? > > Any suggestions would be of help > Thanks in advance, > Sundar Wouldn't it be better to use a list box and a separate edit control - then fill the edit control with the return of GetItemDataPtr(). Rail Oceanway Recording railro@earthlink.net
Syed -- sxs296@psu.edu Saturday, January 04, 1997 At 02:00 PM 12/20/96 -0800, you wrote: >Environment: Win3.1,VC++1.52,MFC > > I have a drop-down combo in a dialog. In the drop-down combobox are a >series of strings (entered using CComboBox.AddString()). Associated with >these strings are some integer values (using the SetItemData(...) >function) , which do not correspond directly to the indices but are some >random values. > My requirement is that ,when ever the user selects an item from >the list box of the drop down comboBox, then the Edit box (of the drop >down combo) should display the attached item value and not the selected >string. I know that this does not answer your question directly, but did you know that a combo box is composed of a list box and an edit control.? Therefore, you might need to trap the notification sent by the edit control and tailor it to what you really want to do. Good luck!
| Вернуться в корень Архива |