In Add Event Handler dialog, select your dialog instead of CAboutDlg.
Or double-click the new button in Dialog Designer.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Windows 11, Visual Studio 17.13.3, C++, MFC, dialog app
Question: The most simple possible button does not work. How could I have messed up Visual Studio to cause this?
Details:
I am trying to create an MFC project with dialogs. The first set of buttons did work for a few iterations, I think, then stopped. Now the most simple button will not work.
Create a new project as MFC App with C++. I named this one MFC_Button. For application type select Dialog Based. In User Interface Features add Minimize and Maximize boxes. In Advanced Features Options disable ActiveX controls. In Generated Classes options field “Generated classes” the options are App and Dlg. As a guess Dlg is selected. (Edit, tried App, the only other option, same result) Finish.
The project is created and the dialog is displayed. From Toolbox drag a button into the dialog. I named it Show. Right click the button and select Add Event Handler. Click OK accepting all the defaults. The following code is presented with one line I added.
void CAboutDlg::OnBnClickedButton1()
{
``// TODO: Add your control notification handler code here
``int x = 1;
}
Put a breakpoint on the line int x = 1; Build, run in debug, and wait a few seconds for VS to stabilize, then click the Show button.
The expectation is that the breakpoint will be hit. It does not work. What might I have done to mess up VS and cause this?
Tried several options. Maybe that line is optimized out. Go to class CAboutDlg and under “public:” add: int x. In the constructor add: x = 0; Change the button handler to: x = 1; Debug and click the button, no response. And yes, the round red circle in the debug column is present next to: x = 1; Just in case it is line 165.
What have I done to VS? How might I fix it?
In Add Event Handler dialog, select your dialog instead of CAboutDlg.
Or double-click the new button in Dialog Designer.