在VC ++中使用C#GUI [英] Using C# GUI in VC++

查看:180
本文介绍了在VC ++中使用C#GUI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个用VC ++编写的应用程序(VS2010 - 非托管代码),但我想要丰富的UI,以便我想使用C#。所以我想用C#构建我的UI,然后在VC ++中使用它。

请告诉我是否可以使用。

我是否需要使用WPF和XAML来实现丰富的UI?

如果我使用非托管代码与托管代码的组合,我可能遇到的问题是什么?

我是否需要将非托管代码转换为托管代码,然后我可以使用C#中的代码。



Regds

解决方案

WPF肯定会为您提供更丰富的用户界面。 Winforms看起来与MFC没有什么不同。您可以轻松地使C ++代码托管C ++,从而编写可以轻松调用的桥接方法。否则你还需要把它放在一个dll中,但是使用p / invoke编写代码来从C#中调用dll,这将会更加有效。


你不能在C ++和C#之间混合UI系统。如果C ++代码中没有UI功能,可以从C#中调用它。你不能(轻松/实际)从本机C ++调用C#。



例外是C ++ / CLI,但我认为你不是在问这个问题

Hi,
I have an application written in VC++ (VS2010--unmanaged code) but I want rich UI so that I would like to use C#. So I want to built my UI using C# and then use it in VC++.
Please let me know whether it is possible to use.
Do I need to use WPF and XAML to achieve rich UI?
What could the problems that I could face if I am using combination of unmanaged code with managed code?
Do I need to convert my unmanaged code to managed code and then I can use that code from C#.

Regds

解决方案

WPF will definitely give you a richer UI. Winforms doesn't look that different to MFC. You can make your C++ code managed C++ easily enough, and thus write bridging methods you can easily call. Otherwise you'll need to still put it in a dll, but use p/invoke to write code to call the dll from C#, which will be much more work.


You can't mix the UI systems between C++ and C#. If there are no UI features in your C++ code you can call it from C#. You can not (easily/practically) call C# from native C++.

An exception to this is C++/CLI, but I don't think you are asking about that.


这篇关于在VC ++中使用C#GUI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆