Jump to content
  • Advertisement

Archived

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

ZenDarva

Dx7 Problem with SetCooperativeLevel in VB

This topic is 5218 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got a pretty standard initilization routine for DX7, and i'm trying to write it into a DLL. It works fine on the first run, everythings perfect, but when I run it again i get DDERR_HWNDALREADYSET as a result when I try to set the cooperative level. The terminate event for the class that initilizes DX looks like this:
Private Sub Class_Terminate()
dd.RestoreDisplayMode
dd.SetCooperativeLevel lHwnd, DDSCL_NORMAL
Set Primary = Nothing
Set BackBuffer = Nothing
Set DX = Nothing
Set dd = Nothing
End Sub
  
and the initilizaton code like so:
Public Sub Initilize(width As Integer, height As Integer, Hwnd As Long)
Dim desc As DDSURFACEDESC2
Dim caps As DDSCAPS2
Dim font As New StdFont
Dim errors As String
On Error GoTo mesg
lHwnd = Hwnd
iWidth = width
iHeight = height
Set dx = New DirectX7
Set dd = dx.DirectDrawCreate("A4918D9A-F0DD-4D4C-A89B-5A511E638C05")
errors = errors & " Created DD" & vbCrLf
'If dd.TestCooperativeLevel <> 0 Then
dd.SetCooperativeLevel Hwnd, DDSCL_ALLOWMODEX Or DDSCL_ALLOWREBOOT Or DDSCL_EXCLUSIVE Or DDSCL_FULLSCREEN
errors = errors & " Set Cooperative Level" & vbCrLf
dd.SetDisplayMode iWidth, iHeight, 16, 0, DDSDM_DEFAULT
errors = errors & " Set Display Mode" & vbCrLf
desc.lFlags = DDSD_BACKBUFFERCOUNT Or DDSD_CAPS
desc.ddsCaps.lCaps = DDSCAPS_FLIP Or DDSCAPS_PRIMARYSURFACE Or DDSCAPS_COMPLEX
desc.lBackBufferCount = 1
Set Primary = dd.CreateSurface(desc)
errors = errors & " Created Primary Surface" & vbCrLf
caps.lCaps = DDSCAPS_BACKBUFFER

Set BackBuffer = Primary.GetAttachedSurface(caps)
BackBuffer.GetSurfaceDesc desc
errors = errors & " Created Backbuffer" & vbCrLf
With myrect
    .Top = 0
    .Bottom = iHeight
    .Left = 0
    .Right = iWidth
End With
BackBuffer.SetForeColor vbRed
font.Name = "Arial"
font.Size = 12
BackBuffer.SetFont font
errors = errors & " Created Font" & vbCrLf
Exit Sub
mesg:
MsgBox "Log: " & errors
End Sub
  
Idea's? Comments? Anything?! [edited by - ZenDarva on May 8, 2004 6:56:08 AM]

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!