Step by step procedures for creating the VB/Ex1 example

  1. Make sure you have register the ActiveCDX.OCX, see install.htm for more information on this.
  2. Create a new project, select Standard Exe
  3. Insert the ActiveCDX component.
    In the toolbox, right click, select components, check the ActiveCDX ActiveX Control module, or you can browse and select the file manually.
    The succees of this step is indicated when you see 3 new components appeared in the toolbox. They are CDXVisual, CDXDraw and CDXAudio.
  4. Put the CDXVisual on the form and name it as CDXVisual
  5. Add the subroutine of CDX_Error in the general section:
        Private Sub CDX_Error(msg As String)
            Rem There is an error, destroy cdx and quit
            CDXVisual.Destroy
            MsgBox msg
            Unload Me
        End Sub
    This subroutine will be called when there is an error and will terminate the application.
  6. Declare a variable in general section:
        Dim Splash As Long
    This variable, Splash will be used to keep the handle of a surface containing the splash bitmap.
  7. In the Form_Load, add this code:
        Private Sub Form_Load()
            If Not CDXVisual.CreateWindowed(Form1.hWnd, 640, 480) Then
                CDX_Error ("Failed creating windowed CDX")
            End If
            Splash = CDXVisual.CreateSurface4("c:\cdx\acdx\examples\res\splash.bmp", 2)
            If Splash = 0 Then
                CDX_Error ("Failed loading c:\cdx\acdx\examples\res\splash.bmp")
            End If
        End Sub
    The first part of the code will create and initialize the CDX into windowed mode. And the second part of the code will create a surface containing the splash bitmap. Value 2 for the last parameter indicated that the surface should be located in the vidmem, and if it's not possible then the surface can be put in the sysmem. It's the same value as CDXSYS_VIDTHENMEM.
  8. Add this in the Form_Unload to destroy all CDX objects:
        Private Sub Form_Unload(Cancel As Integer)
            CDXVisual.Destroy
        End Sub
  9. Again, add the subroutine of Paint_Splash in the general section:
        Private Sub Paint_Splash()
            Dim HResult As Long
            HResult = CDXVisual.DrawFast(CDXVisual.GetBack, 0, 0, Splash)
            CDXVisual.Flip
        End Sub
    The above code will blit the Splash surface to the backbuffer. The Flip command will copy the backbuffer to the primary buffer.
  10. Don't forget to call then Paint_Splash in the Form_Paint and Form_Resize, like this:
        Private Sub Form_Paint()
            Paint_Splash
        End Sub
        Private Sub Form_Resize()
            Paint_Splash
        End Sub