简体   繁体   English

是否可以在Gtk#窗口/小部件中托管Winforms控件?

[英]Is it possible to host a Winforms control in a Gtk# Window/Widget?

Im developing a GUI with MonoDevelop on Ubuntu, which only really supports Gtk# as GUI framework. 我在Ubuntu上使用MonoDevelop开发了一个GUI,它仅真正支持Gtk#作为GUI框架。 The thing is that I'd like to use some 3rd-party controls which are only offered as Winforms controls. 问题是我想使用一些仅作为Winforms控件提供的第三方控件。 Is there a way to host a winforms control in a Gtk# window like how we can host Wpf controls in Winforms applications (and vice-versa)? 有没有办法在Gtk#窗口中托管Winforms控件,如我们如何在Winforms应用程序中托管Wpf控件(反之亦然)?

There is no streight forward way to do this. 没有前进的方式来做到这一点。 WinForms on Linux interop with X11 directly. Linux上的WinForms直接与X11互操作。 It is possible to embed a X11 window in to Gtk, but you'd need to take care of all the stuff around it like widget allocation, sizing etc. 可以在Gtk中嵌入X11窗口,但是您需要照顾它周围的所有内容,例如小部件分配,调整大小等。

So the quick answer is no. 因此,快速答案是“否”。 You can take a look into the mono System.Windows.Forms implementation here: https://github.com/mono/mono/tree/master/mcs/class/System.Windows.Forms/System.Windows.Forms . 您可以在此处查看mono System.Windows.Forms实现: https : //github.com/mono/mono/tree/master/mcs/class/System.Windows.Forms/System.Windows.Forms It should be possible to retrieve the X11 window handle of a control and to embed it into Gtk. 应该可以检索控件的X11窗口句柄并将其嵌入到Gtk中。 But there is no "official" API to do that, so you'd have to write some additional native wrappers for X11/Gtk and a Gtk wrapper widget which takes care of all the Gtk stuff required to size and render a Gtk widget. 但是没有“官方” API可以执行此操作,因此您必须为X11 / Gtk和Gtk包装器小部件编写一些其他的本地包装器,该小部件处理大小和渲染Gtk部件所需的所有Gtk内容。

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

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