Sign in to follow this  
Followers 0
jlorenz1

Changing tabs disturbs loading controls correctly (Solved)

3 posts in this topic

#1 ·  Posted (edited)

Hi,

I've made a little demo of my problem. Cause there are many queries to the user, I 've decided to use a treeview and certains controls, which should be loaded or unload with a function. If you click an item of a treeview, a certain group of controls should be shown and the other should be hidden.

This works fine, if you rest on the same tab. If you're changing the tabs and you want to return to the first tab - what a surprise! - the last group of controls are shown correctly, but if you change the items of the treeview - Load and Unload-Functions won't work correctly. Controls, which should be shown & enabled are visible but disabled! No error messages in scite or as return value of the function. Thanks in advance Johannes

#include <GUIConstants.au3>
Global $iLastload = 0
Global $iActuallyLoad = 0

Global $avControls [5]
$avControls [0] = 'cLengthRadio1|cLengthRadio2|cReplaceRadio1|cReplaceRadio2|cCaseRadio1|cCaseRadio2|cBigRadio1|cBi


gRadio2' 
$avControls [1] = 'cLengthRadio1|cLengthRadio2'
$avControls [2] = 'cReplaceRadio1|cReplaceRadio2'
$avControls [3] = 'cCaseRadio1|cCaseRadio2'
$avControls [4] = 'cBigRadio1|cBigRadio2'

GUICreate('My problem: to load controls in tab (DEMO)',350,250); will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab=GUICtrlCreateTab (10,10, 300,200)
;*************** Tab Cero *****************************
$tab0=GUICtrlCreateTabitem ("tab0")
GUICtrlCreateLabel ("label0", 30,80,50,20)
$tab0OK=GUICtrlCreateButton ("OK Tab0", 220, 180, 70, 20)

;*************** Tab One *****************************
$tab1=GUICtrlCreateTabitem ( "tab here")
GUICtrlSetState(-1,$GUI_SHOW); will be display first
$tab1OK=GUICtrlCreateButton ("OK Tab1", 220, 180, 70, 20)

GUICtrlSetData(-1,"Trids|CyberSlug|Larry|Jon|Tylo", "Jon"); default Jon

$treeview = GUICtrlCreateTreeView(20, 40, 100, 160, BitOr($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)

$generalitem    = GUICtrlCreateTreeViewitem("strings", $treeview)
GUICtrlSetColor(-1, 0x0000C0)
$displayitem    = GUICtrlCreateTreeViewitem("extansions", $treeview)
GUICtrlSetColor(-1, 0x0000C0)
$lengthitem   = GUICtrlCreateTreeViewitem("length", $generalitem)
$replaceitem       = GUICtrlCreateTreeViewitem("replace", $generalitem)
$caseitem      = GUICtrlCreateTreeViewitem("casesensitiv", $generalitem)
$bigitem        = GUICtrlCreateTreeViewitem("big", $displayitem )

$cLengthRadio1 = GUICtrlCreateRadio('LengthRadio1', 130, 60, 110, 20)
$cLengthRadio2 = GUICtrlCreateRadio('LengthRadio2', 130, 80, 110, 20)

$cReplaceRadio1 = GUICtrlCreateRadio('ReplaceRadio1', 130, 60, 110, 20)
$cReplaceRadio2 = GUICtrlCreateRadio('ReplaceRadio2', 130, 80, 110, 20)

$cCaseRadio1 = GUICtrlCreateRadio('CaseRadio1', 130, 60, 110, 20)
$cCaseRadio2 = GUICtrlCreateRadio('CaseRadio2', 130, 80, 110, 20)

$cBigRadio1 = GUICtrlCreateRadio('BigRadio1', 130, 60, 110, 20)
$cBigRadio2 = GUICtrlCreateRadio('BigRadio2', 130, 80, 110, 20)



;*************** Tab Two*****************************
$tab2=GUICtrlCreateTabitem ("tab2")
$tab2OK=GUICtrlCreateButton ("OK Tab2", 220, 180, 70, 20)

GUICtrlCreateTabitem (""); end tabitem definition

GUICtrlCreateLabel ("Changing Tabs makes hidden controls visibles&disabled", 20,230,250,20)

_Unload(0)
GUISetState ()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $tab 
; display the clicked tab
            if GUICtrlread ($tab) = 0 then WinSetTitle("My GUI Tab","","My GUI Tab0")
            if GUICtrlread ($tab) = 1 then WinSetTitle("My GUI Tab","","My GUI Tab1")
            if GUICtrlread ($tab) = 2 then WinSetTitle("My GUI Tab","","My GUI Tab2")
        Case $lengthitem 
            _Load (1)
        Case $replaceitem
            _Load (2)
        Case $caseitem 
            _Load (3)
        Case $bigitem
            _Load (4)           
    EndSwitch
WEnd
        
Func _Load ($iLoadnumber)
    Dim $iCtrl='', $iErr=0
    $iLastLoad = $iActuallyLoad
    $iActuallyLoad = $iLoadnumber
    $avControlsToLoad = StringSplit ($avControls[$iLoadnumber], '|')
    MsgBox(4160, 'Info', '$iLastLoad = ' & $iLastLoad & @CRLF & '$iActuallyLoad = ' & $iActuallyLoad,3)
    For $i = 1 to $avControlsToLoad [0]
        $iCtrl = Eval ($avControlsToLoad [$i])
        $iErr = GUICtrlSetState ($iCtrl, $GUI_SHOW)
        If $iErr == 0 then MsgBox (4160, $avControlsToLoad [$i], 'Error. Problem to set control to GUI_SHOW',1)
    Next
    If $iLastLoad > 0 then _Unload ($iLastLoad)
EndFunc; ==> _Load
    
Func _UnLoad($iNumber)
    Dim $iCtrl='', $iErr=0
    $avControlsToLoad = StringSplit ($avControls[$iNumber], '|')
    For $i = 1 to $avControlsToLoad [0]
        $iCtrl = Eval ($avControlsToLoad [$i])
        $iErr = GUICtrlSetState ($iCtrl, $GUI_HIDE)
        If $iErr == 0 then MsgBox (4160, $avControlsToLoad [$i], 'Error. Problem to set control to GUI_HIDE',1)
    Next
EndFunc;==> _Unload
Edited by jlorenz1

Johannes LorenzBensheim, Germanyjlorenz1@web.de[post="12602"]Highlightning AutoIt Syntax in Notepad++ - Just copy in your Profile/application data/notepad++[/post]

Share this post


Link to post
Share on other sites



Well then,

in Load function, instead of just GUICtrlSetState($iCtrl, $GUI_SHOW), do a

GUICtrlSetState ($iCtrl, $GUI_ENABLE)

GUICtrlSetState ($iCtrl, $GUI_SHOW)

And in Unload, do $GUI_HIDE and $GUI_DISABLE...


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Well then,

in Load function, instead of just GUICtrlSetState($iCtrl, $GUI_SHOW), do a

GUICtrlSetState ($iCtrl, $GUI_ENABLE)

GUICtrlSetState ($iCtrl, $GUI_SHOW)

And in Unload, do $GUI_HIDE and $GUI_DISABLE...

THANKS for your fast help! Great. It works ! Johannes


Johannes LorenzBensheim, Germanyjlorenz1@web.de[post="12602"]Highlightning AutoIt Syntax in Notepad++ - Just copy in your Profile/application data/notepad++[/post]

Share this post


Link to post
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
Sign in to follow this  
Followers 0