Form Show() opening window behind Rhino UI

Hi - as per the title - in Rhino6, I see a random situation where the following code opens my form UNDER the Main Rhino UI panel (so there is a second icon on the Windows toolbar, and the Rhino window has to be moved to see my form). This does NOT happen in Rhino5. My code is…

MyForm.Show(System.Windows.Forms.Control.FromHandle(Rhino.RhinoApp.MainWindowHandle()));

Does anyone know how to fix this pls?

Thanks

Paul

If you want to show the dialog in modal fashion, use ShowModal(...). This will force the dialog to be in front of Rhino, but does not allow interaction with Rhino while the dialog is open.

Thanks. I need the window to be Modeless. In Rhino5 this works correctly, but not in Rhino6.

Paul

Ok, first ensure that the owner is correctly set (Control.FromHandle should not be null). If that does not solve the problem, you could subscribe to the RhinoApp.Idle event, and when that fires, set the form.TopMost = true or call form.Focus().

I have some more info on this - and it looks like a Rhino6 bug to me.

In summary…if I open the Octane Viewport, there is some time loading geometry and then the modeless form opens. If during the loading of geometry I task swap to another application, the modeless form will never display. I cannot find it when Alt-tabing.

Rhino.RhinoApp.MainWindowHandle() is not null.

If I add form.TopMost = true in the Idle event, the modeless window is displayed, however it is always on top of all windows of all applications, which is not what I want.

If I add form.Focus() or BringToFront() in the Idle event, it does not fix the problem (window still not visible).

So as you can see, it appears that Rhino6 is not correctly handling this situation where Rhino5 does.

Thanks

Paul

Strange, maybe @dale can help out here?

@pkinnane,

Does thie help?

– Dale

I would recommend implementing IWin32Window instead of Control.FromHandle

Control.FromHandle doesn’t work on any window that is not created by you

Dale, my form is modeless, not modal, so that code does not help.

Paul

OK, here is a modeless sample:

– Dale

1 Like

Dale - thank you. Form.Show(RhinoWinApp.MainWindow) seems to have resolved the issue. Much appreciated.

Paul

1 Like