Attribute VB_Name = "BasicPropertiesDemoModule" Option Explicit '------------------------------------------------------------------------ 'Basic Properties Demo 'Shows how some basic properties of the widgets can be 'modified to change its appearance and behaviour in any application '------------------------------------------------------------------------ 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 bEnabled As Boolean Dim bShowBorder As Boolean Dim bShowWaitCursor As Boolean Dim bVisible As Boolean Dim iWidth As Integer Dim iHeight As Integer Dim iFontId As Integer bEnabled = True bVisible = True bShowBorder = True bEnd = False bShowWaitCursor = False iWidth = 7 iHeight = 2 'Form creation and customization wsFactory.CreateFormByName "myForm" wsForm.SetCoordTypeByName "myForm", WS_FORM_CT_BYPERCENTAGE 'Widgets creation 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, "" wsFactory.CreateWidget WS_BUTTON, 0, "button", 5, 7, 42, 12, "Button" wsFactory.CreateWidget WS_LABEL, 0, "label", 5, 20, 42, 12, "Label" wsFactory.CreateWidget WS_CHECKBOX, 0, "checkBox", 5, 32, 42, 12, "CheckBox" wsFactory.CreateWidget WS_MENU, 0, "comboBox", 5, 44, 42, 20, "" wsFactory.CreateWidget WS_RADIO_BUTTON, 0, "radioButton", 53, 7, 42, 12, "Radio Button" wsFactory.CreateWidget WS_PROGRESS_BAR, 0, "progBar", 53, 20, 42, 12, "Prog. Bar " wsFactory.CreateWidget WS_FIELD, 0, "field", 53, 32, 42, 12, "Field" wsFactory.CreateWidget WS_MENU, 0, "listBox", 53, 44, 42, 12, "" wsFactory.CreateWidget WS_LINE, 0, "bottomLine", 5, 56, 90, 1, "" wsFactory.CreateWidget WS_CHECKBOX, 0, "visibleCheckBox", 5, 58, 26, 5, "Visible" wsFactory.CreateWidget WS_CHECKBOX, 0, "enableCheckBox", 5, 63, 26, 5, "Enabled" wsFactory.CreateWidget WS_CHECKBOX, 0, "showBorderCheckBox", 5, 69, 26, 5, "Border" wsFactory.CreateWidget WS_CHECKBOX, 0, "showWaitCursorCheckBox", 5, 75, 35, 5, "Wait Cursor" wsFactory.CreateWidget WS_LABEL, 0, "sizeLabel", 65, 58, 30, 5, "Size (In %)" wsFactory.CreateWidget WS_MENU, 0, "sizeComboBox", 65, 63, 30, 20, "" wsFactory.CreateWidget WS_LABEL, 0, "fontLabel", 65, 69, 30, 5, "Font" wsFactory.CreateWidget WS_MENU, 0, "fontComboBox", 65, 74, 30, 20, "" wsFactory.CreateWidget WS_LABEL, 0, "positionLabel", 35, 58, 25, 5, "Position" wsFactory.CreateWidget WS_BUTTON, 0, "moveLeftBtn", 35, 63, 6, 5, "<" wsFactory.CreateWidget WS_BUTTON, 0, "moveRightBtn", 41, 63, 6, 5, ">" 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", "formTittle" wsForm.AddObjectByName "myForm", "exitButton" wsForm.AddObjectByName "myForm", "resetButton" wsForm.AddObjectByName "myForm", "topLine" wsForm.AddObjectByName "myForm", "button" wsForm.AddObjectByName "myForm", "label" wsForm.AddObjectByName "myForm", "checkBox" wsForm.AddObjectByName "myForm", "radioButton" wsForm.AddObjectByName "myForm", "progBar" wsForm.AddObjectByName "myForm", "field" wsForm.AddObjectByName "myForm", "listBox" wsForm.AddObjectByName "myForm", "comboBox" wsForm.AddObjectByName "myForm", "bottomLine" wsForm.AddObjectByName "myForm", "visibleCheckBox" wsForm.AddObjectByName "myForm", "enableCheckBox" wsForm.AddObjectByName "myForm", "showBorderCheckBox" wsForm.AddObjectByName "myForm", "showWaitCursorCheckBox" wsForm.AddObjectByName "myForm", "positionLabel" wsForm.AddObjectByName "myForm", "moveLeftBtn" wsForm.AddObjectByName "myForm", "moveRightBtn" wsForm.AddObjectByName "myForm", "moveUpBtn" wsForm.AddObjectByName "myForm", "moveDownBtn" wsForm.AddObjectByName "myForm", "sizeLabel" wsForm.AddObjectByName "myForm", "sizeComboBox" wsForm.AddObjectByName "myForm", "fontLabel" wsForm.AddObjectByName "myForm", "fontComboBox" 'Widgets customization 'Exit icon wsFactory.LoadExternalIcon 4, WS_EXIT, "iconlib.dll" 'Reset icon wsFactory.LoadExternalIcon 3, WS_RELOAD, "iconlib.dll" wsWidget.SetIconByName "exitButton", 4 wsWidget.SetIconByName "resetButton", 3 'Changes the color of both top and bottom lines wsWidget.SetTextColorByName "topLine", 229, 229, 229 wsWidget.SetTextColorByName "bottomLine", 229, 229, 229 wsWidget.SetBarPositionByName "progBar", 60 wsWidget.SetStateByName "visibleCheckBox", WS_STATE_CHECKED wsWidget.SetStateByName "enableCheckBox", WS_STATE_CHECKED wsWidget.SetStateByName "showBorderCheckBox", WS_STATE_CHECKED wsWidget.SetStateByName "showWaitCursorCheckBox", WS_STATE_UNCHECKED ShowBorder bShowBorder wsWidget.ChangeMenuTypeByName "listBox", WS_LIST_BOX_MENU_TYPE wsWidget.ChangeMenuTypeByName "comboBox", WS_COMBO_BOX_MENU_TYPE 'Fulfills the listBox and comboBox widgets FillOptions "listBox" FillOptions "comboBox" 'Available sizes wsWidget.ChangeMenuTypeByName "sizeComboBox", WS_COMBO_BOX_MENU_TYPE wsWidget.AddOptionByName "sizeComboBox", 0, "30 x 5" wsWidget.AddOptionByName "sizeComboBox", 0, "42 x 12 (Default)" wsWidget.AddOptionByName "sizeComboBox", 0, "15 x 12" 'Available Fonts wsWidget.ChangeMenuTypeByName "fontComboBox", WS_COMBO_BOX_MENU_TYPE 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 wsWidget.AddOptionByName "fontComboBox", 0, "Times New Roman" wsWidget.AddOptionByName "fontComboBox", 0, "Tahoma" wsWidget.AddOptionByName "fontComboBox", 0, "Courier New" bResult = wsForm.ShowByName("myForm", True, True) 'Waits for an event and perform an action While (bEnd = False And bResult And wsFactory.IsConnected) bResult = wsForm.GetEvent() sObjectName = wsForm.GetLastEventSourceName() Select Case sObjectName 'If any function key is pressed or the exit button is pressed 'the loop is ended Case "WSFunctionKeysController" bEnd = True Case "exitButton" bEnd = True Case "resetButton" wsForm.RestoreInitialState bEnabled = True bVisible = True bShowBorder = True bShowWaitCursor = False 'Hides or shows the widgets Case "visibleCheckBox" bVisible = Not bVisible wsWidget.ShowByName "topLine", bVisible wsWidget.ShowByName "button", bVisible wsWidget.ShowByName "label", bVisible wsWidget.ShowByName "checkBox", bVisible wsWidget.ShowByName "radioButton", bVisible wsWidget.ShowByName "progBar", bVisible wsWidget.ShowByName "field", bVisible wsWidget.ShowByName "listBox", bVisible wsWidget.ShowByName "comboBox", bVisible wsWidget.ShowByName "bottomLine", bVisible 'Enable and disables the widgets Case "enableCheckBox" bEnabled = Not bEnabled wsWidget.EnableByName "topLine", bEnabled wsWidget.EnableByName "button", bEnabled wsWidget.EnableByName "label", bEnabled wsWidget.EnableByName "checkBox", bEnabled wsWidget.EnableByName "radioButton", bEnabled wsWidget.EnableByName "progBar", bEnabled wsWidget.EnableByName "field", bEnabled wsWidget.EnableByName "listBox", bEnabled wsWidget.EnableByName "comboBox", bEnabled wsWidget.EnableByName "bottomLine", bEnabled Case "showBorderCheckBox" bShowBorder = Not bShowBorder ShowBorder bShowBorder Case "showWaitCursorCheckBox" bShowWaitCursor = Not bShowWaitCursor wsForm.ShowWaitCursorByName "myForm", bShowWaitCursor 'Change the widget's size Case "sizeComboBox" ChangeSize (wsWidget.GetSelectedItemByName("sizeComboBox")) 'Changes the widget's font Case "fontComboBox" ChangeFont (wsWidget.GetSelectedItemByName("fontComboBox")) 'Move the widgets Case "moveLeftBtn" ChangePosition -1, 0 Case "moveRightBtn" ChangePosition 1, 0 Case "moveUpBtn" ChangePosition 0, -1 Case "moveDownBtn" ChangePosition 0, 1 End Select Wend End Sub Public Sub FillOptions(sMenuName As String) Dim i As Integer Dim sOptionIndex As String For i = 1 To 20 sOptionIndex = i wsWidget.AddOptionByName sMenuName, 0, "Option " + sOptionIndex Next i End Sub 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 Public Sub ChangeSize(iSelectedOption As Integer) Dim iWidth As Integer Dim iHeight As Integer Select Case iSelectedOption Case 0 iWidth = 30 iHeight = 5 Case 1 iWidth = 42 iHeight = 12 Case 2 iWidth = 15 iHeight = 12 Case -1 iWidth = 42 iHeight = 12 End Select If wsWidget.GetWidthByName("button") = iWidth And _ wsWidget.GetHeightByName("button") = iHeight Then Exit Sub End If wsWidget.SetSizeByName "button", iWidth, iHeight wsWidget.SetSizeByName "label", iWidth, iHeight wsWidget.SetSizeByName "checkBox", iWidth, iHeight wsWidget.SetSizeByName "radioButton", iWidth, iHeight wsWidget.SetSizeByName "progBar", iWidth, iHeight wsWidget.SetSizeByName "field", iWidth, iHeight wsWidget.SetSizeByName "listBox", iWidth, iHeight wsWidget.SetSizeByName "comboBox", iWidth, iHeight + 2 End Sub Public Sub ChangePosition(iXOffset As Integer, iYOffset As Integer) wsWidget.SetPositionByName "topLine", wsWidget.GetXCoordByName("topLine") + iXOffset, _ wsWidget.GetYCoordByName("topLine") + iYOffset wsWidget.SetPositionByName "button", wsWidget.GetXCoordByName("button") + iXOffset, _ wsWidget.GetYCoordByName("button") + iYOffset wsWidget.SetPositionByName "label", wsWidget.GetXCoordByName("label") + iXOffset, _ wsWidget.GetYCoordByName("label") + iYOffset wsWidget.SetPositionByName "checkBox", wsWidget.GetXCoordByName("checkBox") + iXOffset, _ wsWidget.GetYCoordByName("checkBox") + iYOffset wsWidget.SetPositionByName "radioButton", wsWidget.GetXCoordByName("radioButton") + iXOffset, _ wsWidget.GetYCoordByName("radioButton") + iYOffset wsWidget.SetPositionByName "progBar", wsWidget.GetXCoordByName("progBar") + iXOffset, _ wsWidget.GetYCoordByName("progBar") + iYOffset wsWidget.SetPositionByName "field", wsWidget.GetXCoordByName("field") + iXOffset, _ wsWidget.GetYCoordByName("field") + iYOffset wsWidget.SetPositionByName "listBox", wsWidget.GetXCoordByName("listBox") + iXOffset, _ wsWidget.GetYCoordByName("listBox") + iYOffset wsWidget.SetPositionByName "comboBox", wsWidget.GetXCoordByName("comboBox") + iXOffset, _ wsWidget.GetYCoordByName("comboBox") + iYOffset wsWidget.SetPositionByName "bottomLine", wsWidget.GetXCoordByName("bottomLine") + iXOffset, _ wsWidget.GetYCoordByName("bottomLine") + iYOffset End Sub Public Sub ShowBorder(bShow As Boolean) wsWidget.ShowBorderByName "topLine", bShow wsWidget.ShowBorderByName "button", bShow wsWidget.ShowBorderByName "label", bShow wsWidget.ShowBorderByName "checkBox", bShow wsWidget.ShowBorderByName "radioButton", bShow wsWidget.ShowBorderByName "progBar", bShow wsWidget.ShowBorderByName "field", bShow wsWidget.ShowBorderByName "listBox", bShow wsWidget.ShowBorderByName "comboBox", bShow wsWidget.ShowBorderByName "bottomLine", bShow End Sub