我建了个编辑框,该怎样做才能通过判断在编辑框上输入的字符而在回车后弹出相应的对话框呢?
如我输入:dog,然后回车后它就弹出一个符合dog命令的窗口

解决方案 »

  1.   

    可以重载编辑框的EN_KILLFOCUS函数,写上相应的分析代码
      

  2.   

    void CTttDlg::OnKillfocusInput() 
    {
    // TODO: Add your control notification handler code here
    CString str;
             CDogDlg dlg;
    UpdateData(true);
    str = m_strInput;
             if(str == "dog")
                    dlg.DoModal();
    }
      

  3.   

    当按回车键时,默认的OK按钮会响应这个事件。所以也可以利用默认按钮的响应函数:OnOk
    {
        CString strInput;    GetDlgItem(IDC_EDIT1)->GetWindowText(strInput);
        switch(strInput)
        {
         ...
        }    CDialog::OnOK();}其中IDC_EDIT1表示你的输入框。
      

  4.   

    函数名后面忘了些括号了,不好意思。
    OnOk()
    {
    ...
    }