CreateControlObject
- Last UpdatedFeb 28, 2024
- 2 minute read
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.
Note: ActiveX objects are not supported on a 64-bit process, such as an alarm server operating
in Extended Memory mode. If a call to this function occurs from a 64-bit process,
an error code will be returned, a hardware alarm will be raised and the Cicode thread
will stop.
For information regarding methods you can use to extend Plant SCADA that do not require
ActiveX, see the topic Extensibility in the Plant SCADA documentation
Syntax
OBJECT 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:
• "Calendar Control 8.0" - human readable name
• "MSCAL.Calendar.7" - Program ID
• "{8E27C92B-1264-101C-8A2F-040224009C02}" - GUID
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 Plant SCADA window.
y1:
The y coordinate of the object's top left hand corner as it will appear in your Plant SCADA window.
x2:
The x coordinate of the object's bottom right hand corner as it will appear in your Plant SCADA window.
y2:
The y coordinate of the object's bottom right hand corner as it will appear in your Plant SCADA 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