News | Articles | Libraries | Developer Tools | Books | Forum Links | Search   
Sections:
 

QA: How to fix when the class wizard says 'Parsing error: Expected "afx_msg".'?

By Vassili Philippov, January 03, 2002.
Print version

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:
Parsing error: Expected afx_msg

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:

Discuss

Discuss this article. Here you can write your comments and read comments of other developers.
Rate this article:     Poor Excellent    
 12345 
© 2001-2005 Pocket PC Developer Network, a division of Spb Software House