Windows Forms & DirectX

Started by
3 comments, last by webbsk 19 years, 11 months ago
I''m trying to render DirectX in an a panel of a form. My problem is that all I can ever accomplish is rendering DirectX to the entire form. I''d like to be able to add some other controls to control my rendering and I''d like to put them on the form. But I can''t even get a toolbar to remain visible after I make the call show the DirectX. Does anyone know a solution to this or know where I could find one? I''m using C#, but I''ll take a solution written in VB or managed C++ too. Thanks.
Advertisement
Using Delphi I''ve succesfully rendered in a panel by passing its hwnd to the createdevice call.
I am sure it must be possible in managed DirectX as well. The constructor takes a Control as the third parameter, so if you cast it it should work.

mydevice = new Device(0, DeviceType.Hardware, (mypanel as Control), CreateFlags.SoftwareVertexProcessing, presentParams);
Create a control which has a DirectX device, etc, and can be embedded in other controls.
Maybe I should elaborate. I'm trying to use a lot of the sample code that comes with the SDK (e.g. d3dapp.cs, D3DMesh.cs, DXUtil) because I'm trying to use DirectInput for keyboard input but use form events for mouse input. The problem is that all this code is geared toward using the entire form. I'm refering to the "Scrawl" application. In D3DMesh.cs, they inherit from a GraphicsSample class to define a GraphicsClass class. The GraphicsSample class is defined in d3dapp.cs and it inherits from System.Windows.Forms.Form. So the entire set of files is all based on rendering to an entire window. But I'm looking for an example that implements all those features as a panel so that I don't have to rewrite all the other files (e.g. dinput.cs, d3denumeration.cs, d3dfont.cs, etc.) Has anyone found this on the web anywhere? Because all my searches are turning up nothing. d3dapp.cs in particular is a huge and very complex file and would be hard to duplicate.

[edited by - webbsk on May 10, 2004 11:27:33 AM]
the owner of the device must be a control like a picturebox and not a form.

This topic is closed to new replies.

Advertisement