void CNoteDlg::OnUpper()
{
// TODO: 在此添加命令处理程序代码
//m_Upper.SetWindowTextA(IDC_EDIT1);
CEdit * p=(CEdit*)GetDlgItem(IDC_EDIT1);
CString str;
p->SetFocus();

p->GetWindowTextA(str);
p->SetSel(0,-1);
str.MakeUpper();
p->SetWindowTextA(str);}
如何控制我用鼠标选中的区域进行大写改变啊?

解决方案 »

  1.   

    你应该在信息显示到EDIT前就做大小写转换。为何到显示后再去处理呢?
      

  2.   


    CEdit * p=(CEdit*)GetDlgItem(IDC_EDIT1);
    CString str,str1;
    int is,ie;
    p->SetFocus(); p->GetWindowTextA(str);
    p->GetSel(is,ie);
    str1 = str.Mid(is,ie-is);
    str1.MakeUpper(); str= str.Mid(0,is)+str1+str.Mid(ie,str.GetLength()); p->SetWindowTextA(str); 
    输入123abc456
    选择abc
    执行代码后输出123ABC456注:代码没有进行错误处理,请加校验代码。
      

  3.   

    void CNoteDlg::OnUpper()
    {
    // TODO: 在此添加命令处理程序代码
    //m_Upper.SetWindowTextA(IDC_EDIT1);
    CEdit * p=(CEdit*)GetDlgItem(IDC_EDIT1);
    CString str;
    //p->SetFocus();
    p->SetSel(0,-1);

    p->GetWindowTextA(str);
    str.MakeUpper();
    p->SetWindowTextA(str);} 
    这么写的意思? 那我怎么才能控制选中的区域啊   0,-1 是选中全文啊  
      

  4.   

    fengrx  你老销魂了!!!! 顶你!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!happyparrot 同样感谢你!!!!!!