Cicode Programming Reference > Cicode Function Categories > ActiveX Objects Introduction > CreateControlObject

CreateControlObject

Creates a new instance of an ActiveX object.

An object created using this function remains in existence until the page is closed or the associated Cicode Object is deleted. This function does not require an existing animation point. When the object is created, an animation point is created internally. This animation point is freed when the object is destroyed.

Syntax

CreateControlObject(sClass, sName, x1, y1, x2, y2, sEventClass)

sClass:

The class of the object. You can use the object's human readable name, its program ID, or its GUID. If the class does not exist, the function will return an error message.

For example:

sName:

The name for the object in the form of "AN" followed by its AN number, for example, "AN35". This name is used to access the object.

x1:

The x coordinate of the object's top left hand corner as it will appear in your CitectSCADA window.

y1:

The y coordinate of the object's top left hand corner as it will appear in your CitectSCADA window.

x2:

The x coordinate of the object's bottom right hand corner as it will appear in your CitectSCADA window.

y2:

The y coordinate of the object's bottom right hand corner as it will appear in your CitectSCADA window.

sEventClass:

The string you would like to use as the event class for the object.

Return Value

The newly created object, if successful, otherwise an error is generated.

Related Functions

DspAnCreateControlObject, CreateObject, AnByName

Example

// This function creates a single instance of the calendar control 
at the designated location with an object name of "CalendarEvent" 
and an event class of "CalendarEvent"//
FUNCTION
CreateCalendar()
OBJECT Calendar;
STRING sCalendarClass;
STRING sEventClass;
STRING sObjectName;
sCalendarClass = "MSCal.Calendar.7";
sEventClass = "CalendarEvent";
sObjectName = "MyCalendar";
Calendar = CreateControlObject(sCalendarClass, sObjectName, 16, 100, 300, 340, sEventClass);
END
// This function shows how to change the title font of the calendar//
FUNCTION
CalendarSetFont(STRING sFont)
OBJECT Font;
OBJECT Calendar;
Calendar = ObjectByName("MyCalendar");
Font = _ObjectGetProperty(Calendar, "TitleFont");
_ObjectSetProperty(Font, "Name", sFont);
END
// This function shows how to change the background color of the calendar//
FUNCTION
CalendarSetColor(INT nRed, INT nGreen, INT nBlue)
OBJECT Calendar;
Calendar = ObjectByName("MyCalendar");
_ObjectSetProperty(Calendar, "BackColor", PackedRGB(nRed,nGreen,nBlue));
END
// This function shows how to call the NextDay method of the calendar//
FUNCTION
CalendarNextDay()
OBJECT Calendar;
Calendar = ObjectByName("MyCalendar");
_ObjectCallMethod(Calendar, "NextDay");
END
// This function shows you how to write a mouse click event handler for the calendar//
FUNCTION
CalendarEvent_Click(OBJECT This)
INT nDay;
INT nMonth;
INT nYear;
nDay = _ObjectGetProperty(This, "Day");
nMonth = _ObjectGetProperty(This, "Month");
nYear = _ObjectGetProperty(This, "Year");
...
Your code goes here...
...
END

See Also

ActiveX Functions