Home > Software engineering >  MFC how to set up a button click response function return values
MFC how to set up a button click response function return values

Time:10-01

MFC interface editing interface double click on the button to add the response function of the default is a void return type, I need to return a Boolean value, how to change? I tried to manually modify the Dlg. H file and CPP file function definitions and declarations to BOOL type, but the compile-time BEGIN_MESSAGE_MAP and END_MESSAGE_MAP errors

The error C2440: "static_cast" : from "int (__thiscall CBPDlg: : *) (void)" into "AFX_PMSG 1 & gt;" From the base type to a derived type coercion dynamic_cast or static_cast

To solve the

CodePudding user response:

If it is a reflection of message, can try ON_CONTROL_REFLECT_EX
The parent class try reloading OnCommand processing directly

CodePudding user response:

The processing function of a button, return void itself, you return a BOOL is for who? The building Lord meaning in where?

CodePudding user response:

Encapsulates a BOOL type function and type a Boolean variable,
BOOL type functions on click inside the void, the return value to the BOOL type variable,
Then take the BOOL variables involved in operation,

As he puts upstairs a BOOL button function is no need to return a BOOL value,

CodePudding user response:

You should not modify the return value, but by the data in a different way

CodePudding user response:

To help the top
Event the return value is a specific meaning

CodePudding user response:

Add a BOOL m_bVar;
Back in the variable,
  • Related