C# Window Form and Panda3D

Hi Everyone!

I’m trying to place a panda3D window inside a win form using c#. I was able to launch the process ppython file.py and I success opening the DOS console inside my form. But Unfortunatley the graphic whindow that opens later, doesn’t appear inside my form (MDI parent).

Any ideas on this issue? Suggestions?

Best Regards

Gabriel Blanco

You need to get the HWND of the created window, and pass it through setParentWindow in the WindowProperties that are passed to the window you open.


First of all thank you for your answer. I’m not sure if i understood correctly.

This is the code I’m using.

        static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
Process p = Process.Start("notepad.exe");
            Thread.Sleep(500); // Allow the process to open it's window
            SetParent(p.MainWindowHandle, panel1.Handle);

I’m able to reparent the consolde window, but not the Panda3d window. How can I have access to that “second” handle withou searching for all opened application on my system?

Thanks in advance.

Gabriel Blanco

It will be cleanest if you let the Python code handle that reparenting: pass the value of pane1.Handle into your Python program, and let it be responsible for passing that to base.openWindow(), via the WindowProperties.setParentWindow() call. Alternatively, your Python program can preload that value as the “parent-window-handle” config variable, e.g. “parent-window-handle 3670896”, where 3670896 is the integer value of pane1.Handle.

A different approach would be to do more as you suggest: to let the Python program create its window normally, and then reparent it to your pane after it has been created. You can get the HWND of the created window by querying base.win.getWindowHandle().getIntHandle().