就是我在InsertString(),比如 0123
然后在我当前的这个Dlg中,增加一个按钮。这个按钮就是增加一个0
就相当于手机的拨号,   
1  2  3
4  5  6
7  8  9
*  0  #
这里每一个数字都是一个按钮。为什么当我按了0时,就会跳出0123
我想在按0时,只会出现0,而不是0123
请教,这个问题应该怎么解决?谢谢
0按钮的原代码如下:
void CSupTermDlg::OnKey0() 
{
if(m_btnKey0.m_iLMBtnDown == 1) 

CString strDigit,strTemp;
CString str;
strDigit="0";
m_ComboCallName.GetWindowText(str); 
DWORD dwSel = m_ComboCallName.GetEditSel(); 
int is = LOWORD(dwSel); 
int ie = HIWORD(dwSel);
if (is == 0 && (ie == 0))
{
UpdateData(TRUE);
int nNoBlue =  m_strComboCallName.GetLength();
if (nNoBlue>12)
{
return;
}
m_strComboCallName += strDigit;
UpdateData(FALSE);
}
else
{
str = str.Left(is) + strDigit + str.Mid(ie); 
int nYesBlue = str.GetLength();
if (nYesBlue>12)
{
return ;
}
m_ComboCallName.SetWindowText(str);  
m_ComboCallName.SetEditSel(is, ie);
}
PlaySound(TEXT("dtmf.wav"),NULL,SND_FILENAME|SND_ASYNC);
}
}

解决方案 »

  1.   

    if (is == 0 && (ie == 0))
    {
    UpdateData(TRUE);
    int nNoBlue =  m_strComboCallName.GetLength();
    if (nNoBlue>12)
    {
    return;
    }
    m_strComboCallName += strDigit;
    UpdateData(FALSE);
    }
    ->
    if (is == 0 && (ie == 0))
    {
       UpdateData(TRUE);
       int nNoBlue =  str.GetLength();
       if (nNoBlue>12)
       {
         return;
       }
       str += strDigit;
       m_ComboCallName.SetWindowText(str);
    }不要将一个组合框同里映射为两个变量,
    一个是CString m_strComboCallName,UpdateData(TRUE)来获取新值,
    一个是CComboBox m_ComboCallName,GetWindowText(LPSTR)来获取新值.