Attribute VB_Name = "FieldDemoModule" Option Explicit '--------------------------------------------------------- 'FieldDemo 'Use of the WS_FIELD widget and all its properties '--------------------------------------------------------- Public wsFactory As New WStFactory Public wsForm As New WStForm Public wsWidget As New WStWidget Public wsRfBarcode As New RFBARCODE Public sBarcodeNames(20) As String Public Sub Main() Dim bResult As Boolean Dim sObjectName As String Dim sEventValue As String Dim sEventResultText As String Dim bEnd As Boolean Dim iIntValue As Integer Dim sNewEventResult As String Dim iMaxLength As Integer Dim iKbdMode As Integer Dim x As Integer Dim y As Integer Dim cx As Integer Dim cy As Integer x = 0 y = 0 cx = 0 cy = 0 bEnd = False CreateBarcodeConfig InitNames wsFactory.CreateFormByName "myForm" wsForm.SetCoordTypeByName "myForm", WS_FORM_CT_BYPERCENTAGE wsFactory.CreateWidget WS_LABEL, 0, "FormTittle", 30, 0, 40, 5, "Field Demo" wsFactory.CreateWidget WS_BUTTON, 0, "exitButton", 2, 80, 29, 12, "Exit" wsFactory.CreateWidget WS_BUTTON, 0, "resetButton", 32, 80, 32, 12, "Reset" wsFactory.CreateWidget WS_FIELD, 0, "field", 5, 10, 44, 13, "Enter your text here" wsFactory.CreateWidget WS_LABEL, 0, "EventResult", 65, 77, 35, 17, "" 'WSScannerController modifications x = 33 y = 79 cx = 30 cy = 5 wsFactory.CreateWidget WS_LABEL, 0, "scannerLabel", x, y, cx, cy, "Scanner Ctrl" wsFactory.CreateWidget WS_CHECKBOX, 0, "enableScanCheckBox", x, y + 5, cx, cy, "Enable" wsFactory.CreateWidget WS_CHECKBOX, 0, "enableScanSoftTriggerCheckBox", x, y + 10, cx, cy, "SoftTrigger" 'LenControl Modes x = 5 y = 26 cx = 48 cy = 5 wsFactory.CreateWidget WS_CHECKBOX, 0, "forceEntryCheckBox", x, y, cx, cy, "ForceEntry" wsFactory.CreateWidget WS_CHECKBOX, 0, "noCrIfEmptyCheckBox", x, y + 5, cx, cy, "NoCrIfEmpty" wsFactory.CreateWidget WS_CHECKBOX, 0, "noReturnOnFillCheckBox", x, y + 10, cx, cy, "NoReturnOnFill" wsFactory.CreateWidget WS_CHECKBOX, 0, "noReturnOnBkspCheckBox", x, y + 15, cx, cy, "NoReturnOnBksp" 'Input modes x = 54 y = 10 cx = 45 cy = 5 wsFactory.CreateWidget WS_CHECKBOX, 0, "multiLineCheckBox", x, y, cx, cy, "MultiLine" wsFactory.CreateWidget WS_CHECKBOX, 0, "passwordCheckBox", x, y + 5, cx, cy, "Password" wsFactory.CreateWidget WS_CHECKBOX, 0, "disableScanCheckBox", x, y + 10, cx, cy, "Disable Scanner" wsFactory.CreateWidget WS_CHECKBOX, 0, "disableKeysCheckBox", x, y + 15, cx, cy, "Disable Keys" wsFactory.CreateWidget WS_CHECKBOX, 0, "softTriggerCheckBox", x, y + 20, cx, cy, "SoftTrigger" wsFactory.CreateWidget WS_LABEL, 0, "maxLengthLabel", x, y + 30, cx, cy, "Max Length" wsFactory.CreateWidget WS_FIELD, 0, "maxLengthField", x, y + 35, 30, cy, "" wsFactory.CreateWidget WS_CHECKBOX, 0, "alphaKeysCheckBox", x, y + 45, cx, cy, "Alpha" wsFactory.CreateWidget WS_CHECKBOX, 0, "numKeysCheckBox", x, y + 50, cx, cy, "Numeric" wsFactory.CreateWidget WS_CHECKBOX, 0, "toUpperCheckBox", x, y + 55, cx, cy, "ToUpper" wsFactory.CreateWidget WS_CHECKBOX, 0, "editDefaultCheckBox", x, y + 60, cx, cy, "EditDefault" 'Function keys x = 5 y = 67 cx = 45 cy = 5 wsFactory.CreateWidget WS_CHECKBOX, 0, "disableFnKeysCheckBox", x, y, cx, cy, "Disable FnKeys" wsFactory.CreateWidget WS_CHECKBOX, 0, "mapArrowKeysCheckBox", x, y + 5, cx, cy, "Map Arrow Keys" 'Keyboard state x = 5 y = 49 cx = 45 cy = 5 wsFactory.CreateWidget WS_RADIO_BUTTON, 0, "keepKbdStateRdBtn", x, y, cx, cy, "Keep Kbd State" wsFactory.CreateWidget WS_RADIO_BUTTON, 0, "numericKbdRdBtn", x, y + 5, cx, cy, "Numberic Kbd" wsFactory.CreateWidget WS_RADIO_BUTTON, 0, "alphaKbdRdBtn", x, y + 10, cx, cy, "Alpha Kbd" 'Widgets customization 'Set a group for the radio buttons wsWidget.SetGroupIdByName "keepKbdStateRdBtn", 1 wsWidget.SetGroupIdByName "numericKbdRdBtn", 1 wsWidget.SetGroupIdByName "alphaKbdRdBtn", 1 wsWidget.SetStateByName "keepKbdStateRdBtn", WS_STATE_CHECKED 'Fonts and icons wsFactory.CreateCustomFont 1, 14, True, False, False, "Times New Roman", WS_CENTER wsFactory.CreateCustomFont 2, 13, False, False, False, "Arial", WS_LEFT 'Exit icon wsFactory.LoadExternalIcon 3, WS_EXIT, "iconlib.dll" 'Reset icon wsFactory.LoadExternalIcon 4, WS_RELOAD, "iconlib.dll" wsWidget.SetIconByName "exitButton", 3 wsWidget.SetIconByName "resetButton", 4 wsWidget.SetFontByName "FormTittle", 1 wsWidget.SetFontByName "exitButton", 1 wsWidget.ModifyInputModeByName "maxLengthField", 0, WS_FIELD_IM_NUMERIC_ONLY wsWidget.ModifyLenCtrlModeByName "maxLengthField", 0, WS_FIELD_LC_FORCE_ENTRY wsWidget.SetMaxLengthByName "maxLengthField", 2 wsWidget.ModifyInputDevicesByName "maxLengthField", 0, WS_FIELD_ID_DISABLE_SCAN wsWidget.SetKeyboardModeByName "maxLengthField", WS_FIELD_KM_NUMERIC wsWidget.SetScannerConfigFileByName "field", "FieldDemo" iKbdMode = WS_FIELD_KM_KEEP_STATE wsWidget.SetKeyboardModeByName "field", iKbdMode 'Widgets attachment wsForm.AddObjectByName "myForm", "FormTittle" wsForm.AddObjectByName "myForm", "exitButton" wsForm.AddObjectByName "myForm", "scannerLabel" wsForm.AddObjectByName "myForm", "enableScanCheckBox" wsForm.AddObjectByName "myForm", "enableScanSoftTriggerCheckBox" wsForm.AddObjectByName "myForm", "field" wsForm.AddObjectByName "myForm", "EventResult" wsForm.AddObjectByName "myForm", "multiLineCheckBox" wsForm.AddObjectByName "myForm", "passwordCheckBox" wsForm.AddObjectByName "myForm", "disableScanCheckBox" wsForm.AddObjectByName "myForm", "disableKeysCheckBox" wsForm.AddObjectByName "myForm", "disableFnKeysCheckBox" wsForm.AddObjectByName "myForm", "mapArrowKeysCheckBox" wsForm.AddObjectByName "myForm", "softTriggerCheckBox" wsForm.AddObjectByName "myForm", "alphaKeysCheckBox" wsForm.AddObjectByName "myForm", "numKeysCheckBox" wsForm.AddObjectByName "myForm", "toUpperCheckBox" wsForm.AddObjectByName "myForm", "editDefaultCheckBox" wsForm.AddObjectByName "myForm", "forceEntryCheckBox" wsForm.AddObjectByName "myForm", "noCrIfEmptyCheckBox" wsForm.AddObjectByName "myForm", "noReturnOnFillCheckBox" wsForm.AddObjectByName "myForm", "noReturnOnBkspCheckBox" wsForm.AddObjectByName "myForm", "keepKbdStateRdBtn" wsForm.AddObjectByName "myForm", "numericKbdRdBtn" wsForm.AddObjectByName "myForm", "alphaKbdRdBtn" wsForm.AddObjectByName "myForm", "maxLengthLabel" wsForm.AddObjectByName "myForm", "maxLengthField" 'Font configuration wsWidget.SetFontByName "multiLineCheckBox", 2 wsWidget.SetFontByName "passwordCheckBox", 2 wsWidget.SetFontByName "disableScanCheckBox", 2 wsWidget.SetFontByName "disableKeysCheckBox", 2 wsWidget.SetFontByName "disableFnKeysCheckBox", 2 wsWidget.SetFontByName "mapArrowKeysCheckBox", 2 wsWidget.SetFontByName "softTriggerCheckBox", 2 wsWidget.SetFontByName "alphaKeysCheckBox", 2 wsWidget.SetFontByName "numKeysCheckBox", 2 wsWidget.SetFontByName "toUpperCheckBox", 2 wsWidget.SetFontByName "editDefaultCheckBox", 2 wsWidget.SetFontByName "forceEntryCheckBox", 2 wsWidget.SetFontByName "noCrIfEmptyCheckBox", 2 wsWidget.SetFontByName "noReturnOnFillCheckBox", 2 wsWidget.SetFontByName "noReturnOnBkspCheckBox", 2 wsWidget.SetFontByName "keepKbdStateRdBtn", 2 wsWidget.SetFontByName "numericKbdRdBtn", 2 wsWidget.SetFontByName "alphaKbdRdBtn", 2 wsWidget.SetFontByName "maxLengthLabel", 2 wsWidget.SetFontByName "EventResult", 2 wsWidget.SetFontByName "maxLengthField", 2 wsWidget.SetFontByName "field", 2 wsWidget.SetFontByName "enableScanCheckBox", 2 wsWidget.SetFontByName "enableScanSoftTriggerCheckBox", 2 wsWidget.SetFontByName "scannerLabel", 2 wsWidget.SetStateByName "enableScanCheckBox", WS_STATE_CHECKED wsWidget.EnableByName "WSScannerController", True 'wsForm.SetFocusByName "myForm", "field" wsWidget.ModifyInputDevicesByName "field", 0, WS_FIELD_ID_VIRTUAL_KEYB bResult = wsForm.ShowByName("myForm", True, True) 'Waits for an event and performs an action 'Most of the events received are triggered by checkboxes,that allow the user to modify 'the flags related to the WS_FIELD widget While (bEnd = False And bResult And wsForm.IsConnected) bResult = wsForm.GetEvent() iIntValue = wsForm.GetLastEventIntValue() sObjectName = wsForm.GetLastEventSourceName() Select Case sObjectName Case "field" sEventResultText = "Field input: " + wsWidget.GetTextByName("field") If wsWidget.GetLastInputTypeByName("field") = WLSCANTYPE Then sEventResultText = sEventResultText + " BCT: " + _ sBarcodeNames(wsWidget.GetLastBarcodeTypeByName("field")) End If wsWidget.SetTextByName "EventResult", sEventResultText wsWidget.SetTextByName "field", "" Case "WSScannerController" sEventResultText = "Scanner input: " + wsWidget.GetTextByName("WSScannerController") _ + " BCT: " + sBarcodeNames(wsWidget.GetLastBarcodeTypeByName("WSScannerController")) wsWidget.SetTextByName "EventResult", sEventResultText Case "WSFunctionKeysController" wsWidget.SetTextByName "field", "" wsWidget.SetTextByName "EventResult", "Function Key: " + _ ProcessFunctionKey(wsWidget.GetTextByName("WSFunctionKeysController")) Case "enableScanCheckBox" wsWidget.EnableByName "WSScannerController", wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Case "enableScanSoftTriggerCheckBox" wsWidget.EnableSoftTriggerByName "WSScannerController", wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Case "multiLineCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsWidget.ModifyDisplayModeByName "field", 0, WS_FIELD_DM_MULTILINE Else wsWidget.ModifyDisplayModeByName "field", WS_FIELD_DM_MULTILINE, 0 End If Case "passwordCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsWidget.ModifyDisplayModeByName "field", 0, WS_FIELD_DM_ECHO_ASTERISK Else wsWidget.ModifyDisplayModeByName "field", WS_FIELD_DM_ECHO_ASTERISK, 0 End If Case "disableScanCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsWidget.ModifyInputDevicesByName "field", 0, WS_FIELD_ID_DISABLE_SCAN Else wsWidget.ModifyInputDevicesByName "field", WS_FIELD_ID_DISABLE_SCAN, 0 End If Case "disableKeysCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsWidget.ModifyInputDevicesByName "field", 0, WS_FIELD_ID_DISABLE_KEY Else wsWidget.ModifyInputDevicesByName "field", WS_FIELD_ID_DISABLE_KEY, 0 End If Case "disableFnKeysCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsForm.EnableFunctionKeysByName "myForm", False Else wsForm.EnableFunctionKeysByName "myForm", True End If Case "mapArrowKeysCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsForm.MapArrowKeysToFunctionKeysByName "myForm", True Else wsForm.MapArrowKeysToFunctionKeysByName "myForm", False End If Case "softTriggerCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsWidget.ModifyInputDevicesByName "field", 0, WS_FIELD_ID_SOFT_TRIGGER Else wsWidget.ModifyInputDevicesByName "field", WS_FIELD_ID_SOFT_TRIGGER, 0 End If Case "alphaKeysCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsWidget.ModifyInputModeByName "field", 0, WS_FIELD_IM_ALPHA_ONLY Else wsWidget.ModifyInputModeByName "field", WS_FIELD_IM_ALPHA_ONLY, 0 End If Case "numKeysCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsWidget.ModifyInputModeByName "field", 0, WS_FIELD_IM_NUMERIC_ONLY Else wsWidget.ModifyInputModeByName "field", WS_FIELD_IM_NUMERIC_ONLY, 0 End If Case "toUpperCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsWidget.ModifyInputModeByName "field", 0, WS_FIELD_IM_TO_UPPER Else wsWidget.ModifyInputModeByName "field", WS_FIELD_IM_TO_UPPER, 0 End If Case "editDefaultCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsWidget.ModifyInputModeByName "field", 0, WS_FIELD_IM_EDIT_DEFAULT Else wsWidget.ModifyInputModeByName "field", WS_FIELD_IM_EDIT_DEFAULT, 0 End If Case "forceEntryCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsWidget.ModifyLenCtrlModeByName "field", 0, WS_FIELD_LC_FORCE_ENTRY Else wsWidget.ModifyLenCtrlModeByName "field", WS_FIELD_LC_FORCE_ENTRY, 0 End If Case "noCrIfEmptyCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsWidget.ModifyLenCtrlModeByName "field", 0, WS_FIELD_LC_NO_CR_IF_EMPTY Else wsWidget.ModifyLenCtrlModeByName "field", WS_FIELD_LC_NO_CR_IF_EMPTY, 0 End If Case "noReturnOnFillCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsWidget.ModifyLenCtrlModeByName "field", 0, WS_FIELD_LC_NO_RETURN_ON_FILL Else wsWidget.ModifyLenCtrlModeByName "field", WS_FIELD_LC_NO_RETURN_ON_FILL, 0 End If Case "noReturnOnBkspCheckBox" If wsForm.GetLastEventIntValue() = WS_STATE_CHECKED Then wsWidget.ModifyLenCtrlModeByName "field", 0, WS_FIELD_LC_NO_RETURN_ON_BKSP Else wsWidget.ModifyLenCtrlModeByName "field", WS_FIELD_LC_NO_RETURN_ON_BKSP, 0 End If Case "maxLengthField" iMaxLength = wsForm.GetLastEventStrValue() wsWidget.SetMaxLengthByName "field", iMaxLength End Select If wsWidget.GetStateByName("keepKbdStateRdBtn") = WS_STATE_CHECKED Then iKbdMode = WS_FIELD_KM_KEEP_STATE ElseIf wsWidget.GetStateByName("numericKbdRdBtn") = WS_STATE_CHECKED Then iKbdMode = WS_FIELD_KM_NUMERIC ElseIf wsWidget.GetStateByName("alphaKbdRdBtn") = WS_STATE_CHECKED Then iKbdMode = WS_FIELD_KM_ALPHABETIC End If wsWidget.SetKeyboardModeByName "field", iKbdMode If sObjectName = "exitButton" Or iIntValue = WS_ESC Then bEnd = True End If 'If sObjectName <> "field" Then ' wsForm.SetFocusByName "myForm", "field" 'End If Wend End Sub Sub CreateBarcodeConfig() 'Creates the barcode configuration wsRfBarcode.ClearBarcodes ' Clear all barcodes wsRfBarcode.AddBarcode UPC_E0, False, DECODEON, 6, 6 wsRfBarcode.AddBarcode UPC_E1, False, DECODEON, 10, 10 wsRfBarcode.AddBarcode UPC_A, False, DECODEON, 12, 12 wsRfBarcode.AddBarcode EAN_8, False, DECODEON, 8, 8 wsRfBarcode.AddBarcode EAN_13, False, DECODEON, 13, 13 wsRfBarcode.AddBarcode CODABAR, False, DECODEON, 2, 12 wsRfBarcode.AddBarcode CODE_39, False, DECODEON, 1, 32 wsRfBarcode.AddBarcode CODE_I25, False, DECODEON, 2, 20 wsRfBarcode.AddBarcode CODE_93, False, DECODEON, 2, 14 wsRfBarcode.AddBarcode CODE_128, False, DECODEON, 1, 32 wsRfBarcode.StoreBarcode "FieldDemo", BCDISABLED End Sub ' Init the Barcode names array (to display it) Sub InitNames() sBarcodeNames(0) = "UPC_E0 " sBarcodeNames(1) = "UPC_E1 " sBarcodeNames(2) = "UPC_A " sBarcodeNames(3) = "MSI " sBarcodeNames(4) = "EAN_8 " sBarcodeNames(5) = "EAN_13 " sBarcodeNames(6) = "CODABAR " sBarcodeNames(7) = "CODE_39 " sBarcodeNames(8) = "CODE_D25" sBarcodeNames(9) = "CODE_I25" sBarcodeNames(10) = "CODE_11 " sBarcodeNames(11) = "CODE_93 " sBarcodeNames(12) = "CODE_128" sBarcodeNames(13) = "PDF_417 " sBarcodeNames(14) = "D25_IATA" sBarcodeNames(15) = "UCC_128 " sBarcodeNames(17) = "B_UPC " sBarcodeNames(18) = "TO_39 " sBarcodeNames(19) = "DATA_MATRIX" End Sub Public Function ProcessFunctionKey(sFunctionKey As String) As String Dim iFunctionKey As Integer iFunctionKey = sFunctionKey Select Case (iFunctionKey) Case WSFunctionKeys.WS_F1 ProcessFunctionKey = "WS_F1" Case WSFunctionKeys.WS_F2 ProcessFunctionKey = "WS_F2" Case WSFunctionKeys.WS_F3 ProcessFunctionKey = "WS_F3" Case WSFunctionKeys.WS_F4 ProcessFunctionKey = "WS_F4" Case WSFunctionKeys.WS_F5 ProcessFunctionKey = "WS_F5" Case Else ProcessFunctionKey = "Greater than WS_F5" End Select End Function