Attribute VB_Name = "LabelDemoModule" Option Explicit '--------------------------------------------------------- 'Label Demo 'Shows different uses of the WS_LABEL widget '--------------------------------------------------------- Public wsFactory As New WStFactory Public wsForm As New WStForm Public wsWidget As New WStWidget Public Sub Main() Dim bResult As Boolean Dim sObjectName As String Dim bEnd As Boolean Dim width As Integer Dim height As Integer Dim x As Integer Dim y As Integer Dim offset As Integer bEnd = False 'Form creation and customization wsFactory.CreateFormByName "myForm" wsForm.SetCoordTypeByName "myForm", WS_FORM_CT_BYPERCENTAGE 'Widgets creation wsFactory.CreateWidget WS_LABEL, 0, "formTittle", 35, 0, 40, 9, "Label Demo" wsFactory.CreateWidget WS_BUTTON, 0, "exitButton", 30, 80, 37, 12, "Exit" x = 10 y = 10 width = 35 height = 15 offset = height + 2 wsFactory.CreateWidget WS_LABEL, 0, "labelTest1", x, y, width, height, "Label Test 1" wsFactory.CreateWidget WS_LABEL, 0, "labelTest2", x, y + offset, width, height, "Label Test 2" wsFactory.CreateWidget WS_LABEL, 0, "labelTest3", x, y + offset * 2, width, height, "Label Test 3" wsFactory.CreateWidget WS_LABEL, 0, "labelTest7", x, y + offset * 3, width, height, "Label Test 7" x = 55 y = 10 wsFactory.CreateWidget WS_LABEL, 0, "labelTest4", x, y, width, height, "Label Test 4" wsFactory.CreateWidget WS_LABEL, 0, "labelTest5", x, y + offset, width, height, "Label Test 5" wsFactory.CreateWidget WS_LABEL, 0, "labelTest6", x, y + offset * 2, width, height, "Label Test 6" wsFactory.CreateWidget WS_LABEL, 0, "labelTest8", x, y + offset * 3, width, height, "Label Test 8" 'Icons wsFactory.LoadExternalIcon 3, WS_EXIT, "iconlib.dll" wsWidget.SetIconByName "exitButton", 3 'Widget attachment wsForm.AddObjectByName "myForm", "formTittle" wsForm.AddObjectByName "myForm", "exitButton" wsForm.AddObjectByName "myForm", "labelTest1" wsForm.AddObjectByName "myForm", "labelTest2" wsForm.AddObjectByName "myForm", "labelTest3" wsForm.AddObjectByName "myForm", "labelTest4" wsForm.AddObjectByName "myForm", "labelTest5" wsForm.AddObjectByName "myForm", "labelTest6" wsForm.AddObjectByName "myForm", "labelTest7" wsForm.AddObjectByName "myForm", "labelTest8" 'label Test 1: Black background, yellow font wsWidget.SetTextColorByName "labelTest1", 255, 255, 0 wsWidget.SetBackGroundColorByName "labelTest1", 0, 0, 0 'label Test 2: White background, blue font wsWidget.SetTextColorByName "labelTest2", 0, 0, 160 wsWidget.SetBackGroundColorByName "labelTest2", 255, 255, 255 'label Test 3: Border and Courier New font wsFactory.CreateCustomFont 1, 17, False, False, False, "Courier New", WS_CENTER wsWidget.SetFontByName "labelTest3", 1 wsWidget.ShowBorderByName "labelTest3", True 'label Test 4: Courier New green, Italic, Bold font wsFactory.CreateCustomFont 2, 17, True, True, False, "Courier New", WS_RIGHT wsWidget.ShowBorderByName "labelTest4", True wsWidget.SetFontByName "labelTest4", 2 wsWidget.SetTextColorByName "labelTest4", 255, 0, 0 'label Test 5: Times New Roman Bold font wsFactory.CreateCustomFont 3, 18, True, False, False, "Times New Roman", WS_LEFT wsWidget.ShowBorderByName "labelTest5", True wsWidget.SetFontByName "labelTest5", 3 wsWidget.SetTextColorByName "labelTest5", 17, 244, 11 wsWidget.SetBackGroundColorByName "labelTest5", 232, 166, 164 'label Test 6: Tahoma underlined font wsFactory.CreateCustomFont 4, 20, False, False, True, "Times New Roman", WS_CENTER wsWidget.SetFontByName "labelTest6", 4 wsWidget.SetTextColorByName "labelTest6", 255, 128, 0 wsWidget.SetBackGroundColorByName "labelTest6", 0, 0, 255 'label Test 7: Current Battery life percent display wsWidget.DisplayBatteryLifePercentByName "labelTest7", True wsWidget.SetBackGroundColorByName "labelTest7", 167, 236, 171 'label Test 8: Current Time display wsWidget.DisplayCurrentTimeByName "labelTest8", WS_TIME_FORMAT_DD_MM_YYYY_HH_MM wsWidget.SetBackGroundColorByName "labelTest8", 167, 100, 171 bResult = wsForm.ShowByName("myForm", True, True) 'Waits until the exit button is pressed While (bEnd = False And bResult) bResult = wsForm.GetEvent() If wsForm.GetLastEventSourceName() = "exitButton" Then bEnd = True End If Wend End Sub