visual-c++visual-studio-2022eventhandler

Visual Studio 2022 (C++) "Add Event Handler..." generating bad names


I am working on an MFC application with a Ribbon Bar and am experiencing difficulty adding event handlers for new controls from the Ribbon Designer. This was working fine the last time I edited the Ribbon roughly 2 months ago. For instance, adding a new button ("Test Function") I change the resource ID to "ID_BUTTON_TESTFUNC" then right click the button and select "Add Event Handler...". The dialog comes up with a Function Name "On18" rather than "OnButtonTestfunc" and adds a message map and function that don't respond to the button.

    BEGIN_MESSAGE_MAP(CMFCApplication2View, CView)
    // Standard printing commands
    ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
    ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
    ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CMFCApplication2View::OnFilePrintPreview)
    ON_WM_CONTEXTMENU()
    ON_WM_RBUTTONUP()
    ON_COMMAND(18, &CMFCApplication2View::On18)
    ...

    void CMFCApplication2View::On18()
    {
    
    }

I have tried the following, expecting (hoping) VS would return to normal behavior:

  1. The same process on 2 computers with the same results
  2. Updating Visual Studio to 17.4.4 (from 17.4.3)
  3. Repairing Visual Studio
  4. Creating a new blank MFC application - same results
  5. In Account Options: UNchecking "Syncronize Visual Studio settings across devices and installs..."
  6. Clearing all Visual Studio settings (Tools, Import Export Settings, Reset all settings)
  7. Changed IDE Tools menu -> Options -> Text Editor -> C/C++ -> Advanced -> Rescan Solution Interval = 0 per Alen Wesker post on: Can't add event handler in visual studio 2010 (mfc project)

Manually adding the message map entry, function declaration and function definition works and responds to the button press: MFCApplication2View.h:

    afx_msg void OnButtonTestfunc();

MFCApplication2View.cpp:

    ON_COMMAND(ID_BUTTON_TESTFUNC, &CMFCApplication2View::OnButtonTestfunc)

    ...

    void CMFCApplication2View::OnButtonTestfunc()
    {
       //my code here
    }

But I am concerned about what else might be corrupted in VS. Any thoughts would be very welcome.


Solution

  • Microsoft indicates that this is an issue and had been previously fixed in version 17.5 Preview 2. See: https://developercommunity.visualstudio.com/t/MFC-Add-Event-Handler-Dialog--not-prope/10211759.