Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.

I want to know if there's any way to stop C style casting in C++ for MFC needs. For example, here is the code.

C++
#include "stdafx.h"

#include "01.h"

App myApp;

BOOL App::InitInstance()
{
	m_pMainWnd = new MainWindow;

	m_pMainWnd->ShowWindow(m_nCmdShow);
	m_pMainWnd->UpdateWindow();

	return TRUE;
}

BEGIN_MESSAGE_MAP(MainWindow, CFrameWnd)  //this is not a casting
	ON_WM_CREATE()
	ON_WM_PAINT()
END_MESSAGE_MAP()

MainWindow::MainWindow()
{
	Create(NULL, _T("window"));
}

void MainWindow::OnCreate()
{

}

void MainWindow::OnPaint()
{

}


Im having a problem in the line where I commented. It's not a casting. That's how MFC begins the message map. But the compiler tries to cast the ON_WM_CREATE() into a (MainWindow, CFrameWnd). The only way, as I see, to stop this casting is insert a semicolon at the end of the BEGIN_MESSAGE_MAP line. But it would cause other problems with MFC.

So I want to know how can I prevent errors like this ? Why on earth would they implements such things that makes the compiler gone fuzzy ?

Thanks in advance.
Posted

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900