c++ - Can't create modal dialog from MFC DLL -


i'm trying launch modal dialog dll loaded mfc application. i'm using vs2010 , both exe , dll use mfc in static library.

i call domodal() in dll launch dialog, parent being cwnd* pointing main window mfc app. dialog resource in dll.

this leads mfc library function cwnd::createdlgindirect, has debug check:

#ifdef _debug     if ( afxgetapp()->iskindof( runtime_class( colecontrolmodule ) ) )     {         trace(traceappmsg, 0, "warning: creating dialog within colecontrolmodule application not supported scenario.\n");     } #endif 

afxgetapp() returns null code in debug check fails. if compile in release, dialog appears, doesn't seem work (all fields empty though set defaults, button's don't appear).

i've tried adding afx_manage_state(afxgetstaticmodulestate()); top of function launches dialog, , doesn't make difference.

what missing?

edit: here's code use call dialog.

hmodule oldresmod = afxgetresourcehandle();  afx_manage_state(afxgetstaticmodulestate()); afxsetresourcehandle(getthismodule());  cwnd wndparent; wndparent.attach(parent);  cexportoptionsdlg dlg(&wndparent); dlg.project_name = project->getname();  if (dlg.domodal() != idok) {     wndparent.detach();     afxsetresourcehandle(oldresmod);     return false;       // cancelled }  // ... (get data dialog members) ...  wndparent.detach(); afxsetresourcehandle(oldresmod); return true;            // ok 

check you've created cwinapp somewhere in current module (dll/exe).

every module should have one, , one, cwinapp object. typically, make cwinapp object global variable such created , destroyed when module loaded , unloaded, respectively.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

c# - SharpSVN - How to get the previous revision? -

php cli reading files and how to fix it? -