picoe / Eto

Cross platform GUI framework for desktop and mobile applications in .NET
Other
3.67k stars 335 forks source link

Wpf - WindowsFormsHost #960

Closed TomQv closed 6 years ago

TomQv commented 6 years ago

I see, that you have some support for System.Windows.Forms integration in Wpf now. How is this suppose to work?

I have a Winform-Control, which I need in Eto.Wpf. Currently I'm doing it like this:

var glcontrol = new QvxWin.Native.GLControlNative("", this);
var host = new System.Windows.Forms.Integration.WindowsFormsHost();
host.Child = glcontrol;
// here comes my Eto.Forms.Control 
var gleto = host.ToEto();

But of course I must reference WindowsFormsIntegration in my native app.

Can this be replaced now with your new System.Windows.Forms integration?

Tom

cwensley commented 6 years ago

Hey @TomQv, yes you can now do something like this:

class MyHandler: WindowsFormsHostHandler<GLControlNative, Control, Control.ICallback>, Control.IHandler
{
    public MyHandler()
    {
        WinFormsControl = new GLControlNative(...);
    }
}

It isn't anything special; it does the same as what you have there except it maps the mouse, keyboard, and focus events and methods to the winforms control itself.

Hope this helps! Curtis.

cwensley commented 6 years ago

Closing as I believe this is answered. Let me know if you have further questions.