|
-
April 12th, 1999, 08:40 AM
#1
How to obtain edited string from CComboBox
I've created the combobox with the style CBS_DROPDOWN. I want to achieve the functionality, where the user can type new string in the edit control of the combobox and when he presses the Enter key, the new string will be added to the combobox list. The problem is, that I don't know how to obtain the typed string. GetWindowText() doesn't work on combobox, neither the GetLBText() function, since the GetCurSel() returns -1 (the string is not in the combobox yet, so I don't have current selection yet...).
Thank you,
soso.
-
April 12th, 1999, 11:51 AM
#2
Re: How to obtain edited string from CComboBox
HI!
I think of 2 possibilities ->
a. CComboBoxEx has member function "GetEditCtrl" to retrieve it's edit control.
b. CComboBox::Copy copies the text in the edit ctrl to the clipboard, maybe you can use it from there...
Hope this helps,
Thomas
-
April 13th, 1999, 02:25 AM
#3
Re: How to obtain edited string from CComboBox
Please where can I get the class CComboBoxEx ? Never heard about it before...
Thank you,
Soso.
-
April 13th, 1999, 02:57 AM
#4
Re: How to obtain edited string from CComboBox
I've installed MSVC6.0 and there's a CComboBoxEx, so it's maybe not available if using MSVC 5.0. Nevertheless it's also for CComboBox possible to retrieve the child edit control attached to it, though, it's a bit more work to do, but I guess FindWindow() should do the work for you.
Regards, Thomas
-
April 13th, 1999, 10:00 AM
#5
Re: How to obtain edited string from CComboBox
Well, GetWindowText should work fine with your ComboBox.
The problem you may have is for sure related to something else.
GetWindowText works with all CWnd derived controls.
I tried it and am using it with many ComboBoxes with different styles and it works fine. On the other hand SetWindowText does not work with all CWnd derived classes.
Are you sure that your handling for ENTER is correct?
ex.
CString sComboTxt;
m_Combo.GetWindowText(sComboTxt);
AfxMessageBox(sComboTxt);Good Luck
Hussam
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|