Jump to content
Sign in to follow this  
Kilhian

Refresh checkbox in group

Recommended Posts

Kilhian

Hi,

I'm trying to create a form with a combobox

the selected item in the combo will determine the content of the group

When I change the selection from the combo, the group must refresh

here is the code:

#include <GUIConstants.au3>
Global $Paused
      HotKeySet("{PAUSE}", "TogglePause")
      HotKeySet("{ESC}", "Terminate")
      HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d
      
      Dim $x
      Dim $j
      
      $List_profession=("...|Alchimiste|Bucheron|Pecheur|Paysan")
      $Res_Alch="Lin,Chanvre,Trefle,Menthe"
      $Res_Buch="6,7,8,9,10"
      $Res_Pech=""
      $Res_Pays=""
      

;Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Helper", 188, 260, 193, 159)                ;   Créé  la fenetre générale
$Label_titre = GUICtrlCreateLabel("Profession", 8, 8, 78, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Combo_Prof = GUICtrlCreateCombo("", 8, 32, 169, 25)                
    GUICtrlSetData($Combo_Prof,$List_profession, "...")
    GUICtrlSetFont($Combo_Prof, 10, 400, 0, "MS Sans Serif")

$Button_start = GUICtrlCreateButton("Lancer", 8, 192, 43, 25, 0)
$Button_pause = GUICtrlCreateButton("Pause", 72, 192, 43, 25, 0)
$Button_stop = GUICtrlCreateButton("Arrêter", 136, 192, 43, 25, 0)
$Button_quit = GUICtrlCreateButton("Quitter", 8, 224, 171, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo_Prof
            $Type=GUICtrlRead($Combo_Prof)
            ;MsgBox(0,"test",$Type)
            Switch $Type
                Case "Alchimiste"
                    $Ress=$Res_Alch
                Case "Bucheron"
                    $Ress=$Res_Buch
            EndSwitch 
            Creation_Group_($Ress)
        Case $Button_start
            
        Case $Button_pause
            TogglePause()
        Case $Button_quit
            Terminate()
        Case $Button_stop
            
        
    EndSwitch
    
Wend

Func Creation_Group_($Checkbox) ;Genere les cases a cocher
;GUICtrlDelete($Group1)
;Dim $Group1
;GUICtrlDelete($Group1)
$Group1 = GUICtrlCreateGroup("Ressource", 8, 64, 169, 121)
    Dim $Checkbox_Number
    $Checkbox_Array=StringSplit($Checkbox,",")
    $Checkbox_Number=UBound($Checkbox_Array)
    Dim $Checkbox_Create[$Checkbox_Number-1]
    $y=80
    For $i=0 to UBound($Checkbox_Create)-1  ;Nombre de Checkbox à créer
        If mod($i,2)=0 and $i<>0 Then $y=$y+24
        Select
            Case mod($i,2)=0
                $x=16
            case Else
                $x=96
        EndSelect
        $Checkbox_Create[$i]= GUICtrlCreateCheckbox($Checkbox_Array[$i+1], $x, $y, 73, 17)
    Next
GUICtrlCreateGroup("", -99, -99, 1, 1)
EndFunc


Func Button_startClick()

EndFunc
Func Button_stopClick()
    ;Break
EndFunc
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","Merci")
EndFunc

Thanks for thr hrlp you can give me

P.S. How do I color my code

Share this post


Link to post
Share on other sites
GEOSoft

There is probably a better method that I've forgotten but this works

#include <GUIConstants.au3>
Global $Paused
      HotKeySet("{PAUSE}", "TogglePause")
      HotKeySet("{ESC}", "Terminate")
      HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d
      
      Dim $x
      Dim $j
      
      $List_profession=("...|Alchimiste|Bucheron|Pecheur|Paysan")
      $Res_Alch="Lin,Chanvre,Trefle,Menthe"
      $Res_Buch="6,7,8,9,10"
      $Res_Pech=""
      $Res_Pays=""
      

;Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Helper", 188, 260, 193, 159)            ;  Créé  la fenetre générale
$Label_titre = GUICtrlCreateLabel("Profession", 8, 8, 78, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Combo_Prof = GUICtrlCreateCombo("", 8, 32, 169, 25)                
    GUICtrlSetData($Combo_Prof,$List_profession, "...")
    GUICtrlSetFont($Combo_Prof, 10, 400, 0, "MS Sans Serif")

$Button_start = GUICtrlCreateButton("Lancer", 8, 192, 43, 25, 0)
$Button_pause = GUICtrlCreateButton("Pause", 72, 192, 43, 25, 0)
$Button_stop = GUICtrlCreateButton("Arrêter", 136, 192, 43, 25, 0)
$Button_quit = GUICtrlCreateButton("Quitter", 8, 224, 171, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo_Prof
            $Type=GUICtrlRead($Combo_Prof)
           ;MsgBox(0,"test",$Type)
            Switch $Type
                Case "Alchimiste"
                    $Ress=$Res_Alch
                Case "Bucheron"
                    $Ress=$Res_Buch
            EndSwitch 
            Creation_Group_($Ress)
        Case $Button_start
            
        Case $Button_pause
            TogglePause()
        Case $Button_quit
            Terminate()
        Case $Button_stop
            
        
    EndSwitch
    
Wend

Func Creation_Group_($Checkbox);Genere les cases a cocher
;GUICtrlDelete($Group1)
;Dim $Group1
;GUICtrlDelete($Group1)
If IsDeclared("gStart") Then
For $I = $gStart To $gEnd
   GUICtrlDelete($I)
Next
EndIf
Global $gStart = GUICtrlCreateDummy()
Global $Group1 = GUICtrlCreateGroup("Ressource", 8, 64, 169, 121)
    Dim $Checkbox_Number
    $Checkbox_Array=StringSplit($Checkbox,",")
    $Checkbox_Number=UBound($Checkbox_Array)
    Dim $Checkbox_Create[$Checkbox_Number-1]
    $y=80
    For $i=0 to UBound($Checkbox_Create)-1 ;Nombre de Checkbox à créer
        If mod($i,2)=0 and $i<>0 Then $y=$y+24
        Select
            Case mod($i,2)=0
                $x=16
            case Else
                $x=96
        EndSelect
        $Checkbox_Create[$i]= GUICtrlCreateCheckbox($Checkbox_Array[$i+1], $x, $y, 73, 17)
    Next
;GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $gEnd = GUICtrlCreateDummy()
EndFunc


Func Button_startClick()

EndFunc
Func Button_stopClick()
   ;Break
EndFunc
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","Merci")
EndFunc

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
GEOSoft

Thanks that works great :)

Glad it works. I have one script that will dynamiclly create over a thousand TreeViewItems and that's the method I use to refresh the treeview. That's not to say there still isn't a better method. That worked so I left it alone.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.