I was wondering if it is possible to use Windows Forms with Panda3D (I am not using python but C++).
I found a forum thread where someone else asked a similar question but It didn’t make much sense to me.
(for reference : [url]C# Window Form and Panda3D] )
I have created “myForm” (via form designer of VS2008)
and now I would like to reparent the panda3d window to my newly created form.
I had a look at the WindowsProperties class and in particular the Set_parent_window function which takes a WindowHandle* .
How do I convert my IntPtr (managed c++) which is a widows handle to “myForm” into a WindowHandle* (Panda3D) ?
Also would I be interested to hear your general thoughts about using Windows Forms as container for Panda3D.
to convert your HWND windows handle to a Panda WindowHandle.
More simply, you can use the version of WindowProperties::set_parent_window() that receives a size_t instead of a WindowHandle pointer, and cast your pointer to size_t:
but I am not sure how to set the new size of the panda window.
I have also seen there is somethig in PandaFramework to use
event_window_event ? Any hints ?
[EDIT}
Actually I just realised theFramework.get_default_window_props(props); does not do the desired effect (getting the actualy windows properties i had setup initially).
At this point I am conviced I am missing something somewhere either in PandaFramework or WindowFrameWork?
[/EDIT]
this doesnt seem to work, though I think I am still missing something.
here is where it fails
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::request_properties
// Access: Published
// Description: Requests a property change on the window. For
// example, use this method to request a window change
// size or minimize or something.
//
// The change is not made immediately; rather, the
// request is saved and will be applied the next time
// the window task is run (probably at the next frame).
////////////////////////////////////////////////////////////////////
void GraphicsWindow::
request_properties(const WindowProperties &requested_properties) {
LightReMutexHolder holder(_properties_lock);
_requested_properties.add_properties(requested_properties);
if (!_has_size && _requested_properties.has_size()) {
// If we just requested a particular size, anticipate that it will
// stick. This is helpful for the MultitexReducer, which needs to
// know the size of the textures that it will be working with,
// even if the texture hasn't been fully generated yet.
_x_size = _requested_properties.get_x_size();
_y_size = _requested_properties.get_y_size();
// Don't set _has_size yet, because we don't really know yet.
}
}
it never passes that if statement.
also I wonder where I would add the theFramework.main_loop();
I think I need register it somehow to be executed by the Form.
It’s actually expected for it not to pass that if statement–that has nothing to do with the actual resizing of the window. That is handled in a sub-class, in WinGraphicsWindow::do_reshape_request(). However, note that the resize doesn’t happen immediately; it happens during the next frame, which means it won’t happen if you’re not calling the Panda loop.
I wanted share my code with others who like me want to use Panda with Windows Forms. So I wrote a little test application with panda3d and managed C++ using windows forms.
hope it helps
Features :
A Windows Form with a split-container
On the right side is panda3d with the tutorial environment model loaded.