QA: How to fix when the class wizard says 'Parsing error: Expected "afx_msg".'?
Vassili Philippov (vasja@spbteam.com), January 03, 2002.
Question
I have just created a new application using "WCE Pocket PC MFC AppWizard (exe)" template,
opened the class wizard and got the following error message: 'Parsing error: Expected "afx_msg".'.
How can I fix it?
Answer
You will see the following error message:
That is because standard template generates wrong code. You have to correct it and the
class wizard will work OK.
Change generated code
In MainFrm.h file you will find the following code:
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnCreateDocList(DLNHDR* pNotifyStruct, LRESULT* result);
LPTSTR MakeString(UINT stringID);
LPTSTR m_ToolTipsTable[NUM_TOOL_TIPS];
afx_msg void OnDestroy();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
You have to move 2 lines that starts with LPTSTR from the AFX_MSG
section. You code should be:
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnCreateDocList(DLNHDR* pNotifyStruct, LRESULT* result);
afx_msg void OnDestroy();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
LPTSTR MakeString(UINT stringID);
LPTSTR m_ToolTipsTable[NUM_TOOL_TIPS];
DECLARE_MESSAGE_MAP()
After that the class wizard will work. It seems like a bug in the project template.
Related resources:
-
http://www.pocketpcdn.com/sections/evc.html
Section: eMbedded Visual C++
-
http://www.pocketpcdn.com/articles/mfc_command_line.html
QA: How can I handle command line parameters in MFC based application?
-
http://www.pocketpcdn.com/articles/wce_prefix.html
QA: Why does MFC adds "WCE_" prefix to my classes?
-
http://www.pocketpcdn.com/articles/mfcbuttonbug.html
QA: Why doesn't my CButton work right?