# include <afxwin.h>
class MyFrameWindow : public CFrameWnd
{
public :
 afx_msg void onPaint()
 {
  CPaintDC paintDC ( this);
  paintDC.TextOutW (0,0,"this is my first progress");
 }
 DECLARE_MESSAGE_MAP ()
};BEGIN_MESSAGE_MAP (MyFrameWindow ,CFromeWnd )
 ON_WM_PAINT ()
END_MESSAGE_MAP ()class HelloApp : public CWinApp
{
public :
 helloApp ()
  : CWinApp ("hello Word !")
 {}
  BOOL InitInstance ()
  {
   CFrameWnd * MyFrame =new MyFrameWindow;
   m_pMainWnd =MyFrame;
   MyFrame->Create (NULL,(LPCTSTR)"hello world ");
   MyFrame->ShowWindow (SW_SHOW);
   return TRUE;
  }
}helloWorld;
//fatal error C1189: #error :  Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
这个程序我是照课本打的,哪里有错?怎么改? 

解决方案 »

  1.   

    如果加上#define _AFXDLL
    就变成error C2146: 语法错误 : 缺少“;”(在标识符“TheBaseClass”的前面)
    1>c:\users\you\desktop\程序\11\11\1221.cpp(14) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>c:\users\you\desktop\程序\11\11\1221.cpp(14) : error C2065: “TheBaseClass”: 未声明的标识符
    1>c:\users\you\desktop\程序\11\11\1221.cpp(16) : error C2653: “TheBaseClass”: 不是类或命名空间名称
    1>c:\users\you\desktop\程序\11\11\1221.cpp(22) : error C2590: “helloApp”: 只有构造函数可以有基/成员初始值列表
    1>c:\users\you\desktop\程序\11\11\1221.cpp(23) : error C2664: “CWinApp::CWinApp(LPCTSTR)”: 不能将参数 1 从“const char [13]”转换为“LPCTSTR”
    1>        与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
      

  2.   

    那个错误说明需要共享的window库,你建立的win32默认的事windows标准库,所以需要改
    选择“项目”——》“属性”——》“配置属性”——》“常规”——》“MFC的使用”——》在共享dll中使用MFC
    接下来代码有几个地方错了,如下# include <afxwin.h>class MyFrameWindow : public CFrameWnd
    {
    public :
    afx_msg void onPaint()
    {
    CPaintDC paintDC ( this);
    paintDC.TextOutW(0,0,_T("This is my first progress"));
    }
    DECLARE_MESSAGE_MAP ()
    };//BEGIN_MESSAGE_MAP (MyFrameWindow ,CFromeWnd )
    //CFrameWnd写成了CFromeWnd,错误之一
    BEGIN_MESSAGE_MAP (MyFrameWindow ,CFrameWnd )
    ON_WM_PAINT ()
    END_MESSAGE_MAP ()class HelloApp : public CWinApp
    {
    public :
    //helloApp ()
    //构造函数写错,H是大写,错误之二也
    HelloApp()
    : CWinApp(_T("hello Word !"))
    {}
    BOOL InitInstance ()
    {
    CFrameWnd * MyFrame =new MyFrameWindow;
    m_pMainWnd =MyFrame;
    //这里不要强制转换,加上_T()宏或者L,否则可能乱码,错误之三也
    //MyFrame->Create (NULL,(LPCTSTR)"hello world ");
    MyFrame->Create (NULL,_T("Hello world "));
    MyFrame->ShowWindow (SW_SHOW);
    return TRUE;
    }
    }helloWorld;