Copyright © 1998-2010 MultiMedia Soft

SurfaceColor object

Previous pageReturn to chapter overviewNext page

The SurfaceColor object is internally implemented as a COM interface called ISurfaceColor and contains information needed to calculate the gradient 3D rendering applied over the button surface.

It can be used at Run-time to change the settings of any of the following color properties, based upon this object: ColorSurfaceNormal, ColorSurfaceMO, ColorSurfaceInternal, ColorSurfaceFocus, ColorSurfaceDisabled and ColorSurfacePressed (in order to perform changes to color settings at Design-time take a look to the How to change the button colors section).

The SurfaceColor object is implemented through the following properties:

Color

Color2

Render3DType

GradientType

GradientFactor

 

The following code snippets show how to modify this object in your code. These examples assume that you have placed a control named MyButton on a form or dialog.  The object is to change at run-time the color to a Green value and the gradient factor needed to calculate the 3D gradient applied to the button surface.

Microsoft Visual C++ (4.0, 5.0 and 6.0)

Microsoft Visual C++.NET (2003)

Microsoft Visual Basic (5.0 and 6.0)

Microsoft Visual Basic.NET (2003)

Microsoft Visual C#.NET (2003)

Microsoft Visual J#.NET (2003)

 

Microsoft Visual C++ (4.0, 5.0 and 6.0)

Properties and methods of the control are accessible through the control wrapper class CBtnEnh contained inside the BtnEnh.cpp and BtnEnh.h files: these wrapper files are automatically generated when you insert the control inside your project so, in order to access the wrapper functions, you will have to insert the following line of code somewhere in your code.

 

#include "BtnEnh.h"

 

The SurfaceColor object is defined by the control wrapper class CSurfaceColor contained inside the SurfaceColor.cpp and SurfaceColor.h files: also these wrapper files are automatically generated when you insert the control inside your project so, in order to access this object, you will have to insert the following line of code somewhere in your code.

 

#include "SurfaceColor.h"

 

Here follows the code needed to perform the requested operation of changing the surface color and its 3D gradient factor.

// declare a SurfaceColor object

CSurfaceColor color;

 

// init the object with the control's SurfaceColor for the Normal state (button not pressed)

color = MyButton.GetColorSurfaceNormal ();

 

// set the Green color

color.SetColor (RGB (0, 255, 0));

// set the new gradient factor

color.SetGradientFactor (6);

 

As you can see the access to the SurfaceColor properties Color and GradientFactor are wrapped by the SetColor and SetGradientFactor functions declared inside the wrapper class CSurfaceColor.

 

Microsoft Visual C++.NET (2003)

With this new development environment, the creation of wrapper classes for ActiveX control is not an easy operation and, while this documentation is being written, it seems to suffer some annoying bug. For this reason 3D Active Button Magic comes with the needed wrapper classes inside the directory "wrappers\cpp.net", created by the product installation package. What you have to do is to add the wrapper classes to your project and use them as described inside the "How to use the control in your projects".

As for the previous versions of Visual C++, properties and methods of the control are accessible through the control wrapper class CBtnEnh contained inside the BtnEnh.cpp and BtnEnh.h files: in order to access the wrapper functions, you will have to insert the following line of code somewhere in your code.

 

#include "BtnEnh.h"

 

The SurfaceColor object is defined by the control wrapper class CSurfaceColor contained inside the SurfaceColor.cpp and SurfaceColor.h files: in order to access this object, you will have to insert the following line of code somewhere in your code.

 

#include "SurfaceColor.h"

 

Here follows the code needed to perform the requested operation of changing the surface color and its 3D gradient factor.

// declare a SurfaceColor object

CSurfaceColor color;

 

// init the object with the control's SurfaceColor for the Normal state (button not pressed)

color = MyButton.GetColorSurfaceNormal ();

 

// set the Green color

color.SetColor (RGB (0, 255, 0));

// set the new gradient factor

color.SetGradientFactor (6);

 

As you can see the access to the SurfaceColor properties Color and GradientFactor are wrapped by the SetColor and SetGradientFactor functions declared inside the wrapper class CSurfaceColor.

 

Microsoft Visual Basic (5.0 and 6.0)

Here follows the code needed to perform the requested operation of changing the surface color and its 3D gradient factor.

' set the Green color

MyButton.ColorSurfaceNormal.Color = RGB(0, 255, 0)

' set the new gradient factor

MyButton.ColorSurfaceNormal.GradientFactor = 6

 

 

Microsoft Visual Basic.NET (2003)

Here follows the code needed to perform the requested operation of changing the surface color and its 3D gradient factor.

' set the Green color

MyButton.ColorSurfaceNormal.Color = Convert.ToUInt32(RGB(0, 255, 0))

' set the new gradient factor

MyButton.ColorSurfaceNormal.GradientFactor = 6

 

Microsoft Visual C#.NET (2003)

Here follows the code needed to perform the requested operation of changing the surface color and its 3D gradient factor.

// set the Green color

MyButton.ColorSurfaceNormal.Color = Convert.ToUInt32 (ColorTranslator.ToWin32 (Color.Green));

// set the new gradient factor

MyButton.ColorSurfaceNormal.GradientFactor = 6;

 

Microsoft Visual J#.NET (2003)

Here follows the code needed to perform the requested operation of changing the surface color and its 3D gradient factor.

// obtain a compatible color value

color = (System.UInt32) ColorTranslator.ToWin32 (Color.get_Green ());

// set the Green color

MyButton.get_ColorSurfaceNormal ().set_Color (color);

// set the new gradient factor

MyButton.get_ColorSurfaceNormal ().set_GradientFactor ((short) 6);

 

As you can see in J#.NET the access to the button properties is made through the use of wrapper functions (automatically generated when you insert the control inside your project) with the "get_" and "set_" prefixes. Intellisense will help you finding the right wrapper function.