TCHAR EditC[] = "0123456789";
HWND E;
E=FindWindow(NULL,"IDC_EDIT2");
SetWindowText(E,X);为什么没有用 不知道哪里错了先谢谢了

解决方案 »

  1.   

    E=FindWindow(NULL,"IDC_EDIT2");这句是成功的吗?
    看一下取得的句柄是不是正确的??
    应该是不成功的吧,如果是对话框的话,直接用GetDlgItem 来取就行了.
      

  2.   


    用这个 API 函数获得编辑框的句柄:HWND GetDlgItem(
      HWND hDlg,       // handle of dialog box
      int nIDDlgItem   // identifier of control
    );
      

  3.   

    直接用cwnd的getdlgitem函数不就可以了阿
      

  4.   

    1.使用LS的两种方法1)判断是否找到,如果找到,再处理。
    2)TCHAR EditC[] = "0123456789";
    CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT2);
    pEdit->SetWindowText(EditC);
    2.如果就在同一个对话框中,先定义一个字符串变量(关联到IDC_EDIT2),直接使用UpdateData(FALSE)
      

  5.   

    The FindWindow function retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. This function does not perform a case-sensitive search.
      

  6.   

    FindWindow不是这么用的!!
    FindWindow是用来查找一个top-level(顶层)窗口的,查找的根据就是窗口类名和窗口的名称
    它并不能查找字窗口。
    像你的编辑框属于(可能是对话框的,看你的情况了)子窗口,FindWindow是找不到他的
    要获取编辑框的内容,方法很多,比如关联一个变量,或者直接用指向编辑框的指针
    如:
    CEdit* pEdt = ( CEdit* )GetDlgItem( IDC_EDIT2 );
    CString str = _T("gggg");
    pEdt->SetWindowText( str );str就是编辑框IDC_EDIT2的值了
      

  7.   

    干吗这么麻烦
    cstring msg="0123456789";
    SetDlgItemText(idc_edit,msg)