Jump to content

Tab not being painted gui loads


Recommended Posts

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 ;==>_AddActiveHost

GUIScrollbars_Ex.au3

Edited by Melba23
Changed tags
Link to comment
Share on other sites

  • Moderators

Odewallrus,

You need to close the tab definition as explained in the Help file:

; .....
GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUISetState()
' .....

M23

P.S. When you post code please use AutoIt tags - put [autoit] before and [/autoit] after your posted code. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. ;)

Edited by Melba23
Typo

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Odewallrus,

My pleasure. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

×
×
  • Create New...