Getting Started using Active CDX for CDX user

 

This brief tutorial is designed for user that already familiar in using CDX to know and understand the different between the use of the original CDX library and Active CDX.

Basically, most of the function names and their functionality between the two are the same. Some of the different are:

  1. The CDXScreen and CDXSurface are combined into one control called CDXVisual.
  2. For example if you want to create a surface in original CDX library:

        CDXScreen* Splash = new CDXSurface();

    In CDXVisual, it would be written like this:

        long Splash = CDXVisual.CreateSurface();

    There are no different between the two. Both return the address of the new created surface. The different is that the Active CDX can’t return specific pointer, so it just return a long integer which is actually a pointer to the new surface.

  3. There is no such kind of function overloading in custom control, so these kind of functions have to be written using different name. The approach that Active CDX used for this is by numbering the functions. There is also no default value for the parameter.
  4. For example, these 4 constructors of CDXSurface taken from the original CDX library:

        CDXSurface();

        CDXSurface(CDXSurface& aSurface);

        CDXSurface(CDXScreen *pScreen, int Width, int Height, BYTE memoryType = CDXMEM_VIDTHENSYS);

        CDXSurface(CDXScreen *pScreen, const char *szFilename, BYTE memoryType = CDXMEM_VIDTHENSYS);

    Would be written in ActiveCDX as:

        OLE_HANDLE CreateSurface();

        OLE_HANDLE CreateSurface2(OLE_HANDLE surface);

        OLE_HANDLE CreateSurface3(long width, long height, short memoryType);

        OLE_HANDLE CreateSurface4(LPCTSTR szFilename, short memoryType);

    Please note that you can’t use constant CDXMEM_VIDTHENSYS in ActiveCDX since those kind of constants are undefined. Instead you would have to use the number that represent each constant (ex: number 2 for CDXMEM_VIDTHENSYS).

    Don’t be confused by the use of many different way in representing address, like OLE_HANDLE, CDXSurface*, and long integer. They basically are just the same pointer. The different occurs because they are being used on the different place. Actually, OLE_HANDLE is a long integer too.

  5. Because you only have one CDXVisual and no CDXSurface, each time you want to use the function of CDXSurface, you can do that from CDXVisual but with one additional parameter, that is the address/handle of the surface. For example, in CDX lib:
  6.     Splash->SetColorKey(5);

    In ActiveCDX become:

        CDXVisual.SetColorkey(Splash, 5);

    Other examples:

        void SetDest(int t, int l, int b, int r);

        void SetSrc(int t, int l, int b, int r);

        void SetColorKey(DWORD col);

        void SetColorKey(void);

    In ActiveCDX become:

        void SetDest(OLE_HANDLE surface, long x1, long y1, long x2, long y2);

        void SetSrc(OLE_HANDLE surface, long x1, long y1, long x2, long y2);

        void SetColorKey(OLE_HANDLE surface);

        void SetColorKey2(OLE_HANDLE surface, OLE_COLOR color);

  7. Because there is no default parameter, in CDX lib:

          HRESULT Flip(BOOL VSync=TRUE, BOOL FlipWithStretch=TRUE, BOOL displayFPS = FALSE);

In ActiveCDX become 2 functions:

           long Flip();

     long Flip2(BOOL bVSync, BOOL bFlipWithStretch, BOOL bDisplayFPS);

 

The Step by Step Tutorials

In each example, there is a file named "step.htm". This file contains the step by step procedures to make the example. You might find this file to be a great help to start you coding using ActiveCDX. So, make sure you want to check them out. Further question about ActiveCDX can be asked via CDX mailing list.