Attribute VB_Name = "BitmapDemoModule" Option Explicit '--------------------------------------------------------- 'Bitmap Demo 'This demo show the use of th WS_BITMAP widget '--------------------------------------------------------- Public wsFactory As New WStFactory Public wsForm As New WStForm Public wsWidget As New WStWidget Public wsFile As New RFFILE Public Sub Main() Dim sObjectName As String Dim bEnd As Boolean Dim iMatchedFiles As Integer Dim bResult As Boolean Dim sRemoteTempFolder As String Dim uXCoord As Integer Dim uYCoord As Integer Dim uWidth As Integer Dim uHeight As Integer bEnd = False 'Form creation and customization wsFactory.CreateFormByName "myForm" wsForm.SetCoordTypeByName "myForm", WS_FORM_CT_BYPERCENTAGE wsForm.SetBackGroundColorByName "myForm", 236, 252, 241 uXCoord = 60 uYCoord = 30 uWidth = 35 uHeight = 12 'Widgets creation wsFactory.CreateWidget WS_LABEL, 0, "FormTittle", 33, 0, 40, 5, "Bitmap Demo" wsFactory.CreateWidget WS_BUTTON, 0, "Image1Btn", uXCoord, uYCoord, uWidth, uHeight, "Load Image 1" wsFactory.CreateWidget WS_BUTTON, 0, "Image2Btn", uXCoord, uYCoord + 14, uWidth, uHeight, "Load Image 2" wsFactory.CreateWidget WS_BUTTON, 0, "Image3Btn", uXCoord, uYCoord + 28, uWidth, uHeight, "Load Image 3" wsFactory.CreateWidget WS_BUTTON, 0, "exitButton", uXCoord, uYCoord + 42, uWidth, uHeight, "Exit" wsFactory.CreateWidget WS_BITMAP, 0, "bitmapWidget", 20, 30, 20, 20, "" wsFactory.CreateWidget WS_BITMAP, 0, "backGroundImage", 0, 0, 0, 0, "" 'Fonts and icons used on the form wsFactory.CreateCustomFont 1, 17, True, False, False, "Tahoma", WS_CENTER wsFactory.LoadExternalIcon 3, WS_EXIT, "iconlib.dll" 'Widgets customization wsWidget.SetBackGroundColorByName "Image1Btn", 143, 237, 171 wsWidget.SetTextColorByName "Image1Btn", 9, 169, 79 wsWidget.ShowBorderByName "Image1Btn", False wsWidget.SetFontByName "Image1Btn", 1 wsWidget.SetTextColorByName "FormTittle", 9, 169, 79 wsWidget.SetFontByName "FormTittle", 1 wsWidget.SetBackGroundColorByName "Image2Btn", 143, 237, 171 wsWidget.ShowBorderByName "Image2Btn", False wsWidget.SetTextColorByName "Image2Btn", 9, 169, 79 wsWidget.SetFontByName "Image2Btn", 1 wsWidget.SetBackGroundColorByName "Image3Btn", 143, 237, 171 wsWidget.ShowBorderByName "Image3Btn", False wsWidget.SetTextColorByName "Image3Btn", 9, 169, 79 wsWidget.SetFontByName "Image3Btn", 1 wsWidget.SetBackGroundColorByName "exitButton", 143, 237, 171 wsWidget.ShowBorderByName "exitButton", False wsWidget.SetTextColorByName "exitButton", 9, 169, 79 wsWidget.SetFontByName "exitButton", 1 wsWidget.SetIconByName "exitButton", 3 wsWidget.SetBackGroundColorByName "FormTittle", 236, 252, 241 wsWidget.SetBackGroundColorByName "bitmapWidget", 236, 252, 241 wsWidget.ShowBorderByName "bitmapWidget", True 'Widgets Attachment wsForm.AddObjectByName "myForm", "FormTittle" wsForm.AddObjectByName "myForm", "exitButton" wsForm.AddObjectByName "myForm", "Image1Btn" wsForm.AddObjectByName "myForm", "Image2Btn" wsForm.AddObjectByName "myForm", "Image3Btn" wsForm.AddObjectByName "myForm", "bitmapWidget" wsForm.AddObjectByName "myForm", "backGroundImage" 'The buttons are disabled until the files are transfered wsWidget.EnableByName "exitButton", False wsWidget.EnableByName "Image1Btn", False wsWidget.EnableByName "Image2Btn", False wsWidget.EnableByName "Image3Btn", False If Not wsForm.SaveToTerminalByName("myForm") Then Exit Sub End If bResult = wsForm.ShowByName("myForm", True, True) sRemoteTempFolder = wsFile.GetRemoteTempFolder iMatchedFiles = wsFile.RFListFiles(sRemoteTempFolder + "\logoBackground.bmp") If iMatchedFiles = 0 Then wsForm.ShowMessageBox "The images will be downloaded now", "Bitmap Demo", _ WS_MSG_BOX_OP_OK, WS_MSG_BOX_DEFBUTTON1, WS_MSG_BOX_ICON_INFORMATION 'The bitmap files are transfered to be later attached to the WS_BITMAP widget wsFile.RFTransferFile "..\SamplesWidgets\Exe\Resources\logoBackground.bmp", _ sRemoteTempFolder + "\logoBackground.bmp", True wsFile.RFTransferFile "..\SamplesWidgets\Exe\Resources\information.bmp", _ sRemoteTempFolder + "\information.bmp", True wsFile.RFTransferFile "..\SamplesWidgets\Exe\Resources\shield.bmp", _ sRemoteTempFolder + "\shield.bmp", True wsFile.RFTransferFile "..\SamplesWidgets\Exe\Resources\warning.bmp", _ sRemoteTempFolder + "\warning.bmp", True ElseIf iMatchedFiles = -1 Then Exit Sub End If wsWidget.SetImageFileByName "backGroundImage", sRemoteTempFolder + "\logoBackground.bmp" wsWidget.EnableByName "exitButton", True wsWidget.EnableByName "Image1Btn", True wsWidget.EnableByName "Image2Btn", True wsWidget.EnableByName "Image3Btn", True 'Waits for an event and perform an action While (bEnd = False And bResult) If Not wsForm.GetEvent() Then Exit Sub End If Select Case wsForm.GetLastEventSourceName() 'If any function key is pressed or the exit button is pressed 'the loop is ended Case "exitButton" bEnd = True Case "WSFunctionKeysController" bEnd = True Case "Image1Btn" wsWidget.SetImageFileByName "bitmapWidget", sRemoteTempFolder + "\information.bmp" Case "Image2Btn" wsWidget.SetImageFileByName "bitmapWidget", sRemoteTempFolder + "\shield.bmp" Case "Image3Btn" wsWidget.SetImageFileByName "bitmapWidget", sRemoteTempFolder + "\warning.bmp" End Select Wend End Sub