Results 1 to 5 of 5

Thread: A dx7 question. Its simple but I cant figure it out!

  1. #1

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242

    Angry

    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:

    Code:
    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":

    Code:
    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

  2. #2
    Addicted Member hypnos's Avatar
    Join Date
    Aug 2000
    Location
    UK
    Posts
    183

  3. #3

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    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

  4. #4
    Addicted Member hypnos's Avatar
    Join Date
    Aug 2000
    Location
    UK
    Posts
    183

    Wink

    I notice a problem with your code. In the declarations you said:

    Code:
    '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.

  5. #5

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242

    i see said the blind man...

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width