Color DataBlade Module The Color DataBlade module consists of a server project and a client project. The server project defines the Color opaque type, its support routines, and its accessor methods for execution on the server. The client project provides the code that allows Microsoft Visual Basic to instantiate the server opaque type as a client-side ActiveX value object; it also provides the ActiveX custom methods and interfaces with which Visual Basic and the client application developer can access the ActiveX value object. The client program connects to an Informix database table that contains a Color opaque type column, retrieves a row from that table, then makes use of the ActiveX client project to visualize (display) the data as a color in Visual Basic. The Color data type represents standard RGB color codes. The Color data type has three members: one each for red, green, and blue. The project root directory is dbdk\Types\ActiveX\AxColorDemo under the Informix Directory. This directory contains the following files: readme.txt - The current file AxColorDemo.ibs - DBDK project file ColorBuild.sql - The SQL script that populates the database Follow these steps to build the complete application: Step 1: Building the DataBlade module for the server - All the generated files are in the src\ActiveX directory. Copy all the *.cpp, *.h and AxColorDemoU.mak files to the target server machine where the build needs to be performed. - If the target machine is a Windows NT machine, open the AxColorDemoS.dsp file using Visual C++ and perform a build. - If the target machine is a UNIX machine, use the AxColorDemoU.mak file to build the project. - After the build, follow the standard procedures for deploying the DataBlade module onto the appropriate server. You must create a database (colors) and install the DataBlade in the database. Step 2: Creating and populating the database - Connect to the Informix Server through SQL Editor and create a database (colors). - Follow the standard procedures for installing the built DataBlade onto this database. - From SQL Editor, open the file ColorBuild.sql and execute it against the colors database. This will create a table called colors and insert a few rows into it. Step 3: Building the ActiveX for the client - Open the AxColorDemoX.dsp project from the Visual C++ environment and build the project. This will build the AxColorDemoX.dll file and register it into the current machine. Step 4: Create a data source for the colors database - Open the ODBC Admin application and create a data source called Colors that points to the colors database that you just created. Step 5: Modify the Visual Basic application to connect to Colors - Open the vb\Color.vbp project from Visual Basic. This application is already configured to connect to the Colors data source. Step 6: Run the application - Run the application from within Visual Basic. You will be able to see the colors of the table displayed on the main form. You will also be able to navigate from row to row and modify the colors. Project Tips: The AxColorCommon::FromString and AxColorCommon::ToString functions were modified to change the format from "red green blue" to "(red, green, blue)". You can find these functions in the src\ActiveX\AxColorCommon.cpp file. You may need to supply the username and password properties for the MSRDC1 control in the Visual Basic application. The following properties of MSRDC1 were modified to make this application work: CursorDriver: 1 - rdcUseOdbc DataSourceName: Colors SQL: select index, color::lvarchar::char(30) as color from colors Note that the SQL statement needs the cast and the alias to let VB bypass the fact that color is not a standard ODBC type. For Shape1, the BackStyle property was changed to '1 - Opaque'. For Text1, the following properties were changed: DataSource: MSRDC1 DataField: index For Text2, the following properties were changed: DataSource: MSRDC1 DataField: color Also, for Text2, the following code was inserted for the Change event: Private Sub Text2_Change() On Error Resume Next Dim obj As New AxColor obj.FromString Text2.Text Shape1.BackColor = RGB(obj.red, obj.green, obj.blue) End Sub