Hello. H file:
class CMyApp: public CWinApp//define a application class
{
Public:
Virtual bool InitInstance ();
};
Class CMainWindow: public CFrameWnd//define an application window class
{
Public:
CMainWindow ();
Protected:
Afx_msg void OnPaint ();
DECLARE_MESSAGE_MAP ()
};
Hello. CPP file:
# include & lt; Afxwin. H>
# include "Hello. H"
CMyApp myApp.//instantiate an application object
BOOL CMyApp: : InitInstance ()
{
M_pMainWnd=new CMainWindow;
M_pMainWnd - & gt; ShowWindow (m_nCmdShow);
M_pMainWnd - & gt; UpdateWindow ();
Return TRUE;
}
BEGIN_MESSAGE_MAP (CMainWindow CFrameWnd)
ON_WM_PAINT ()
END_MESSAGE_MAP ()
CMainWindow: : CMainWindow ()
{
Create (NULL, _T (" The Hello App!" ));
}
Void CMainWindow: : OnPaint ()
{
CPaintDC dc (this);
CRect the rect.
GetClientRect (& amp; The rect);
Dc. DrawText (_T (" Hello, MFC "), 1, & amp; The rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
Below is the error message:
Error 1 error C1189: # error: Building MFC application with/MD [d] (CRT DLL version) requires the MFC Shared DLL version. Both Please # define _AFXDLL or do not use/MD [d] c: \ program files \ Microsoft visual studio (x86) vc 11.0 \ \ atlmfc \ include \ afx 24 h
2 IntelliSense: # error command: Building MFC application with/MD [d] (CRT DLL version) requires the MFC Shared DLL version. Both Please # define _AFXDLL or do not use/MD [d] c: \ Program Files \ Microsoft Visual Studio (x86) VC 11.0 \ \ atlmfc \ include \ afx 24 h
3 IntelliSense: the declaration and "bool CMyApp: : InitInstance ()" (declared in the lines of: 4, belongs to the file: "c: \ users \ hsjiang \ documents \ visual studio 2012 \ projects \ project1 \ project1 \ Hello h") is not compatible with the c: \ users \ hsjiang \ documents \ visual studio 2012 \ projects \ project1 \ project1 \ Hello CPP 4
4 IntelliSense: return type virtual function and rewrite the return type of "CWinThread: : InitInstance" "BOOL" is neither the same nor covariance c: \ Users \ hsjiang \ Documents \ Visual Studio 2012 \ Projects \ Project1 \ Project1 \ Hello h 4
How do these errors, online etc.! Thank you friends!
CodePudding user response:
Bool and bool is not the same, want case-sensitiveCodePudding user response:
BOOL CMyApp: : InitInstance ()Virtual bool InitInstance ();
BOOL and BOOL is not a type,
CodePudding user response: