Here is another suggestion. In the App variable, add the AFX_MODULE_STATE * variable named m_pModuleState and initialize it at the end of the InitInstance function,
m_pModuleState = AfxGetModuleState();
Change the callback function to set the state of the application before opening the dialog box, and then set the initial state before exiting the function
void callback() {
And save your plugin as it was in your example
extern "C" void GS_EXTERNAL_ENTRY plugin_main(TFunc func) { AFX_MANAGE_STATE(AfxGetStaticModuleState( )); func(); CDialog1 dlg; dlg.DoModal(); }
Thus, you should call AFX_MANAGE_STATE in your plugins, but when any of the plugins makes a callback function call, you must set the state of the application so that it can find good dialog resources and perform state-dependent functions
source share