我在一个工程(例如CTEST1)中新建一个对话框资源,ID为IDD_DIALOG_TEST
在另一个工程(例如CTEST2)中手动创建一个该对话框的类,在类的构造函数中,写下如下语句:
class CTestDlg : public CDialog  
{
public:
CTestDlg(CWnd* pParent = NULL);   // standard constructor
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_DIALOG_TEST };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA...
}
并且在resource.h中加入代码#define IDD_DIALOG_TEST  200但是编译的时候,系统仍然提示错误信息如下:
testdlg.h(18) : error C2065: 'IDD_DIALOG_TEST' : undeclared identifier
testdlg.h(18) :error C2057: expected constant expression不知道为什么,我该如何解决?万分感谢!

解决方案 »

  1.   

    你为什么要这样做呢?
    你可以在 CTEST1 中 自动创建一个该对话框的类 CTestDlg,然后导入到CTEST2 中。
    方法:
    在旧工程中(你的CTEST1)classview视图的相应类(你的CTestDlg)上右击,然后,选择Add to Gallery,这样就创建了相应的.ogx。再在新工程中(你的CTEST2)点Add to Preject加入刚才生成的.ogx,这样连同资源和类都可以了。
      

  2.   

    testdlg.cpp
    加上以下代码...
    #include "resource.h"
    #include "testdlg.h"
      

  3.   

    因为那个.RC文件中没有对话框数据,把那个对话框模板COPY到这个工程中来应该行的