简体   繁体   中英

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. The thing is that I'd like to use some 3rd-party controls which are only offered as Winforms controls. 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)?

There is no streight forward way to do this. WinForms on Linux interop with X11 directly. 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.

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 . It should be possible to retrieve the X11 window handle of a control and to embed it into 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.

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