Click to See Complete Forum and Search --> : Problem manipulating selected values in ComboBox's edit control.


Peter White
May 17th, 1999, 02:25 PM
Hello,

I am trying to create a ComboBox control which allows me to manipulate the text of the selection value before it is displayed. For example, if someone selects Dog, 'Dog' should appear in the edit control. Eventually, users will be able to create expressions like: 'field1' - 'field2'. Below is the code that I am using unsuccessfully:


void ZSExprCombo::PreSubclassWindow()
{
m_xEdit.SubclassDlgItem(1001, this);
CComboBox::PreSubclassWindow();
}

void ZSExprCombo::OnSelchange()
{
// TODO: Add your control notification handler code here
int index = GetCurSel();

if(index != CB_ERR)
{
CString tmpStr, label;
GetLBText(index, tmpStr);
label.Format("'%s'", tmpStr);
m_xEdit.SetWindowText(label);
AfxMessageBox("Waiting...");
}
}




The text placed in the combo box's edit control is correct while the "Waiting..." message box is being displayed but it replaced with the exact text from the combo box selection after the message box is dismissed. Is it possible to achieve my desired functionality without creating an owner-drawn ComboBox? I know this is probably a fairly simple solution if you know what you're doing, but I've tried a few things and I don't have a clue. I would really appreciate it if anyone could point me in the right direction!

Thanks!

Peter