Error in code

Epo
02-19-2002, 09:14 PM
I know nothing is more of a pain than looking through someone's code and telling them where their mistake is.....so I'm going to try and make this as easy as possible for you :)


'In general
Dim DX As New DirectX7
Dim DD As DirectDraw7
Dim DDPS As DirectDrawSurface7
Dim DDBS As DirectDrawSurface7
Dim DDPSD As DDSURFACEDESC2
Dim DDBSD As DDSURFACEDESC2
Dim DDCaps As DDSCAPS2
Dim Running As Boolean

Private Sub Form_Load()
Set DD = DX.DirectDrawCreate("")
frmMain.Show

Call DD.SetCooperativeLevel(frmMain.hWnd, DDSCL_EXCLUSIVE Or DDSCL_FULLSCREEN Or DDSCL_ALLOWMODEX)
Call DD.SetDisplayMode(1280, 1024, 32, 0, DDSDM_DEFAULT)

With DDPSD
.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX
.lBackBufferCount = 1
End With
Set Primary = DD.CreateSurface(DDPSD)

DDCaps.lCaps = DDSCAPS_BACKBUFFER
Set Backbuffer = Primary.GetAttachedSurface(DDCaps)**
Backbuffer.GetSurfaceDesc ddsd3

frmMain.Show
Running = True

Do Until Running = False
DoEvents
Loop
End Sub


I get an error where the double stars are (they are not a part of the code) :) ....and the error says "Only user defined types in public modules can be coerced to or from a variant or passed to late bound functions"

And i really don't know what I'm doing wrong....andy ideas, suggestions or questions are welcome :)

Thanks

Iceplug
02-20-2002, 07:17 AM
Did you declare primary and backbuffer as surfaces?

Squirm
02-20-2002, 01:31 PM
Adding Option Explicit to the top of your code will help eradicate errors like these. You can make it automatic by going Tools -> Options -> Require Variable Declaration.

I concur with Iceplug that the error probably has something to do with the fact that Primary and Backbuffer have not been declared (or ddsd3 and ddsCaps for that matter).

ALWAYS DECLARE YOUR VARIABLES! :eek:

Epo
02-20-2002, 02:05 PM
There it is :)....Yeah....I'm flipping between Squirm's Tutorial, a second tutorial, and my code (my code uses different variables though) so I got mixed up with Primary and BackBuffer (I thought they were "declarations" instead of calling variables)....although now that I look at it more carefully I don't get why I thought that :)

Thanks

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum