VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



DirectX 7 Example of DirectDraw. See Microsoft website for further info: http://msdn.microsoft.com/

by Gideon Cole (3 Submissions)
Category: Graphics
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 7th June 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

DirectX 7 Example of DirectDraw. See Microsoft website for further info: https://msdn.microsoft.com/library/psdk/directx/vbddtut_0k4i.htm

API Declarations



' Visual Basic 6.0 Source Code
' illustrating Direct Draw via DirectX 7.0 API
'
' Developed using http://msdn.microsoft.com/library/psdk/directx/vbddtut_0k4i.htm example.

Dim objDX As New DirectX7 'DirectX Object
Dim objDD As DirectDraw7 'Direct Draw Object
Dim ddsd1 As DDSURFACEDESC2 'Surface Desc
Dim ddsd2 As DDSURFACEDESC2 'Surface Desc
Dim objDDSurf As DirectDrawSurface7 'Surface
Dim objDDPrimSurf As DirectDrawSurface7 'Surface
Dim ddClipper As DirectDrawClipper 'Clipper
Dim rSource As RECT
Dim rDestination As RECT

Dim bInit As Boolean
Dim lResult As Long

Rate DirectX 7 Example of DirectDraw. See Microsoft website for further info: http://msdn.microsoft.com/



On Error GoTo ErrorHandler
        
    Set objDD = objDX.DirectDrawCreate("") 'Create empty DirectDraw7 Object
    Call objDD.SetCooperativeLevel(Me.hWnd, DDSCL_NORMAL) 'Set behaviour
    
    '//Create Surface - Onscreen
    ddsd1.lFlags = DDSD_CAPS 'Surface Type
    ddsd1.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE 'Set type to Primary Surface
    Set objDDPrimSurf = objDD.CreateSurface(ddsd1) 'Create the Surface
    
    '//Create Surface - Offscreen
    ddsd2.lFlags = DDSD_CAPS 'Surface Type
    ddsd2.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN 'Offscreen surface in memory
    Set objDDSurf = objDD.CreateSurfaceFromFile(App.Path & "\dot.bmp", ddsd2)
    
    Set ddClipper = objDD.CreateClipper(0)
    ddClipper.SetHWnd oPicture.hWnd
    objDDPrimSurf.SetClipper ddClipper

    bInit = True
        
    DoEvents

    Exit Sub
ErrorHandler:
    MsgBox Err.Number & ": " & Err.Description, vbExclamation, App.Title
End Sub

Private Sub Form_Resize()

    'Source Rectangle
    rSource.Right = ddsd2.lWidth
    rSource.Bottom = ddsd2.lHeight
    
    'Destination Rectangle
    Me.ScaleMode = vbPixels
    oPicture.Width = Me.ScaleWidth
    oPicture.Height = Me.ScaleHeight
    
    Call objDX.GetWindowRect(oPicture.hWnd, rDestination)
    
    lResult = objDDPrimSurf.Blt(rDestination, objDDSurf, rSource, DDBLT_WAIT)
    If (lResult <> 0) Then
        MsgBox lResult, vbExclamation, App.Title
    End If

    Exit Sub
ErrorHandler:
    MsgBox Err.Number & ": " & Err.Description, vbExclamation, App.Title
End Sub



Download this snippet    Add to My Saved Code

DirectX 7 Example of DirectDraw. See Microsoft website for further info: http://msdn.microsoft.com/ Comments

No comments have been posted about DirectX 7 Example of DirectDraw. See Microsoft website for further info: http://msdn.microsoft.com/. Why not be the first to post a comment about DirectX 7 Example of DirectDraw. See Microsoft website for further info: http://msdn.microsoft.com/.

Post your comment

Subject:
Message:
0/1000 characters