Home > Software engineering >  IntelliSense: return type virtual function and rewrite the return type of "CWinThread: : InitIn
IntelliSense: return type virtual function and rewrite the return type of "CWinThread: : InitIn

Time:10-21

I use VS2012, run the MFC Windows programming examples, code like books, the code is as follows:
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-sensitive

CodePudding user response:

BOOL CMyApp: : InitInstance ()
Virtual bool InitInstance ();

BOOL and BOOL is not a type,

CodePudding user response:

refer to the second floor schlafenhamster response:
BOOL CMyApp: : InitInstance ()
Virtual bool InitInstance ();

BOOL and BOOL is not a type,
why manually enter example code, to set up using static or dynamic library, cannot use Windows standard library, also want to choose a multi-byte character set, why should specify the entry point, and take the example of don't however, such a set, can be used in the actual project?

CodePudding user response:

reference 1st floor zgl7903 response:
bool and bool is different, be case-sensitive
I run this example, I want to ask, CWinApp with CWinAppEx use anything, why I can't change the CWinApp to CWinAppEx use, thank you!

CodePudding user response:

Jianghais
reference 4 floor response:
Quote: refer to 1st floor zgl7903 response:

Bool and bool is not the same, want case-sensitive
I run this example, I want to ask, CWinApp with CWinAppEx use anything, why I can't change the CWinApp to CWinAppEx use, thank you!

Did you all get rid of? This project search CWinApp modified into CWinAppEx try ~
  • Related