I am following up this thread on simulating fullscreen behaviour with a borderless form, to avoid context destruction/recreation.
My implementation is roughly this:
_MinimalWindow = new Form(); _MinimalWindow.FormBorderStyle = FormBorderStyle.None; _MinimalWindow.TopMost = true; ... Hide(); // Use a native SetWindowPos call because the Form.Bounds property // does not move windows across monitors when the form is hidden. Platform.SetFormBounds(_MinimalWindow, new Rectangle(screenOffset, 0, dDev.Width, dDev.Height)); _GLControl.Parent = _MinimalWindow; _GLControl.Bounds = new Rectangle(0, 0, dDev.Width, dDev.Height); _MinimalWindow.Show();
(Best to ignore the native SetWindowPos call; Forms.Bounds would not move the form correctly if it was in the hidden state. I'm chasing this up on the MSDN forums. It doesn't change the problem I'm about to describe.)
This almost works great. If I make the GLControl width (dDev.Width - 1) then the behaviour is correct. However with (dDev.Width) the OpenGL full-screen effect spills from the first screen onto the second, causing the display to go black. I suspected an off-by-one error but (dDev.Width - 1) does leave a single column of the form's pixels unrendered.
Can you think of any reason this might be? I could make the form black so that the column of pixels is not visible, but it's a bit ugly!