如题.
还有就是从一个Edit中取得一个字符串,怎么把它转换成整型?

解决方案 »

  1.   

    CRect rect(10,10,100,100);
    m_Edit.Create(ES_LEFT|ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP ,rect,this,IDC_EDIT);
    m_Edit.ShowWindow(SW_SHOW);
    CString str;
    GetDlgItemText(IDC_EDIT,str);
    int i=atoi(str);
      

  2.   

    CEdit::Create
    This method creates the Windows CE edit control and attaches it to the CEdit object.To construct a CEdit object, call the CEdit constructor, then call Create. BOOL Create( 
    DWORD dwStyle, 
    const RECT& rect, 
    CWnd* pParentWnd, 
    UINT nID ); 
    Parameters
    dwStyle 
    Specifies the style of an edit control style. Apply any combination of edit styles to the control. 
    rect 
    Specifies the size and position of an edit control. Can be a CRect object or RECT structure. 
    pParentWnd 
    Specifies the parent window of an edit control usually a CDialog. It must not be NULL. 
    nID 
    Specifies the identifier of the edit control. 
    Return Value
    Nonzero if initialization is successful; otherwise, it is zero.
      

  3.   

    create(..)CStirng str = "123";
    int i;
    atoi(str);
      

  4.   

    放在对应的父窗体下。
    CEdit *m_edit = new CEdit;m_edit->Create(ES_LEFT|ES_AUTOVSCROLL, CRect(0,0,200,200),this, 500/*自定义ID*/);最后用完就 delete m_edit; 就可以了, 是分别的三句话,放在合适位置。
    取字符串简单,
    CString str;
    m_edit->GetWindowText(str);
    int aaa = atoi(str); aaa 就是转出来的整数了。
      

  5.   

    CEdit m_wndEdit;
    m_wndEdit.Create(WS_VSCROLL|WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|ES_MULTILINE|ES_WANTRETURN,CRect(0,0,100,02),this,101);
    this为父窗口指针,101为ID号,可根据实际代码修改。
    int nTemp = atoi(m_strEdit.GetBuffer(0))
    m_strEdit为字符串
      

  6.   

    CEdit *m_pEdit;...
    In yout InitDiloag()
    ...
    #ifdef IDC_EDIT_NEW1
    #define IDC_EDIT_NEW1 10011
    #endifm_pEdit = new CEdit;
    m_pEdit->Create(SW_SHOW|SW_CHILD|SW_VISIBLE, CRect(5, 5, 15, 100), this, IDC_EDIT_NEW1);char sz[255];
    ((CEdit *)GetDlgItem(IDC_EDIT))->GetWindowText(sz, 255);int n = ::atoi(sz);
      

  7.   

    2。还有就是从一个Edit中取得一个字符串,怎么把它转换成整型?
    不要直接用atoi()函数进行转换。atoi()存在安全隐患。比如“aaa"用atoi()进行转换为0。
    用sscanf()进行转换。
      

  8.   

    1。创建edit
    CRect r(1,1,50,50);
    CEdit edit;
    edit.Create(ES_LEFT|ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP ,
                 r,this,IDC_EDIT);
    edit.ShowWindow(SW_SHOW);