   DirectX device in a panel on a form
  Hi,I'm kinda new to DirectX,a total noob actually and I'm following this tuturial: http://www.gpwiki.org/index.php/VBNET:Direct3D_Initializationbut for the schoolproject I'm doing,I need the Direct3D device in a panel on my form instead of covering the entire formmy attempts of editing this code crash on meso,could anyone tell me how I adjust the following code,so the Direct3D device shows up in Panel1 on the form? Thank you very much in advanceImports SystemImports System.DrawingImports System.ComponentModelImports System.Windows.FormsImports System.IOImports Microsoft.DirectXImports Microsoft.DirectX.Direct3DImports Direct3D = Microsoft.DirectX.Direct3DPublic Class frmSpel    Inherits System.Windows.Forms.Form    Private GraphicsDevice As Direct3D.Device = Nothing    Private presentParams As PresentParameters = New PresentParameters    Private Sub InitializeGraphics()   presentParams.SwapEffect = SwapEffect.Discard   Dim current As Format = Direct3D.Manager.Adapters(0).CurrentDisplayMode.Format   If Direct3D.Manager.CheckDeviceType(0, DeviceType.Hardware, current, current, False) Then  presentParams.Windowed = False  presentParams.BackBufferFormat = current  presentParams.BackBufferCount = 1  presentParams.BackBufferWidth = 1280  presentParams.BackBufferHeight = 1024   Else  presentParams.Windowed = True   End If   GraphicsDevice = New Direct3D.Device(0, Direct3D.DeviceType.Hardware, Me, CreateFlags.SoftwareVertexProcessing, presentParams)    End Sub    Private Sub Render()   GraphicsDevice.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0F, 0)   GraphicsDevice.BeginScene()   GraphicsDevice.EndScene()   GraphicsDevice.Present()    End Sub    Private Sub frmSpel_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load   Me.InitializeGraphics()   Try  While Me.Created Me.Render() Application.DoEvents()  End While   Finally  Me.Dispose()   End Try    End SubEnd Class   
  Hello !In your InitializeGraphics method do this instead of what you are doing now :GraphicsDevice = New Direct3D.Device(0, Direct3D.DeviceType.Hardware, Panel1, CreateFlags.SoftwareVertexProcessing, presentParams)That should do it. I just solved the same you are trying to do for a small tetris-like game but I used C# instead of VB.NET.Passing the panel instead of the form in the Device-Constructor solved it for me.Good luck !   ;  unfortunatly,doing that always gives me an error without further explanation whyhttp://users.pandora.be/snaplet/error.JPG   