5

I am converting a VC++6.0 project to Visual Studio 2008 (enroute to 2014). I am encountering the above error.

Here is my code snippet:

BEGIN_MESSAGE_MAP(CImportProjectDlg, CDialog)
//{{AFX_MSG_MAP(CImportProjectDlg)
ON_WM_SIZE()
ON_WM_GETMINMAXINFO()
ON_WM_SIZING()
ON_WM_PAINT()
ON_WM_NCHITTEST()
ON_BN_CLICKED(IDC_MERGE_IN, OnAdd)
ON_BN_CLICKED(IDC_MERGE_OUT, OnRemove)
ON_BN_CLICKED(IDC_IMPORTPROJECT_CLEARALL, OnClearAll)
ON_BN_CLICKED(IDC_IMPORTPROJECT_APPLY, OnApply)
ON_BN_CLICKED(IDCANCEL,OnCancel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

And the error is indicated on the ON_WM_NCHITTEST() line.

Very puzzling.

Don Golden
  • 53
  • 6

2 Answers2

6

The correct signature for OnNcHitTest handler is afx_msg LRESULT OnNcHitTest(CPoint);. You have it return UINT instead of LRESULT.

Igor Tandetnik
  • 50,461
  • 4
  • 56
  • 85
  • It is unclear to me how and where to change the UINT into LRESULT. – Don Golden Feb 24 '17 at 22:40
  • 1
    `CImportProjectDlg` has a method named `OnNcHitTest`. This method is currently defined to return `UINT`. Change it to return `LRESULT`. – Igor Tandetnik Feb 24 '17 at 23:14
  • I feel a little out of my depth.... do I change the declaration: UINT CImportProjectDlg::OnNcHitTest(CPoint point) to LRESULT. or do I change the return code to LRESULT? – Don Golden Feb 25 '17 at 00:22
  • 1
    You change the return type from `UINT` to `LRESULT`, so the declaration becomes `LRESULT CImportProjectDlg::OnNcHitTest(CPoint point)` – Igor Tandetnik Feb 25 '17 at 00:44
  • 1
    The function is likely declared in an .h file, and defined in a .cpp file. You've updated it in one place but not the other. Update both. – Igor Tandetnik Feb 25 '17 at 01:11
  • Works on Windows 10/VS2017 – jw_ Sep 17 '19 at 01:31
0

If you need to let the source code compiled both on VC6 and vs2008 (unfortunately), you may use _MSC_VER to handle it.

Full list here

#if _MSC_VER >= 1500 // For vs2008+
LRESULT
#else
UINT
#endif

CImportProjectDlg::OnNcHitTest(CPoint point)
Louis Go
  • 2,213
  • 2
  • 16
  • 29