Attribute VB_Name = "ButtonDemoModule" Option Explicit '------------------------------------------------------------------------------------ 'Button Demo 'Shows the how the WS_BUTTON widget can be customized '------------------------------------------------------------------------------------ Public wsFactory As New WStFactory Public wsForm As New WStForm Public wsWidget As New WStWidget Public bResult As Boolean Public Sub Main() Dim sObjectName As String Dim bEnd As Boolean 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, 15, "Button Demo" wsFactory.CreateWidget WS_BUTTON, 0, "exitButton", 30, 75, 37, 15, "Exit" wsFactory.CreateWidget WS_BUTTON, 0, "buttonTest1", 5, 15, 40, 15, "Button Test 1" wsFactory.CreateWidget WS_BUTTON, 0, "buttonTest2", 5, 35, 40, 15, "Button Test 2" wsFactory.CreateWidget WS_BUTTON, 0, "buttonTest3", 5, 55, 40, 15, "Button Test 3" wsFactory.CreateWidget WS_BUTTON, 0, "buttonTest4", 55, 15, 40, 15, "Button Test 4" wsFactory.CreateWidget WS_BUTTON, 0, "buttonTest5", 55, 35, 40, 15, "Button Test 5" wsFactory.CreateWidget WS_BUTTON, 0, "buttonTest6", 55, 55, 40, 15, "Button Test 6" 'Used icons wsFactory.LoadExternalIcon 1, WS_BOX, "iconlib.dll" wsFactory.LoadExternalIcon 2, WS_UPLOAD, "iconlib.dll" wsFactory.LoadExternalIcon 3, WS_BACK, "iconlib.dll" wsFactory.LoadExternalIcon 4, WS_VALIDATE, "iconlib.dll" wsFactory.LoadExternalIcon 5, WS_OK, "iconlib.dll" wsFactory.LoadExternalIcon 6, WS_ERROR, "iconlib.dll" wsFactory.LoadExternalIcon 7, WS_EXIT, "iconlib.dll" wsWidget.SetIconByName "exitButton", 7 'Widgets Attachment wsForm.AddObjectByName "myForm", "formTittle" wsForm.AddObjectByName "myForm", "exitButton" wsForm.AddObjectByName "myForm", "buttonTest1" wsForm.AddObjectByName "myForm", "buttonTest2" wsForm.AddObjectByName "myForm", "buttonTest3" wsForm.AddObjectByName "myForm", "buttonTest4" wsForm.AddObjectByName "myForm", "buttonTest5" wsForm.AddObjectByName "myForm", "buttonTest6" 'Button Test 1: Blue background, Blue font wsWidget.SetTextColorByName "buttonTest1", 0, 0, 119 wsWidget.SetBackGroundColorByName "buttonTest1", 184, 202, 241 wsWidget.SetIconByName "buttonTest1", 1 wsWidget.ShowBorderByName "buttonTest1", False wsWidget.EnableFlatStyleByName "buttonTest1", True 'Button Test 2: White background, blue font wsWidget.SetTextColorByName "buttonTest2", 0, 0, 160 wsWidget.SetBackGroundColorByName "buttonTest2", 255, 255, 255 wsWidget.SetIconByName "buttonTest2", 2 'Button Test 3: Border and Courier New font wsFactory.CreateCustomFont 1, 17, False, False, False, "Courier New", WS_CENTER wsWidget.SetFontByName "buttonTest3", 1 wsWidget.SetIconByName "buttonTest3", 3 wsWidget.ShowBorderByName "buttonTest3", False 'Button Test 4: Courier New green, Italic, Bold font wsFactory.CreateCustomFont 2, 17, True, True, False, "Courier New", WS_RIGHT wsWidget.SetFontByName "buttonTest4", 2 wsWidget.SetTextColorByName "buttonTest4", 0, 0, 160 wsWidget.EnableFlatStyleByName "buttonTest4", True wsWidget.SetIconByName "buttonTest4", 4 'Button Test 5: Times New Roman Bold font wsFactory.CreateCustomFont 3, 18, True, False, False, "Times New Roman", WS_LEFT wsWidget.SetFontByName "buttonTest5", 3 wsWidget.SetTextColorByName "buttonTest5", 0, 0, 102 wsWidget.SetBackGroundColorByName "buttonTest5", 183, 183, 255 wsWidget.EnableFlatStyleByName "buttonTest5", True wsWidget.SetIconByName "buttonTest5", 5 wsWidget.ShowBorderByName "buttonTest5", False 'Button Test 6: Tahoma underlined font wsFactory.CreateCustomFont 4, 16, False, False, True, "Times New Roman", WS_LEFT wsWidget.SetFontByName "buttonTest6", 4 wsWidget.SetTextColorByName "buttonTest6", 240, 244, 244 wsWidget.SetBackGroundColorByName "buttonTest6", 78, 187, 89 wsWidget.EnableFlatStyleByName "buttonTest6", True wsWidget.SetIconByName "buttonTest6", 6 wsWidget.ShowBorderByName "buttonTest6", False bResult = wsForm.ShowByName("myForm", True, True) 'Waits for an event and perform an action While (bEnd = False And bResult) bResult = wsForm.GetEvent() If wsForm.GetLastEventSourceName() = "exitButton" Or _ wsForm.GetLastEventSourceName() = "WSFunctionKeysController" Then bEnd = True End If Wend End Sub