mcneel / rhinocommon

RhinoCommon is the .NET SDK for Rhino5 / Grasshopper
http://wiki.mcneel.com/developer/rhinocommon
242 stars 93 forks source link

Application message loop #93

Closed piac closed 11 years ago

piac commented 12 years ago

Using Form.Show() or Form.Show(Rhino.RhinoApp.MainWindow()) does not trigger proper tab behavior between controls in the non-modal form. (Usually, if you push "Tab" in a windows form, you get to move from one control to the next).

It seems that the origin of the problem is the fact that there is no proper WinForm message loop that is registered on the UI thread, but the unmanaged host is taking care of handling all messages. Application.MessageLoop returns false if queried.

It seems we are in a similar situation as this one: http://stackoverflow.com/questions/7604111/why-does-application-idle-never-fire-when-my-form-is-hosted-in-a-mfc-application There are some possible ways to circumvent this problem, and these are outlined on that page

piac commented 12 years ago

As outlined in those questions, using Form.ShowDialog() enables the tab behavior.

sbaer commented 11 years ago

John, I think you may have already fixed this but I guess we need to double check

johnmorse commented 11 years ago

I fixed it in controls embedded in Rhino docking windows, this still appears to be a problem doing something simple like this: var form = new MyForm(); form.Show(Rhino.RhinoApp.MainWindow());

I display a form with 3 TextBox controls and am unable to tab between them, I will investigate further and see if I can figure out why.

johnmorse commented 11 years ago

MSDN Documents this as a know problem here: http://support.microsoft.com/kb/233263

johnmorse commented 11 years ago

I cooked up a sample https://github.com/mcneel/rhinocommon/tree/master/examples/ModelessFormTabProblem which demonstrates how to make this work, see the Form1 class for implementation.