在VC ++中使用C#GUI

编程入门 行业动态 更新时间:2024-10-13 00:33:22
本文介绍了在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

本文发布于:2023-11-12 11:04:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581310.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:VC   GUI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!