简体   繁体   中英

Can I use WPF in win32 application?

Our company has a software in Alaska Xbase++. I want to modernize the GUI with WPF, without rewriting the software in C#. In this Alaska Xbase++ language, I have the ability to call C/C++ functions. I beleive, it is possible to create hybrid DLL, which has managed code, yet callable from unmanaged language, so doing a 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). In this Alaska Xbase++ language I would call this wrapper DLL to create WPF window and controls in my Application.

For example: -WpfWrapper.DLL In C# DLL (or application which listens data from Xbase++ app):

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

C# DLL doing the "WPF things".

-In Alaska Xbase++ language I have a main window. But I want to modernize the GUI, I want to create some WPF window in that old Win32 app, so I call the 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? I beleive it does, either via some wrapper DLL or via some wrapper application.

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. I have the HWND of my main window, I beleive it is neccesary.

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. You shouldn't try to build a GUI application by calling into C# from some obscure programming environment. You should try to wrap your business logic, implemented in an obscure programming environment, in a DLL and call into that from C#.

Does Xbase++ expose a C interface?

If so make a custom DLL that calls your Xbase++ code and DllImport that DLL into a WPF application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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