Hello –
I have written a Grasshopper plugin that create, manages, and manipulates Rhino Viewports. I need viewports to be active so that I can capture screen content from them but have them hidden from view. One hacky way to do this is to create them with a screen rectangle that is very far from the screen coordinates, but it feels hacky and not right.
I have written a component to Hide/Show the window using the window handle, but unfortunately it doesn’t hide the window, only the contents of the window. The code is here:
[DllImport(“user32.dll”)]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);const int SW_HIDE = 0; const int SW_SHOW = 5; const int SW_MINIMIZE = 6; const int SW_RESTORE = 7;
protected override void SolveInstance(IGH_DataAccess DA)
{
IGH_Goo viewportGoo = null;
int width = 0;
int height = 0;
bool show = true;if (!DA.GetData(0, ref viewportGoo)) return; RhinoViewport viewport = null; viewportGoo.CastTo<RhinoViewport>(out viewport); if (viewport == null) { string vpString = ""; DA.GetData(0, ref vpString); viewport = RhinoDoc.ActiveDoc.Views.FirstOrDefault(v => v.ActiveViewport.Name == vpString)?.ActiveViewport; if (viewport == null) { return; } } if (!DA.GetData(1, ref show)) return; RhinoView rv = viewport.ParentView as RhinoView; if (rv.Floating) { IntPtr hWnd = rv.Handle; int show_command = show ? SW_SHOW : SW_HIDE; ShowWindow(hWnd, show_command); } }
Questions:
- What type of window is the RhinoView window? WPF? Eto?
- How do I get the handle of the window itself? Right now the RhinoView handle seems to encapsulate only the content of the window, not the window itself. Am I going about this all wrong?
Thanks,
Marc
P.S. Working in Rhino 7 currently