   Initialize Direct3D to draw in a part of the window
  Hello,I am trying to write a very basic program which draws just a few colored triangles. I found a few good tutorials on this in my programming language (Turbo Delphi 2006). I have a big problem with initializing D3D though, as I want it to draw just in a small area of my window. I know that probably most of you use C++ but maybe you can point me to what i am doing wrong. Thanks for your help!Here is my Code: procedure D3DInit;var  hr    : HRESULT;  d3dpp : TD3DPRESENTPARAMETERS;begin  lpd3d:=nil;  lpd3ddevice:=nil;  red:=0; green:=0; blue:=0;  lpd3d:=Direct3DCreate8(D3D_SDK_VERSION);  if(lpd3d=nil) then FatalError(0,'error creating D3D');  // reset D3DPRESENT_PARAMETERS  ZeroMemory(@d3dpp, SizeOf(d3dpp));  with d3dpp do begin    SwapEffect:=D3DSWAPEFFECT_DISCARD;    //this is where i try to force d3d to draw on the    //panel (a delphi-class similar to MFC's CRect)    //by passing the handle of the panel instead    //to the one of the window (called form1 in delphi)    hDeviceWindow:=Form1.panel1.handle;    BackBufferCount:=1;Windowed:= true;    BackBufferWidth   := 640;    BackBufferHeight  := 480;    BackBufferFormat  := D3DFind16BitMode;  end;  //this is where the initialization breaks  //error says wrong parameters  hr:=lpd3d.CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,Form1.Panel1.Handle,//here again the handle of my panelD3DCREATE_SOFTWARE_VERTEXPROCESSING,d3dpp,lpd3ddevice);  if FAILED(hr) then FatalError(hr,'error creating the 3d-device');end;   
  Did everything work fine when you used the handle from the form, rather than the panel? and it was only after switching to the panel handle that things started to fail?I would suggest playing around with this property:D3DFind16BitMode   try 24 or 32 bitsAlso, you should be getting a specific error back. While Failed() will just tell you that it was not successful, looking up the error will give you a more detailed description of the issue.I'm also curious about your choice of the software vertex processing mode.   