How to get the Rhino7 handle in rhino.inside.cad project?

After learning about the RIR code, I find it create Rhino7 Window by RhinoApp.MainWindowHandle.
But It seems useless in rhino.inside.CAD project. It turns that in cad project RhinoApp.MainWindowhandle is the handle of MainCAD window? I have no idea to find the rhino window handle Without RhinoApp.MainWindowhandle? Any one can give some suggestion? Thank you in advanced.

rhino.inside.cad project

rhino.inside.revit project

image

Code below also can’t get rhino handle, just get the CAD Window.

var MainWindow = Rhino.UI.RhinoEtoApp.MainWindow;
  MainWindow.Visible = true;
 MainWindow.WindowState = Eto.Forms.WindowState.Normal;

Hi @huaxiamengqing1,

Have you seen this sample?

If you want the HWND to Rhino’s main window, use RhinoApp.MainWindowHandle.

– Dale

1 Like

Thank you dear Dale! Yes , I am using this sample.But it shows that RhinoAPP.MainWindowHandle is the handle of AutoCAD MainWindow.

Hi @huaxiamengqing1,

RhinoApp.MainWindowHandle will return Rhino’s window handle if the Rhino main window has been created. Otherwise it returns the main window handle of the current process, which is what it’s doing in your test case.

– Dale