WireLess Studio Widgets Developer's Guide
WSWDG ContentsWStFactory class reference

CreateWidget

Call this method to create a new widget. Once a widget is created, it can be manipulated using the WStWidget object and can be attached to a form using the WStForm::AddObject method.

Ole declaration

VARIANT_BOOL CreateWidgetById(SHORT usType, SHORT usId, LPCTSTR sName, SHORT usXCoord, SHORT usYCoord, SHORT usWidth, SHORT usHeight, LPCTSTR sText);

VARIANT_BOOL CreateWidget(SHORT usType, SHORT usId, LPCTSTR sName, SHORT usXCoord, SHORT usYCoord, SHORT usWidth, SHORT usHeight, LPCTSTR sText);

Parameters
usType
The widget's type.
usId
The id of the widget.
sName
The name of the widget.
usXCoord
Specifies the position of the left side of the widget.
usYCoord
Specifies the position of the top of the widget.
usWidth
Specifies the width of the widget.
usHeight
Specifies the height of the widget.
sText
The text that will be displayed by the widget.
Return Value

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

Remarks

The widget's type can be one of the following constants found on the WSTFactoryConstants enumeration: WS_BITMAP, WS_BUTTON, WS_CHECKBOX, WS_FIELD, WS_HTML_CTRL, WS_LABEL, WS_LINE, WS_LIST_CTRL, WS_MENU, WS_PROGRESS_BAR and WS_RADIO_BUTTON.

The description of the available widgets can be found here.

CreateWidgetById tries to index the widget only by its id, if it fails the widget creation fails.

Unlike CreateWidgetById, CreateWidget tries to index the widget by its id or its name, if it fails the widget creation fails. If the indexation success by both id and name, the WStWidget methods with the suffix ById and ByName can be used to customize the widget.

The widget's size and position depends on the coordinates type used by the form the widget is attached to. (For more information see WStForm::SetCoordType).

The first id that can be to create a widget is 11, lower numbers are reserved.

Example
C#
using WirelessStudioOleWidgets;
WStFactory oFactory = new WStFactory();
oFactory.CreateWidgetBy((short)WSTFactoryConstants.WS_LINE, 33, "MyLine", 15, 15, 30, 30, "")
Visual Basic 6 (Full Example: BasicPropertiesDemoModule.bas.txt)
Public wsForm As New WStForm
Public wsFactory As New WStFactory		
...
wsFactory.CreateWidget WS_LABEL, 0, "formTittle", 33, 0, 40, 5, "Basic Properties Demo"
wsFactory.CreateWidget WS_BUTTON, 0, "exitButton", 5, 80, 29, 12, "Exit"
wsFactory.CreateWidget WS_BUTTON, 0, "resetButton", 35, 80, 29, 12, "Reset"
wsFactory.CreateWidget WS_LINE, 0, "topLine", 5, 6, 90, 1, ""
...
See also

CloneObject | WStForm::AddObject | CreateForm

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