Attribute VB_Name = "PoppuMsgDemoModule" Option Explicit '----------------------------------------------------------------------- 'PopupMessage Demo 'This demo shows the use of the method WSForm.ShowPopupMessage '----------------------------------------------------------------------- Public wsFactory As New WStFactory Public wsForm As New WStForm Public wsWidget As New WStWidget Public Sub Main() Dim sObjectName As String Dim sEventValue As String Dim sCurrentState As String Dim sState As String Dim bEnd As Boolean Dim iTimeOut As Integer Dim bResult As Boolean Dim sNextWidget As String Dim x As Integer Dim y As Integer Dim cx As Integer bEnd = False wsFactory.CreateFormByName "popupMsgForm" wsForm.SetCoordTypeByName "popupMsgForm", WS_FORM_CT_BYPERCENTAGE wsFactory.CreateWidget WS_LABEL, 0, "formTittle", 30, 0, 40, 5, "Popup Message Demo" wsFactory.CreateWidget WS_BUTTON, 0, "showPopupBtn", 5, 30, 40, 15, "Show Popup Message" wsFactory.CreateWidget WS_BUTTON, 0, "exitButton", 5, 55, 40, 15, "Exit" 'Popup configuration widgets x = 60 y = 15 cx = 35 wsFactory.CreateWidget WS_LABEL, 0, "popupTittleLabel", x, y, cx, 5, "Popup Tittle" wsFactory.CreateWidget WS_FIELD, 0, "popupTittleField", x, y + 6, cx, 20, "Test" wsFactory.CreateWidget WS_LABEL, 0, "popupLabel", x, y + 26 + 5, cx, 5, "Popup Message" wsFactory.CreateWidget WS_FIELD, 0, "popupField", x, y + 26 + 5 + 6, cx, 20, "This is a popup message" wsFactory.CreateWidget WS_LABEL, 0, "timeOutLabel", x, y + 26 + 5 + 26 + 5, cx, 5, "Time out" wsFactory.CreateWidget WS_FIELD, 0, "timeOutField", x, y + 26 + 5 + 26 + 5 + 6, cx, 6, "10" wsFactory.CreateCustomFont 1, 14, True, False, False, "Times New Roman", WS_CENTER wsFactory.LoadExternalIcon 3, WS_EXIT, "iconlib.dll" wsFactory.LoadExternalIcon 4, WS_SEARCH, "iconlib.dll" wsWidget.SetIconByName "exitButton", 3 wsWidget.SetIconByName "showPopupBtn", 4 wsWidget.ModifyDisplayModeByName "popupField", 0, WS_FIELD_DM_MULTILINE wsWidget.ModifyInputModeByName "timeOutField", 0, WS_FIELD_IM_NUMERIC_ONLY wsWidget.ModifyLenCtrlModeByName "timeOutField", 0, WS_FIELD_LC_FORCE_ENTRY wsWidget.SetMaxLengthByName "timeOutField", 2 wsForm.AddObjectByName "popupMsgForm", "formTittle" wsForm.AddObjectByName "popupMsgForm", "exitButton" wsForm.AddObjectByName "popupMsgForm", "showPopupBtn" wsForm.AddObjectByName "popupMsgForm", "popupTittleLabel" wsForm.AddObjectByName "popupMsgForm", "popupTittleField" wsForm.AddObjectByName "popupMsgForm", "popupLabel" wsForm.AddObjectByName "popupMsgForm", "popupField" wsForm.AddObjectByName "popupMsgForm", "timeOutLabel" wsForm.AddObjectByName "popupMsgForm", "timeOutField" wsWidget.SetFontByName "formTittle", 1 wsWidget.SetFontByName "exitButton", 1 wsWidget.SetIconByName "exitButton", 3 wsWidget.EnableTabStopByName "exitButton", False wsWidget.EnableTabStopByName "showPopupBtn", False 'Enables the submit mode on the main button, the texts of the ' fields attached to popupMsgForm will be sent before ' the click event on the showPopupBtn is processed wsWidget.EnableSubmitModeByName "showPopupBtn", True bResult = wsForm.ShowByName("popupMsgForm", True, True) bEnd = False iTimeOut = 0 While (bEnd = False And bResult) bResult = wsForm.GetEvent() sObjectName = wsForm.GetLastEventSourceName() If sObjectName = "showPopupBtn" Then If IsNumeric(wsWidget.GetTextByName("timeOutField")) Then iTimeOut = wsWidget.GetTextByName("timeOutField") End If bResult = wsForm.ShowPopupMessage(wsWidget.GetTextByName("popupTittleField"), _ wsWidget.GetTextByName("popupField"), iTimeOut, "") End If If sObjectName = "exitButton" Or wsForm.GetLastEventIntValue() = WS_ESC Then bEnd = True End If If wsForm.GetLastEventType() = WS_EVENT_TEXT_INPUT Then sNextWidget = wsForm.GetNextWidgetByName("popupMsgForm", sObjectName) If sNextWidget <> "" Then wsForm.SetFocusByName "popupMsgForm", sNextWidget End If End If Wend End Sub