Search the Community
Showing results for tags 'refreshed'.
-
I have looked and read for 2 days now without finding what I assume is a simple solution. Can someone please look at the codebelow and help me to understand why when the gui opens the controls on the default tab (tab1) do not show up unless another tab is selected and tab1 is re-selected. I am trying to get the controls to be available when the form opens. This code uses GUIScrollbars_Ex.au3 which I have attached if needed. and reads a MobileMan.ini file the contents wich are below. Thank you, [Groups] ActiveGroups=MobileTest,Mobile [Mobile] ActiveHosts=computer1,computer2,computer3,computer4 [MobileTest] ActiveHosts=computer5,computer6 #include <GuiConstants.au3> #include <GuiEdit.au3> #Include <Date.au3> #include <GUIScrollbars_Ex.au3> #include <Array.au3> $Logfile = @ScriptDir & '\' & @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & "-" & @min & "-" & @SEC & "_" & 'MobileMan.log' Global $aHosts[1][18] = [[0, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",""]] ;~ Create Gui $sTitle = "Mobile Management Console" $sINI = @ScriptDir & "\MobileMan.ini" $GUI = GUICreate($sTitle,900, 570, -1, -1) $MessageMenu = GUICtrlCreateMenu("&File") $HelpMenu = GUICtrlCreateMenu("Help") GUICtrlCreateTab(160,10,730,310) $tabFreeform = GUICtrlCreateTabItem("tab1") $tabInpMessage = GUICtrlCreateInput("Enter text here...", 180,50,400,40, $ES_MULTILINE ) GUICtrlCreateTabItem("tab2") GUICtrlCreateTabItem("tab3") GUICtrlCreateTabItem("tab4") GUISetState() ;~ Create Child gui $cGUI = GUICreate("Child GUI", 140,525,10,10, $WS_CHILD, $WS_EX_CLIENTEDGE, $Gui) GUICtrlSetResizing($cGUI, $GUI_DOCKALL) Opt("GUICoordMode", 2) $GrpCord = GUISetCoord(5,5) $bToggleAll = GUICtrlCreateButton("Toggle All", -1, 1, 115, 20) GUISetState() FileOpen($Logfile,1) FileWrite($Logfile, _Now() & " - Session started" & @CRLF) ;~ Read ini $aGroups = IniReadSection($sINI, "Groups") If @error Then MsgBox(16, "Error", "Failed to read 'Groups' section.") FileWrite($Logfile, _Now() & " - Failed to read 'Groups' section" & @CRLF) Exit EndIf If ($aGroups[0][0] >= 1) And ($aGroups[1][0] = "ActiveGroups") Then $aActiveGroups = StringSplit($aGroups[1][1], ",") If ($aActiveGroups[0] = 1) And (StringStripWS($aActiveGroups[1], 8) = "") Then Dim $aActiveGroups[1] = [0] Else MsgBox(16, "Error", "Missing or invalid Groups keys.") FileWrite($Logfile, _Now() & " - Missing or invalid Groups keys" & @CRLF) Exit EndIf For $g = 1 To $aActiveGroups[0] $sGroupName = $aActiveGroups[$g] $aGroupSection = IniReadSection($sINI, $sGroupName) If @error Then MsgBox(16, "Error", "Failed to read groups section: '" & $sGroupName & "'.") FileWrite($Logfile, _Now() & " - Failed to read groups section: '" & $sGroupName & "'" & @CRLF) ContinueLoop EndIf If ($aGroupSection[0][0] >= 1) And ($aGroupSection[1][0] = "ActiveHosts") Then $aActiveHosts = StringSplit($aGroupSection[1][1], ",") If ($aActiveHosts[0] = 1) And (StringStripWS($aActiveHosts[1], 8) = "") Then Dim $aActiveHosts[1] = [0] For $h = 1 To $aActiveHosts[0] _AddActiveHost($sGroupName, $aActiveHosts[$h]) Next Else MsgBox(16, "Error", "Missing or invalid keys in group: '" & $sGroupName & "'.") FileWrite($Logfile, _Now() & " - Missing or invalid keys in group: '" & $sGroupName & "'." & @CRLF) ContinueLoop EndIf Next Dim $GrpButton[($aActiveGroups[0] + 1)] $Btn_Start = GUICtrlCreateDummy() For $g = 1 To $aActiveGroups[0] $GrpButton[$g] = GUICtrlCreateButton($aActiveGroups[$g],-1, 1, 115, 20) FileWrite($Logfile, _Now() & " - Group created: '" & $aActiveGroups[$g] & "'" & @CRLF) For $n = 1 To $aHosts[0][0] if $aActiveGroups[$g] = $aHosts[$n][0] then $aHosts[$n][2] = GUICtrlCreateCheckbox($aHosts[$n][1],-1,0,130,15) if $aActiveGroups[$g] = $aHosts[$n][0] then FileWrite($Logfile, _Now() & " - Host created: '" & $aHosts[$n][1] & "'") if $aActiveGroups[$g] = $aHosts[$n][0] then $aHosts[$n][3] = IniRead($sINI, $aActiveGroups[$g], 'Share','C$') ;~ if $aActiveGroups[$g] = $aHosts[$n][0] then $aHosts[$n][4] = ping ($aHosts[$n][1],$PingTimeout) ;~ if not $aHosts[$n][4] = 1 then GUICtrlSetState ($aHosts[$n][2],$GUI_DISABLE) if $aHosts[$n][4] = 1 then GUICtrlSetState ($aHosts[$n][2],$GUI_ENABLE) if $aActiveGroups[$g] = $aHosts[$n][0] and not $aHosts[$n][4] = 1 then FileWrite($Logfile, " -DISABLED" & @CRLF) Elseif $aActiveGroups[$g] = $aHosts[$n][0] Then FileWrite($Logfile, @CRLF) EndIf Next Next $Btn_End = GUICtrlCreateDummy() _GUIScrollbars_Generate($cGUI, 0, ($n * 15) + ($g * 21)) ;number of checkboxes in the list * 15 pixels (height of the checkbox + spacing ???) GUISetState() ;~ _ArrayDisplay($aActiveGroups) ;~ _ArrayDisplay($aHosts) While 1 $msg = GUIGetMsg() Switch $msg ;~ If $msg = $GUI_EVENT_CLOSE Then Case $GUI_EVENT_CLOSE Exit ;~ ElseIf $msg = $bToggleAll Then Case $bToggleAll For $n = 1 To $aHosts[0][0] If $aHosts[$n][0] = True Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsEnabled") Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsChecked") Then ControlCommand($cGUI, "", $aHosts[$n][2], "Uncheck") Else ControlCommand($cGUI, "", $aHosts[$n][2], "Check") EndIf EndIf EndIf Next Case $bToggleAll For $n = 1 To $aHosts[0][0] If $aHosts[$n][0] = True Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsEnabled") Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsChecked") Then ControlCommand($cGUI, "", $aHosts[$n][2], "Uncheck") Else ControlCommand($cGUI, "", $aHosts[$n][2], "Check") EndIf EndIf EndIf Next Case $Btn_Start To $Btn_End For $n = 1 To $aHosts[0][0] If $aHosts[$n][0] = GUICtrlRead($Msg) Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsEnabled") Then If ControlCommand($cGUI, "", $aHosts[$n][2], "IsChecked") Then ControlCommand($cGUI, "", $aHosts[$n][2], "Uncheck") Else ControlCommand($cGUI, "", $aHosts[$n][2], "Check") EndIf EndIf EndIf Next EndSwitch WEnd Func _AddActiveHost($sGrp, $sHost) ReDim $aHosts[UBound($aHosts) + 1][UBound($aHosts, 2)] ; Resize the array $aHosts[0][0] = UBound($aHosts) - 1 ; Save count in [0][0] $aHosts[$aHosts[0][0]][0] = $sGrp ; Put group in [n][0] $aHosts[$aHosts[0][0]][1] = $sHost ; Put host in [n][1] EndFunc ;==>_AddActiveHostGUIScrollbars_Ex.au3