开发者

Adding WPF window to Win32 application

I have a monster of a win32 applicati开发者_运维知识库on with GUI based on a mixture of MFC, WTL, user32 and a few other technologies. I need to add another top-level window and I would like to give WPF a chance.

Could you help me identify the steps necessary to host a WPF window in win32 app? Details are welcome.


I'm sorry for giving trite answer, but I can't explain it better than it is explained at MSDN: Hosting WPF Content in a Microsoft Win32 Window, Walkthrough: Hosting a WPF Clock in Win32. You may also be interested in WPF Documentation samples at MSDN Code Gallery, or alternatively look at their mind-mapped version.


Keep in mind if its a top-level window you're after (and not a window embedded within another window) you can simply create a new Window-derived WPF window from managed C++.

I.E., either 1) create a C++/CLI library that references your WPF library and call that from your unmanaged code or 2) add the /clr library setting (not recommended, due to performance implications) and add a reference to your WPF library. Then simply call:

#include <vcclr.h>

gcroot<MyWindow^> newWin = gcnew MyWindow();
newWin->Show();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜