diff --git a/Source/GLControl/CarbonGLControl.cs b/Source/GLControl/CarbonGLControl.cs index 380a735f..58589f95 100644 --- a/Source/GLControl/CarbonGLControl.cs +++ b/Source/GLControl/CarbonGLControl.cs @@ -54,10 +54,13 @@ namespace OpenTK } private int GetYOffset(){ - System.Drawing.Point offset = control.PointToScreen(control.Location); - System.Drawing.Point windowOffset = control.TopLevelControl.PointToScreen(System.Drawing.Point.Empty); - 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; + if (control.TopLevelControl != null) { + System.Drawing.Point offset = control.PointToScreen (control.Location); + System.Drawing.Point windowOffset = control.TopLevelControl.PointToScreen (System.Drawing.Point.Empty); + 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