Featured post
How can my WPF application (w/ MVVM, Prism) interact with a monolithic MFC application? -
i'm developing wpf front end (using mvvm , prism) existing mfc application. application not going changed monolithic , lacks documentation of kind. there technologies can either bring these 2 platforms same memory space (best option) or allow them communicate in synchronously (as mfc application no means thread safe)? maintain stability, need wpf executable. i've tried attaching dll mfc application, results in extreme instability.
one option have directly host mfc in wpf, or embed wpf in mfc app outlined on wpf , win32 interoperation msdn article. specifically, check out 2 walkthroughs mentioned @ top of article.
i found embedding wpf in mfc code simpler rehosting mfc application in wpf.
hosting wpf in mfc matter of correctly using hwndsource class (if you're unafraid of using managed c++ can create nice interop layer , avoid /clr flag in mfc project altogether.)
hosting mfc application within wpf application trickier if trying rehost mdi application, allows host individual frames anywhere in wpf code (using prism regions, example.) in case, ended stripping away mdi frame management code manually.
to created own cmultidoctemplate
-derived class , override opendocumentfile()
virtual method provide own frame-opening behaviour. method manually created special cmdichildwnd
-derived frame had created overrode method interacted mdi parent frame window, , passed them underlying cframewnd
(bypassing cmdichildwnd
).
first, helper function object creates frame (m_pframeclass special cmdichildwnd-derived class described above)
hwnd createhostedframe(hwnd parent)
cframewnd* pframe = (cframewnd*)m_pframeclass->createobject(); cwnd parentwnd; parentwnd.attach(parent); pframe->loadframe(resourceid, ws_child, &parentwnd, pcontext); parentwnd.detach(); return pframe->m_hwnd;
then overridden doctemplate method (or wherever create frames)
chostedmultidoctemplate::opendocumentfile:
cdocument* pdocument = createnewdocument(); // following demo purposes. use own mechanism m_mywpfshellorsomething->pleasecreateahostedwindowusing(&createhostedframe); initialupdateframe(pframe, pdocument, bmakevisible); return pdocument;
your cmdichildwnd
-derived class want override refers mdi parent frame (search mfc cmdichildwnd
source mdiparent()
or something.)
of course final step updating cmyapp::oninitinstance() method use specialised multidoc template , child frame instead of other ones.
- Get link
- X
- Other Apps
Comments
Post a Comment