#define MYEDIT 2343
..................
CEdit*  tempEdit ; tempEdit=new CEdit();
ASSERT_VALID(tempEdit);
if(tempEdit->Create(ES_RIGHT|WS_VISIBLE|WS_CHILD,CRect(0,0,30,50),this,MYEDIT)==0)
    MessageBox("creat false");
..................结果总是报告出错

解决方案 »

  1.   

    如果在构造函数里做THIS是NULL
    会出错
    如果不在构造函数:是可以的
      

  2.   

    GetLastError()?返回什么!CEdit* pEdit = new CEdit;
       pEdit->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, CRect(10, 10, 100, 100), this, 1);
      

  3.   

    fingerfox兄,我不是在构造函数里写的呀,是自己定义的一个函数。
    真烦,太奇怪了
      

  4.   

    唯一的理由是MYEDIT有问题了,要不就是你的VC这几天吃坏了肚子,生病了
      

  5.   

    //////////////.h文件#define MYBUTTON 233class CRequestInput : public CDialog
    {
    // Construction
    public:
    CEdit* tempEdit;
    CButton* tempButton;
    bool m_fnInitiatInputFrame();           ///在此函数中加入生成控件的代码
    CRequestInput(CWnd* pParent = NULL);   // standard constructor// Dialog Data
    //{{AFX_DATA(CRequestInput)
    enum { IDD = IDD_INPUTREQUEST };
    // NOTE: the ClassWizard will add data members here
    //}}AFX_DATA
    // Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CRequestInput)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    //}}AFX_VIRTUAL// Implementation
    protected: // Generated message map functions
    //{{AFX_MSG(CRequestInput)
    // NOTE: the ClassWizard will add member functions here
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };//{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_REQUESTINPUT_H__D1F5BC62_DECC_4A03_8115_496695BD1492__INCLUDED_)
    /////////////////////cpp文件
    // RequestInput.cpp : implementation file
    //#include "stdafx.h"
    #include "SDIMulViewB.h"
    #include "RequestInput.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CRequestInput dialog
    CRequestInput::CRequestInput(CWnd* pParent /*=NULL*/)
    : CDialog(CRequestInput::IDD, pParent)
    {
    //{{AFX_DATA_INIT(CRequestInput)
    // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
    }
    void CRequestInput::DoDataExchange(CDataExchange* pDX)
    {
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CRequestInput)
    // NOTE: the ClassWizard will add DDX and DDV calls here
    //}}AFX_DATA_MAP
    }
    BEGIN_MESSAGE_MAP(CRequestInput, CDialog)
    //{{AFX_MSG_MAP(CRequestInput)
    // NOTE: the ClassWizard will add message map macros here
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // 我的调试代码bool CRequestInput::m_fnInitiatInputFrame()
    {
    UINT temp(1234);
    UINT temp2(1233);
    int error;
    CString str;
    //temp=1278; tempEdit=new CEdit();
    ASSERT_VALID(tempEdit);
    if(tempEdit->Create(1,CRect(0,0,30,50),this,MYBUTTON)==0)  //////不能成功
        MessageBox("false");
    tempButton=new CButton();
    ASSERT_VALID(tempButton);
    if(tempButton->Create("Button Title ",
    WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,       //////创建按钮也不能成功
    CRect(40,50,100,24),
    this,
    temp2)==0)
    MessageBox("Buttonfalse");

    return true;
    }
      

  6.   

    哪里调用m_fnInitiatInputFrame()?