I have a Visual C++ 6.0 project which I need to update and I import it to Visual Studio 2012 with no problems, however, during compilation, I get the following four errors:
Error 1 error C2440: 'static_cast' : cannot convert from 'void (__thiscall CTrendDlg::* )(int)' to 'void (__thiscall CCmdTarget::* )(UINT)' c:\users\nima\desktop\ffls_scode\trenddlg.cpp 89
Error 6 error C2440: 'static_cast' : cannot convert from 'void (__thiscall CManualDlg::* )(int)' to 'void (__thiscall CCmdTarget::* )(UINT)' c:\users\nima\desktop\ffls_scode\manualdlg.cpp 175
Error 7 error C2440: 'static_cast' : cannot convert from 'void (__thiscall CManualDlg::* )(int)' to 'void (__thiscall CCmdTarget::* )(UINT)' c:\users\nima\desktop\ffls_scode\manualdlg.cpp 177
Error 8 error C2440: 'static_cast' : cannot convert from 'void (__thiscall CManualDlg::* )(int)' to 'void (__thiscall CCmdTarget::* )(UINT)' c:\users\nima\desktop\ffls_scode\manualdlg.cpp 178
The first error is originating from the following line of code, and the rest are similar:
ON_COMMAND_RANGE(IDC_CHECK_PEN, IDC_CHECK_GRID, OnCheckButtons)
ON_COMMAND_RANGE(IDC_REF_L1, IDC_REF_L16, OnCarriagePos)
ON_COMMAND_RANGE(IDC_VALVE_L1, IDC_VALVE_L4, OnValve)
ON_COMMAND_RANGE(IDC_SAMPLE_L_A, IDC_SAMPLE_L_B, OnDetector)
Where (as an instance) OnCheckButtons
function is defined in TrendDlg.cpp
as follows:
void CTrendDlg::OnCheckButtons(int id)
{
UINT state;
RECT rect = {m_rect.left-60, m_rect.top-10, m_rect.right+40, m_rect.bottom+30};
state = ((CButton*)GetDlgItem(id))->GetState();
if ((state & 0x0003) == 1)
{
switch (id)
{
case IDC_CHECK_PEN:
m_pen = TRUE;
break;
case IDC_CHECK_LINE:
m_line = TRUE;
break;
case IDC_CHECK_BUBBLES:
m_bubble = TRUE;
break;
case IDC_CHECK_GRID:
m_grid = TRUE;
}
}
else
{
switch (id)
{
case IDC_CHECK_PEN:
m_pen = FALSE;
break;
case IDC_CHECK_LINE:
m_line = FALSE;
break;
case IDC_CHECK_BUBBLES:
m_bubble = FALSE;
break;
case IDC_CHECK_GRID:
m_grid = FALSE;
}
}
InvalidateRect(&rect);
}
my message map range is also defined as:
BEGIN_MESSAGE_MAP(CTrendDlg, CDialog)
Why is the compiler trying to cast CTrendDlg
and CManualDlg
type to CCmdTarget
type? is there a change in class structure from VC 6.00 to VS2012?
I appreciate your help.