void MyButtonClicked() { // Do something when the button is clicked } CButton myButton; myButton.setOnClickListener(MyButtonClicked);
CButton myButton; myButton.setOnClickListener([]() { // Do something when the button is clicked });In this example, an anonymous function is defined as the callback for the button click event. This function will get called when the button is clicked and will perform some action. The setOnClickListener() method is part of the MFC library, specifically the CButton class.