Site Tools

MFC Version Incompatibility Problems

Summary: How to fix MFC version incompatibility problems between VS2005 and VS2010

First, you should do the following:

  1. Download the Rhino 5 64-bit (2010) Release Candidate.
  2. Install the Rhino 5 64-bit SDK.
  3. Migrate your plug-in project from Visual Studio 2005 to 2010.

We didn't actually encounter many problems, but the few we found were difficult to solve. We hope this saves you some time.


To use both VS2005 (32-bit) and VS2010 (64-bit) and MFC's CFileDialog, do the following:

  #if defined(_MFC_VER) && _MFC_VER >= 0x0A00
  //    When bVistaStyleDlg = true (the default) MFC 8 uses IFileDialog instead
  //    of GetOpenFileName() and the GetParent() function on CRhinoUiFileDialog
  //    returns NULL instead of a handle to the file dialog.  Rhino code has
  //    places that expect GetParent() to return the handle to the file dialog
  //    (like the OK to save dialog when overwriting a file).
  : CFileDialog( bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd, 0, false )
  // In older MFC, calling CRhinoUiFileDialog::GetParent() returns a handle to this file dlg window.
  : CFileDialog( bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)

int/INT_PTR changes

Several MFC classes changed members and return values from int to INT_PTR (which is better for 64-bit portability). You will likely need code like this to make it compile properly for both 32- and 64-bit.

  #if defined(_MFC_VER) && _MFC_VER >= 0x0A00
    // VC 2010 GetMenuItemCount() returns int
    int iID;
    // VC 2005 GetMenuItemCount() returns UINT
    iID = pCB->GetDlgCtrlID();
    if( (UINT_PTR)pInfo->m_arrBarID[j] == (UINT_PTR)iID)
    pInfo->m_arrBarID[j] =
  #if defined(_MFC_VER) && _MFC_VER >= 0x0A00
    // VC 2010 m_arrBarID[] element is UINT
    // VC 2005 m_arrBarID[] element is void*
developer/sdksamples/migratevs2010/compilerchanges.txt ยท Last modified: 2020/08/14 (external edit)