PDA

Click to See Complete Forum and Search --> : A dx7 question. Its simple but I cant figure it out!


drewski
Aug 25th, 2000, 10:53 PM
looking at the source that came with dx7 and im trying to recreate the first the first ddraw tutorial but i keep getting this stupid type mismatch error! i've looked it over pretty good and I can'd find it! I just need a fresh view of it from someone else with a little more experience than dx than me.

Here is the code in the form:


Private Sub Form_Load()
strFile = App.Path & "\picture.bmp"
Init
End Sub

Private Sub Form_Resize()
Picture1.Width = Form1.ScaleMode
Picture1.Height = Form1.ScaleMode

Blt
End Sub

Private Sub Picture1_Paint()
DDraw.RestoreAllSurfaces
Init
Blt
End Sub


Here is the code in the "setup dx.bas":


Option Explicit
'need this to do anything at all
Public DX7 As New DirectX7
'we need this to do anything with ddraw
Public DDraw As DirectDraw7
'these are the surfaces we will us with ddraw
Public ddsPrimary As DirectDrawSurface7
Public ddsSecondary As DirectDraw7
'these are the descriptions for the ddraw surfaces
Public ddsd1 As DDSURFACEDESC2
Public ddsd2 As DDSURFACEDESC2
'this is the clipper so we can draw off the screen
Public DDClipper As DirectDrawClipper
'this is just a flag to tell us what we've done
Public bInit As Boolean
'this is to hold the path to the picture for out background
Public strFile As String

Public Sub Init()
Set DDraw = DX7.DirectDrawCreate("")

Call DDraw.SetCooperativeLevel(Form1.hWnd, DDSCL_NORMAL)

'create the primary surface
ddsd1.lFlags = DDSD_CAPS
ddsd1.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE
Set ddsPrimary = DDraw.CreateSurface(ddsd1)


'create the secondary surface
ddsd2.lFlags = DDSD_CAPS
ddsd2.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
'the problem is here!!! it says there is a type mismatch! there is not type mismatch!!!! :{
Set ddsSecondary = DDraw.CreateSurfaceFromFile(strFile, ddsd2)

Set DDClipper = DDraw.CreateClipper(0)
DDClipper.SetHWnd Form1.Picture1.hWnd
ddsPrimary.SetClipper DDClipper

bInit = True

End Sub

Public Sub Blt()
If bInit = flase Then Exit Sub

Dim ddrval As Long
Dim rect1 As RECT
Dim rect2 As RECT

Call DX7.GetWindowRect(Form1.Picture1.hWnd, rect1)

rect2.Bottom = ddsd2.lHeight
rect2.Right = ddsd2.lWidth

ddrval = ddsPrimary.Blt(rect1, ddsSecondary, rect2, DDBLT_WAIT)

End Sub



If it helps remember that I'm trying to remake the first tutorial sent with the dx7 sdk.



a fellow programmer,
Drewski

hypnos
Aug 26th, 2000, 05:43 AM
Have a look at my code: http://forums.vb-world.net/showthread.php?threadid=27691

drewski
Aug 26th, 2000, 07:02 PM
hypnos that doesnt really answer my question. i need to know why i'm getting a type mismatch error. im pretty dang sure im doing everything right but the stupid computer brings up this type mismatch error. its really frustrating!!! hey fox if you read this can you please help? or kenney or kedaman or wildghost or anyone? please help me. i cant see why this is a problem! i mean ive looked and i cant see why there is an error! im going to go look again. if anyone knows what the problem is please help. it will be greatly appreciated.


thanks to all,
Drewski

hypnos
Aug 27th, 2000, 08:48 AM
I notice a problem with your code. In the declarations you said:


'these are the surfaces we will us with ddraw
Public ddsPrimary As DirectDrawSurface7
Public ddsSecondary As DirectDraw7


You have declared the secondary surface as DirectDraw7 and not DirectDrawSurface7 - That needs changing. Hope this helps. I think this is your problem.

drewski
Aug 27th, 2000, 09:21 PM
ahhh i see now!!! thankyou so much! i cant believe i didnt see that. geez i guess i might need new glasses now ;) geez i need to watch my declartions more closely.


thanks a bunch hypnos.