WireLess Studio Widgets Developer's Guide
WSWDG ContentsWStWidget class reference

SetFont

Changes the current font of a specific widget.

Ole declaration

VARIANT_BOOL SetFontByName(LPCTSTR sObjectName, SHORT usFontId);

VARIANT_BOOL SetFontById(SHORT usObjectId, SHORT usFontId);

Parameters
sObjectName
The name of the target widget.
usObjectId
The id of the target widget.
usFontId
Specifies the id of a font previously created with WStFactory::CreateCustomFont.
Return Value

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

Remarks

When a WS_MENU widget behaves as a button menu (See ChangeMenuType), the modification of it's font also changes the font of the buttons that contains and it's title.

Example
C#
using WirelessStudioOleWidgets;
WStWidget oWidget = new WStWidget();
WStFactory oFactory = new WStFactory();
short sFontId = 4;
oFactory.CreateCustomFont(sFontId, 21, true, false, false, "Arial",(short)WSFontAlignment.WS_CENTER);
                
/* Using a previously created widget*/
short iButtonId = 20;
oWidget.SetFontById(iButtonId, sFontId);
Visual Basic 6 (Full Example: BasicPropertiesDemoModule.bas.txt)
Public wsWidget As New WStWidget
Public wsFactory As New WStFactory
..
wsFactory.CreateCustomFont 3, 11, True, False, False, "Times New Roman", WS_LEFT
wsFactory.CreateCustomFont 4, 16, False, True, True, "Tahoma", WS_RIGHT
wsFactory.CreateCustomFont 5, 16, False, False, False, "Courier New", WS_CENTER
...
Public Sub ChangeFont(iSelectedOption As Integer)
    Dim iFontId As Integer
    
    Select Case iSelectedOption
        Case 0
            iFontId = 3
        Case 1
            iFontId = 4
        Case 2
            iFontId = 5
        Case -1
            iFontId = 3
    End Select
        
    wsWidget.SetFontByName "button", iFontId
    wsWidget.SetFontByName "label", iFontId
    wsWidget.SetFontByName "checkBox", iFontId
    wsWidget.SetFontByName "radioButton", iFontId
    wsWidget.SetFontByName "progBar", iFontId
    wsWidget.SetFontByName "field", iFontId
    wsWidget.SetFontByName "listBox", iFontId
    wsWidget.SetFontByName "comboBox", iFontId
    
End Sub
See also

WStFactory::CreateCustomFont | SetText | GetText | SetTextColor | SetBackGroundColor

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