GetDlgItemText()出错function does not take 2 parameters 为什么
谢谢

解决方案 »

  1.   

    UINT GetDlgItemText(          HWND hDlg,
        int nIDDlgItem,
        LPTSTR lpString,
        int nMaxCount
    );四个参数
      

  2.   

    int CWnd::GetDlgItemText(
       int nID,
       LPTSTR lpStr,
       int nMaxCount 
    ) const;
    // 三个参数int CWnd::GetDlgItemText(
       int nID,
       CString& rString 
    ) const;
    // 两个参数
    注意使用正确的参数!
      

  3.   

    int GetDlgItemText( int nID, LPTSTR lpStr, int nMaxCount ) const;int GetDlgItemText( int nID, CString& rString ) const;Return ValueSpecifies the actual number of bytes copied to the buffer, not including the terminating null character. The value is 0 if no text is copied.ParametersnIDSpecifies the integer identifier of the control whose title is to be retrieved.lpStrPoints to the buffer to receive the control’s title or text.nMaxCountSpecifies the maximum length (in bytes) of the string to be copied to lpStr. If the string is longer than nMaxCount, it is truncated.rStringA reference to a CString.ResCall this member function to retrieve the title or text associated with a control in a dialog box. The GetDlgItemText member function copies the text to the location pointed to by lpStr and returns a count of the number of bytes it copies.
      

  4.   

    int GetDlgItemText(
    int nID,//控件的ID
    LPTSTR lpStr,//用来保存buffer
    int nMaxCount//buffer的大小
     )
    const; int GetDlgItemText(
    int nID,//控件的ID
    CString& rString )//用来保存的CString变量
    const; 使用时要加上CWnd::才有用.例:void CTempDlg::OnOK() 
    {
    // TODO: Add extra validation here
    UpdateData(TRUE);
    CString szCaption;
    CWnd::GetDlgItemText(IDC_BUTTON1, szCaption);
    MessageBox(szCaption);
    }
      

  5.   

    问题没有问清楚,SetWindowText一共好几个呢,一个是API,共有四个参数,
    UINT GetDlgItemText(
      HWND hDlg,       // 对话框句柄
      int nIDDlgItem,  // 控件ID
      LPTSTR lpString, // 字串
      int nMaxCount    // 字串长
    );
    还有两个,都是CWnd的成员函数,
    int GetDlgItemText( int nID, LPTSTR lpStr, int nMaxCount ) int GetDlgItemText( int nID, CString& rString ) 
    参数和API不一样,但是含义类似