I have a WPF project setup using an OpenTK GLControl inside of a Windows Forms Host... When I tie events to the GLControl's Mouse events (MouseDown, MouseWheel, etc) I cannot get them to function. Any mouse input done while the mouse is over the GLControl never seems to fire. Is there a way to accomplish mouse inputs over a GLControl that is inside of a Forms Host?
I tie the event when the GLControl is loaded using
glControl1.MouseWheel += glControl1_MouseWheel;
and then create
private void glControl1_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
{
Console.WriteLine("Do something");
}
In you proyect add an user control, then in the .cs, you have something similar to:
public partial class WindowGL: System.Windows.Forms.UserControl{
private void mouseDown(object sender, System.Windows.Forms.MouseEventArgs e){}
private void mouseMove(object sender, System.Windows.Forms.MouseEventArgs e){}
private void mouseUp(object sender, System.Windows.Forms.MouseEventArgs e){}
}
then in design view into properties connect the event with the function. And in the WPF:
this.diagramHost.Child = new WindowGL();
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.