Fix potential exception that I was ignoring.

This can happen, so we should handle it
This commit is contained in:
Paul Kratt 2014-02-21 21:36:22 -06:00
parent 794d45fdeb
commit ba0180ed77

View file

@ -54,10 +54,13 @@ namespace OpenTK
} }
private int GetYOffset(){ private int GetYOffset(){
System.Drawing.Point offset = control.PointToScreen(control.Location); if (control.TopLevelControl != null) {
System.Drawing.Point windowOffset = control.TopLevelControl.PointToScreen(System.Drawing.Point.Empty); System.Drawing.Point offset = control.PointToScreen (control.Location);
int relativeY = offset.Y-windowOffset.Y; //control.TopLevelControl.Location.Y is not the same as windowOffset.Y for some reason. System.Drawing.Point windowOffset = control.TopLevelControl.PointToScreen (System.Drawing.Point.Empty);
return control.TopLevelControl.ClientSize.Height - control.Bottom - relativeY; int relativeY = offset.Y - windowOffset.Y; //control.TopLevelControl.Location.Y is not the same as windowOffset.Y for some reason.
return control.TopLevelControl.ClientSize.Height - control.Bottom - relativeY;
}
return control.Location.Y;
} }
#region IGLControl Members #region IGLControl Members