Hi! I've been trying to combine direct3d and directdraw in order to create a 2d game using 3d techniques like alpha blending and so on... It works fine using fullscreen mode but I can't get it working using windowed mode! What am I suppose to do?

The code for fullscreen is:
...
DD.SetCooperativeLevel frmMain.hWnd, DDSCL_EXCLUSIVE Or DDSCL_FULLSCREEN Or DDSCL_ALLOWREBOOT
DD.SetDisplayMode width, height, depth, 0, DDSDM_DEFAULT

ddsd.lFlags = DDSD_BACKBUFFERCOUNT Or DDSD_CAPS
ddsd.ddsCaps.lCaps = DDSCAPS_COMPLEX Or DDSCAPS_FLIP Or DDSCAPS_3DDEVICE Or DDSCAPS_PRIMARYSURFACE
ddsd.lBackBufferCount = 1
Set surfacePrimary = DD.CreateSurface(ddsd)

caps.lCaps = DDSCAPS_BACKBUFFER Or DDSCAPS_3DDEVICE
Set surfaceBackbuffer = surfacePrimary.GetAttachedSurface(caps)
...

and the code for windowed is:
...
DD.SetCooperativeLevel frmMain.hWnd, DDSCL_NORMAL

ddsd.lFlags = DDSD_CAPS
ddsd.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE
Set surfacePrimary = DD.CreateSurface(ddsd)

ddsd.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
caps.lCaps = DDSCAPS_3DDEVICE
Set surfaceBackbuffer = surfacePrimary.GetAttachedSurface(caps) ' DD.CreateSurfaceFromFile(App.Path + "\test.bmp", ddsd)

Set DDClipper = DD.CreateClipper(0)
DDClipper.SetHWnd Me.hWnd
surfacePrimary.SetClipper DDClipper
...

and after these lines the d3d snippet comes like this:
Set D3D = DD.GetDirect3D

Set DEnum = D3D.GetDevicesEnum
Guid = DEnum.GetGuid(DEnum.GetCount)
Set D3DDevice = D3D.CreateDevice(Guid, surfaceBackbuffer)


the fullscreen part works but not windowed, can anyone explain why?