简体   繁体   English

我可以在 win32 应用程序中使用 WPF 吗?

[英]Can I use WPF in win32 application?

Our company has a software in Alaska Xbase++.我们公司在Alaska Xbase++ 有一个软件。 I want to modernize the GUI with WPF, without rewriting the software in C#.我想用 WPF 现代化 GUI,而不用 C# 重写软件。 In this Alaska Xbase++ language, I have the ability to call C/C++ functions.在这种阿拉斯加 Xbase++ 语言中,我可以调用 C/C++ 函数。 I beleive, it is possible to create hybrid DLL, which has managed code, yet callable from unmanaged language, so doing a stdcall.我相信,可以创建混合 DLL,它具有托管代码,但可以从非托管语言调用,因此执行 stdcall。

So my plan is that I write a wrapper DLL which manages all the things to create a WPF window and controls (and eventloop, everything).所以我的计划是我编写一个包装器 DLL,它管理所有东西以创建 WPF 窗口和控件(以及事件循环,一切)。 In this Alaska Xbase++ language I would call this wrapper DLL to create WPF window and controls in my Application.在这种阿拉斯加 Xbase++ 语言中,我会调用这个包装器 DLL 在我的应用程序中创建 WPF 窗口和控件。

For example: -WpfWrapper.DLL In C# DLL (or application which listens data from Xbase++ app):例如:-WpfWrapper.DLL 在 C# DLL(或从 Xbase++ 应用程序侦听数据的应用程序)中:

Function CreateWpfWindow(title) {..}
Function CreateWpfButton(caption, x, y, parent) {..}

C# DLL doing the "WPF things". C# DLL 做“WPF 事情”。

-In Alaska Xbase++ language I have a main window. - 在阿拉斯加 Xbase++ 语言中,我有一个主窗口。 But I want to modernize the GUI, I want to create some WPF window in that old Win32 app, so I call the DLL:但是我想对 GUI 进行现代化改造,我想在那个旧的 Win32 应用程序中创建一些 WPF 窗口,所以我调用了 DLL:

nHandle=CreateWpfWindow("My WPF window in Alaska Xbase++!")
CreateWpfButton("My button", 100, 100, nHandle)

This is just my thoughts.. Maybe there is other way.这只是我的想法..也许还有其他方法。 But I wonder is it possible to integrate IN ANY WAY WPF window and controls to an old Win32 Application?但我想知道是否有可能以任何方式将 WPF 窗口和控件集成到旧的 Win32 应用程序中? I beleive it does, either via some wrapper DLL or via some wrapper application.我相信它是通过一些包装器 DLL 或通过一些包装器应用程序。

Please give me some guidance how this could work.请给我一些指导,这是如何工作的。 The created WPF window in my old app must be in focus, and above other windows.在我的旧应用程序中创建的 WPF 窗口必须在焦点上,并且高于其他窗口。 I have the HWND of my main window, I beleive it is neccesary.我有我的主窗口的 HWND,我相信这是必要的。

I don't know what "Alaska Xbase++" is but my guess is the question you are asking is the reverse of what you should try.我不知道“Alaska Xbase++”是什么,但我猜你问的问题与你应该尝试的问题相反。 You shouldn't try to build a GUI application by calling into C# from some obscure programming environment.您不应该尝试通过从一些晦涩的编程环境调用 C# 来构建 GUI 应用程序。 You should try to wrap your business logic, implemented in an obscure programming environment, in a DLL and call into that from C#.您应该尝试将在晦涩的编程环境中实现的业务逻辑包装在 DLL 中,并从 C# 调用该逻辑。

Does Xbase++ expose a C interface? Xbase++ 是否公开了 C 接口?

If so make a custom DLL that calls your Xbase++ code and DllImport that DLL into a WPF application.如果是这样,请创建一个调用 Xbase++ 代码的自定义 DLL,并将该 DLL 导入 WPF 应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM