Archived

This topic is now archived and is closed to further replies.

FatzBomb

Direct Draw 7 Windowed Mode Problem

Recommended Posts

FatzBomb    122
I have created several games using DirectX 7 in fullscreen mode and now I want to do one in Windowed mode and am having a very difficult time. When I try to create my primary surface, I am getting an automation error, and I do not know why. I am programming in Visual Basic 6.0 and would really appreciate some help here. Thanks in advance, Keith. Here is my Initialization code: On Error GoTo DisplayError Set DD = DX.DirectDrawCreate("") DD.SetCooperativeLevel MainForm.hWnd, DDSCL_NORMAL With DDsdPrimary .lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT .ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX .lBackBufferCount = 1 End With ************ THE NEXT LINE GIVES ME AN AUTOMATION ERROR Set Primary = DD.CreateSurface(DDsdPrimary) ************ HAVEN''T TESTED BEYOND THIS Set Clip = DD.CreateClipper(0) Clip.SetClipList 1, ClipRect ''Get the backbuffer from the primary surface Dim caps As DDSCAPS2 caps.lCaps = DDSCAPS_BACKBUFFER Set BackBuffer = Primary.GetAttachedSurface(caps) BackBuffer.SetClipper Clip Thanks again!

Share this post


Link to post
Share on other sites
burp    122
Here''s some dx source I used for a client, it should help
  
Option Explicit
Private dx As DirectX7
Private dd As DirectDraw7
Private dds0 As DirectDrawSurface7
Public dxCount As Long

Public Type dxType
dds As DirectDrawSurface7
ddc As DirectDrawClipper
hWnd As Long
ddr As RECT
End Type

Public Sub dxStart()
If dxCount = 0 Then
Set dx = New DirectX7
Set dd = dx.DirectDrawCreate("")
dd.SetCooperativeLevel 0, DDSCL_NORMAL
Dim ddsd As DDSURFACEDESC2
With ddsd
ddsd.lFlags = DDSD_CAPS
ddsd.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE
End With
Set dds0 = dd.CreateSurface(ddsd)
End If
dxCount = dxCount + 1
End Sub

Public Sub dxEnd()
dxCount = dxCount - 1
If dxCount = 0 Then
Set dds0 = Nothing
Set dd = Nothing
Set dx = Nothing
End If
End Sub

Public Sub dxSurface(dxt As dxType)
With dxt
Dim ddsd As DDSURFACEDESC2
With ddsd
.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY
.lWidth = dxt.ddr.Right
.lHeight = dxt.ddr.Bottom
End With
Set .dds = dd.CreateSurface(ddsd)
End With
End Sub

Public Sub dxClipper(dxt As dxType)
With dxt
Set .ddc = dd.CreateClipper(0)
.ddc.SetHWnd .hWnd
End With
End Sub

Public Sub dxPaint(dxt As dxType)
With dxt
dds0.SetClipper .ddc
Dim wr As RECT
Call dx.GetWindowRect(.hWnd, wr)
wr.Bottom = wr.Top + .ddr.Bottom
wr.Right = wr.Left + .ddr.Right

Dim dde As Long
dde = dds0.Blt(wr, .dds, .ddr, DDBLT_DONOTWAIT)
If dde <> 0 Then MsgBox "
DirectX Error"
End With
End Sub

Share this post


Link to post
Share on other sites