Jump to content

How do I add tabs to view our embedded Esri web maps


aa2zz6
 Share

Recommended Posts

How do I add tabs to view our embedded Esri web maps into the GUI? I have 3-4 maps I would like to incorporate in the GUI but in separate tabs. Each tab will have 1 map so users can simple switch between maps to view map data. I'm currently am able to get the GUI to view 1 embedded map. I tried using GUICtrlCreateTab and placed it in front of the GUICtrlCreatObj but it didn't move it inside so I'm not quite sure tbh.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=ICO NEO_LOGO.ico
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;#NoTrayIcon
;
; Simple Browser based on Internet Explorer ActiveX Component.
;
#include <ColorConstantS.au3>
#Include <WindowsConstants.au3>
#Include <WinAPI.au3>
#include <GUIConstants.au3>
#include <IE.au3>
#include <INet.au3>
#include <GUIConstantsEx.au3>
#include <Date.au3>
#include <File.au3>

Opt("GUIOnEventMode", 1)

; Connection Variable
Global $connectionFailed

; Used for the _WriteErrorLog($ErrorMessage)
Global $path = "C:\temp"
Global $files = _FileListToArray($path, "*.txt", 2) ;create an array of files in the specified folder
Global $date = @YEAR & "/" & @MON & "/" & @MDAY ;getting the current date
Global $newdate = _DateAdd("D", -10, $date) ;adding -10 days (subtract 10 days)
Global $formatdate = StringSplit($newdate, "/") ;removing the /
Global $newdate = $formatdate[1] & $formatdate[2] & $formatdate[3] & @HOUR & @MIN & @SEC ;putting the date back together in a format easily compared to the FileGetTime func
If IsArray($files) Then ;Making sure an array was created
    For $i = 1 To UBound($files) - 1 ;Loop through all the files found
        $aTime = FileGetTime($path & $files[$i], 1, 1) ;get the creation time of the file
        If $aTime < $newdate Then ;check to see if creation time is older than 10 days
            FileDelete($files[$i]) ;delete the file if it is
        EndIf
    Next
EndIf

_IEErrorHandlerRegister()
$oIE = _IECreateEmbedded()
$name = "<Company Name>"
$address = "https://<domain name>.net/<web adapter>/apps/webappviewer/"

; Calculate visible screen dimensions.
$one_percent_width = @DesktopWidth / 100
$one_percent_height = @DesktopHeight / 100
$width = $one_percent_width * 98
$height = $one_percent_height * 91

local $form = GUICreate($name, @DesktopWidth, @DesktopHeight, 1, 1, $WS_MAXIMIZE + $WS_OVERLAPPEDWINDOW + $WS_VISIBLE)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 50, $width, $height)

GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP)

; Show GUI.
GUISetState(@SW_MAXIMIZE)


_IENavigate($oIE, $address)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")
$i = 0
$Timer = TimerInit
; Waiting for user to close the window.
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
    checkConnection()
    Sleep(10)
WEnd
GUIDelete()
Exit

Func checkConnection()
    While 1
        $Ping = Ping(<domain name>.net)
        $Delay = TimerDiff($Timer)
        If $Delay >= 2000 Then ;2 seconds delay check
            If $Ping Then ; also possible:  If @error = 0 Then ...
                ;ToolTip("Network Connection Active!", 0, 0)
                Sleep(2000) ; Sleep to give tooltip time to display
                If $connectionFailed = True Then
                    Local $oElements = _IETagNameGetCollection($oIE, "div")

                    For $oElement In $oElements
                        If $oElement.classname == "appstate-tips" Then
                            _IEAction($oElement, "click")
                        EndIf
                        ;ConsoleWrite ( $oElement.classname & @CRLF)
                        _WriteErrorLog("Reconfigured map settings")
                        $connectionFailed = False ; Reset back to default
                    Next
                EndIf
                $i = $i + 1
                _WriteErrorLog("Network Connection Active!") ;Used for testing..
            Else
                ;ToolTip("Network Connection Failed", 0, 0)
                Sleep(2000) ; Sleep to give tooltip time to display
                $i = $i + 1
                $connectionFailed = True
                _WriteErrorLog("Network Connection Failed")
            EndIf
            $Timer = TimerInit()
        EndIf
        Sleep(10)
    WEnd

EndFunc   ;==>checkConnection

Func _Close()
    GUIDelete()
    Exit
EndFunc   ;==>_Close

Func _WriteErrorLog($ErrorMessage)
    ; If the directory exists then don't continue.
    If FileExists($path) Then
        ;MsgBox($MB_SYSTEMMODAL, "", "An error occurred. The directory already exists.")
        Return False
    EndIf

    ; Create the directory.
    DirCreate($path)

    FileWriteLine($path & "\" & @ScriptName & ".log", _NowTime() & " " & $ErrorMessage)
EndFunc   ;==>_WriteErrorLog

 

Link to comment
Share on other sites

On 7/26/2018 at 12:46 PM, coffeeturtle said:

Would you mind sharing the code with your solution, please? Would be interested in doing something similar. Thanks!

Here you go
 

#include <ColorConstantS.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GUIConstants.au3>
#include <IE.au3>
#include <INet.au3>
#include <GUIConstantsEx.au3>
#include <Date.au3>
#include <File.au3>

Opt("GUIOnEventMode", 1)

_IEErrorHandlerRegister()

$GUIname = "GUI Name"

; Calculate visible screen dimensions.
$one_percent_width = @DesktopWidth / 100
$one_percent_height = @DesktopHeight / 100
$width = $one_percent_width * 98
$height = $one_percent_height * 91

Local $form = GUICreate($GUIname, @DesktopWidth, @DesktopHeight, 1, 1, $WS_MAXIMIZE + $WS_OVERLAPPEDWINDOW + $WS_VISIBLE)

GUISetFont(9, 300)

GUICtrlCreateTab(5, 5, $width, $height)

GUICtrlCreateTabItem("Gas Network")
$oIE = _IECreateEmbedded()
$address = "URL"
$GUIActiveX = GUICtrlCreateObj($oIE, 5, 28, $width, $height)
_IENavigate($oIE, $address)

GUICtrlCreateTabItem("Gas Leaks")
$oIE1 = _IECreateEmbedded()
$address1 = "URL"
$GUIActiveX1 = GUICtrlCreateObj($oIE1, 5, 30, $width, $height)
_IENavigate($oIE1, $address1)

GUICtrlCreateTabItem("Cathodic Protection")
$oIE2 = _IECreateEmbedded()
$address2 = "URL"
$GUIActiveX2 = GUICtrlCreateObj($oIE2, 5, 30, $width, $height)
_IENavigate($oIE2, $address2)

; Show GUI.
GUISetState(@SW_MAXIMIZE)



GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")
$i = 0
$Timer = TimerInit
; Waiting for user to close the window.
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
    checkConnection()
    Sleep(10)
WEnd
GUIDelete()
Exit

Func checkConnection()
    While 1
        Sleep(10)
    WEnd

EndFunc   ;==>checkConnection

Func _Close()
    GUIDelete()
    Exit
EndFunc   ;==>_Close

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...