Product Home Class IndexDownload

CreateComponent

All components should be created using this global factory function. The reason it is global is because it takes a varying number of parameters.

Creates a component of a any type, assigns the parent, and can assign zero or more properties at creation time.

Return Value
Returns a pointer to the component that was created. If necessary, this can be dynamic-cast to the specific type of component.

Parameters

componentType
One of the component types, such as CT_Label, listed in the ComponentTypes enumeration in ck_component.h.
parent
The parent component. If it is the top-level component on a screen, then parent should be null.
...
Following parent there can be a number of property-value pairs terminated by a 0. See the examples below.
Examples

The following call creates a row-column component.

CK_RowColumn *rc = (CK_RowColumn *)CreateComponent(CT_RowColumn,0,
	CP_LayoutDirection,CV_LayoutHorizontal,
	CP_ComponentSpacing,5,
	0);

The following creates a label with text, but with no background bitmap or fill-color.

CK_Label *label = (CK_Label *)CreateComponent(CT_Label,0,
	CP_Width,200,
	CP_Height,100,
	CP_Font,font,
	CP_Text,"This is a test",
	0);