WireLess Studio Widgets Developer's Guide
WSWDG ContentsWStForm class reference

AddObject

This method attaches a widget to a form.
When a widget is attached to a form, this form is called the widget's "parent form".

Ole declaration

VARIANT_BOOL AddObjectByName(LPCTSTR sFormName, LPCTSTR sObjectName);

VARIANT_BOOL AddObjectById(SHORT usFormId, SHORT usObjectId);

Parameters
sFormName
The form's name.
usFormId
The form's id.
sObjectName
The name of the widget.
usObjectId
The widget's id.
Return Value

On success, AddObject returns TRUE, FALSE otherwise. To get extended information, call WStError::GetLastErrorCode.

Remarks

A widget can be attached to more than one form.

Example
C#
using WirelessStudioOleWidgets;
WStFactory oFactory = new WStFactory();
WStForm oForm = new WStForm ();
short formId = 10;
short lineId = 15;
oFactory.CreateFormById(formId);
oFactory.CreateWidgetById((short)WSTFactoryConstants.WS_LINE, lineId , "MyLine", 15, 15, 30, 30, "");
oForm.AddObjectBydId(formId, lineId);
Visual Basic 6 (Full Example: BasicPropertiesDemoModule.bas.txt)
Public wsForm As New WStForm
Public wsFactory As New WStFactory		
...
'Form creation and customization
wsFactory.CreateFormByName "myForm"
wsForm.SetCoordTypeByName "myForm", WS_FORM_CT_BYPERCENTAGE
...
wsFactory.CreateWidget WS_BUTTON, 0, "moveUpBtn", 47, 63, 6, 5, "^"
wsFactory.CreateWidget WS_BUTTON, 0, "moveDownBtn", 53, 63, 6, 5, "v"
...
'Widgets Attachment
wsForm.AddObjectByName "myForm", "moveUpBtn"
wsForm.AddObjectByName "myForm", "moveDownBtn"
...
See also

WStFactory::CreateWidget | WStFactory::CloneObject | WStFactory::CreateForm

WStWiget class reference | WStForm class reference | WStFactory class reference | WStError class reference