Sign in to follow this  
Followers 0
PrinsBertil

TreelistView

8 posts in this topic

Hello

I have an issues with The GUITreeview.

A function that reads the value behind eg. "Light" of A2.

So when you click on "light" of A2 it will change the color of the box to the right

And when GO! button is being pressed it shall save the selected color value to an ini file.

The GO! button starts another script that reads an INI file where values have been stored for use within the script

This is causing some real headace. I don't know if AutoIt can do something like whit its GUI or if some other program is better to use when creating an UI and then having that UI starting the AutoIt script reading the values from the ini file that the program made. If so do anyone have any recomendations

And to top it of and make it more of a problem that I belive will cause alot of code with autoIt, is that when the custom color is clicked at the bottom it shall open a small window where the user can choose from a palette of witch color he like to see in the box.

#include <GuiConstants.au3>
; GUI
    $MyGUI = GuiCreate("Flash", 533, 634, -1, -1, $WS_EX_TOPMOST)
    GuiSetIcon(@SystemDir & "\mspaint.exe", 0)
    $title = "Flash"
; INPUT

; TAB
    GuiCtrlCreateTab(0, 0, 480, 500)
    GuiCtrlCreateTabItem("TreeView")
    GuiCtrlCreateLabel("Location (Value) ", 40, 40)
    
; TREEVIEW DAYLIGHT
    $Mommy = GuiCtrlCreateTreeView(20, 60, 220, 420,BitOr($TVS_HASBUTTONS,,$TVS_SINGLEEXPAND,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE)


    $A = GuiCtrlCreateTreeViewItem("A", $Mommy)
        $A1 = GuiCtrlCreateTreeViewItem("A 1 (130)", $A)
            GuiCtrlCreateTreeViewItem("Light", $A1);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $A1);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $A1);0x0B1931

        $A2 = GuiCtrlCreateTreeViewItem("A 2 (130)", $A)
            GuiCtrlCreateTreeViewItem("Light", $A2);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $A2);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $A2);0x0B1931

        $A3 = GuiCtrlCreateTreeViewItem("A 3 (330)", $A)
            GuiCtrlCreateTreeViewItem("Light", $A3);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $A3);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $A3);0x0B1931
            
    $B = GuiCtrlCreateTreeViewItem("B", $Mommy)

        $B1 = GuiCtrlCreateTreeViewItem("B 1 (330)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B1);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B1);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B1);0x0B1931

        $B2 = GuiCtrlCreateTreeViewItem("B 2 (1)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B2);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B2);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B2);0x0B1931

        $B3 = GuiCtrlCreateTreeViewItem("B 3 (55)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B3);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B3);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B3);0x0B1931

        $B4 = GuiCtrlCreateTreeViewItem("B 4 (330)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B4);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B4);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B4);0x0B1931

        $B5 = GuiCtrlCreateTreeViewItem("B 5 (1)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B5);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B5);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B5);0x0B1931

        $B6 = GuiCtrlCreateTreeViewItem("B 6 (20)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B6);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B6);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B6);0x0B1931
            
    $Custom = GuiCtrlCreateTreeViewItem("Custom", $Mommy)
            GuiCtrlCreateTreeViewItem("Custom Light", $Custom)

            

    GuiCtrlCreateLabel("", 420, 60, 40, 40,BitOr(,$TVS_DISABLEDRAGDROP),$WS_EX_CLIENTEDGE)
    GuiCtrlSetBkColor(-1, 0x00FF00)
    
        GuiCtrlCreateButton("GO!", 380, 460, 80, 30)


GUISetState(@SW_SHOW)

While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Share this post


Link to post
Share on other sites



Hello again.

I have abandon the hope for an easy solution for my problem

I vas hoping to be able to use something like

GuiCtrlCreateTreeViewItem("Light", $A1);0x0B15C0
GuiCtrlSetOnEvent(-1, "Color"[,Value = 0x0B15C0])

Not proper coding, I know, my excuse is that I am just in the begining of learning this.

if instead I write an function for each line in the Treelist it might work it will be a long script since I have about 500 entries in the Tree

Something like:

$Mommy = GuiCtrlCreateTreeView(20, 60, 220, 420,BitOr($TVS_HASBUTTONS,$TVS_SINGLEEXPAND,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE)


    $A = GuiCtrlCreateTreeViewItem("A", $Mommy)
        $A1 = GuiCtrlCreateTreeViewItem("A 1 (130)", $A)
            GuiCtrlCreateTreeViewItem("Light", $A1);0x0B15C0
                GuiCtrlSetOnEvent(-1, "C0x0B15C0")
            GuiCtrlCreateTreeViewItem("Green", $A1);0xA72C0B
                GuiCtrlSetOnEvent(-1, "C0xA72C0B")
            GuiCtrlCreateTreeViewItem("Dark", $A1);0x0B1931
                GuiCtrlSetOnEvent(-1, "C0x0B1931")

    $Color = GuiCtrlCreateLabel("test", 420, 60, 40, 40,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE)
    
        GuiCtrlCreateButton("GO!", 380, 460, 80, 30)

GUISetState(@SW_SHOW)
    
Func C0X0B15C0()
    $Color = GUICtrlsetBKColor(-1, 0x0B15C0)
    IniWrite = (test.ini, Color, ColorChosen, 0x0B15C0)
EndFunc

Func C0xA72C0B()
    $Color = GUICtrlsetBKColor(-1, 0xA72C0B)
    IniWrite = (test.ini, Color, ColorChosen, 0xA72C0B)
EndFunc

Func C0x0B1931()
    $Color = GUICtrlsetBKColor(-1, 0x0B1931)
    IniWrite = (test.ini, Color, ColorChosen, 0x0B1931)
EndFunc

Again not proper coding, I was hoping if someone could help me out with this one.

BRGDS

PrinsBertil

Share this post


Link to post
Share on other sites

Hi, something like this?

#include <GuiConstants.au3>
#Include <GuiTreeView.au3>

Opt("GUIOnEventMode", 1) 

Global $Ini = @ScriptDir & "\test.ini"

; GUI
$MyGUI = GuiCreate("Flash", 533, 634, -1, -1, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $MyGUI)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)

; TAB
GuiCtrlCreateTab(0, 0, 480, 500)
GuiCtrlCreateTabItem("TreeView")
GuiCtrlCreateLabel("Location (Value) ", 40, 40)
    
; TREEVIEW DAYLIGHT
$Mommy = GuiCtrlCreateTreeView(20, 60, 220, 420,BitOr($TVS_HASBUTTONS,$TVS_SINGLEEXPAND,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE)

    $A = GuiCtrlCreateTreeViewItem("A", $Mommy)
        $A1 = GuiCtrlCreateTreeViewItem("A 1 (130)", $A)
            GuiCtrlCreateTreeViewItem("Light", $A1);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $A1);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $A1);0x0B1931

        $A2 = GuiCtrlCreateTreeViewItem("A 2 (130)", $A)
            GuiCtrlCreateTreeViewItem("Light", $A2);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $A2);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $A2);0x0B1931

        $A3 = GuiCtrlCreateTreeViewItem("A 3 (330)", $A)
            GuiCtrlCreateTreeViewItem("Light", $A3);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $A3);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $A3);0x0B1931
            
    $B = GuiCtrlCreateTreeViewItem("B", $Mommy)

        $B1 = GuiCtrlCreateTreeViewItem("B 1 (330)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B1);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B1);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B1);0x0B1931

        $B2 = GuiCtrlCreateTreeViewItem("B 2 (1)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B2);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B2);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B2);0x0B1931

        $B3 = GuiCtrlCreateTreeViewItem("B 3 (55)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B3);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B3);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B3);0x0B1931

        $B4 = GuiCtrlCreateTreeViewItem("B 4 (330)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B4);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B4);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B4);0x0B1931

        $B5 = GuiCtrlCreateTreeViewItem("B 5 (1)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B5);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B5);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B5);0x0B1931

        $B6 = GuiCtrlCreateTreeViewItem("B 6 (20)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B6);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B6);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B6);0x0B1931
            

    
    $Custom = GuiCtrlCreateTreeViewItem("Custom", $Mommy)
        GuiCtrlCreateTreeViewItem("Custom Light", $Custom)

For $i = $A To $Custom
    GUICtrlSetOnEvent($i, "Event")
Next    

$Label = GuiCtrlCreateLabel("", 420, 60, 40, 40,-1,$WS_EX_CLIENTEDGE)
GuiCtrlSetBkColor(-1, 0x00FF00)
GuiCtrlCreateButton("GO!", 380, 460, 80, 30)


GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            Switch GUICtrlRead(@GUI_CtrlId, 1)
                Case "Light"
                    GUICtrlSetBkColor($Label, 0x0B15C0)
                    IniWrite($Ini, "Color", GUICtrlRead(_GUICtrlTreeView_GetParentParam($Mommy, @GUI_CtrlId),1), "0x0B15C0")
                Case "Green"
                    GUICtrlSetBkColor($Label, 0xA72C0B)
                    IniWrite($Ini, "Color", GUICtrlRead(_GUICtrlTreeView_GetParentParam($Mommy, @GUI_CtrlId),1), "0xA72C0B")
                Case "Dark"
                    GUICtrlSetBkColor($Label, 0x0B1931)
                    IniWrite($Ini, "Color", GUICtrlRead(_GUICtrlTreeView_GetParentParam($Mommy, @GUI_CtrlId),1), "0x0B1931")
                Case Else
                    GUICtrlSetBkColor($Label, 0x00FF00)
            EndSwitch
    EndSwitch       
EndFunc

If I knew how many items and there names then I could probable supply a briefer bit of code for the creation treeview of items.

Cheers

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi, something like this?

#include <GuiConstants.au3>
#Include <GuiTreeView.au3>

Opt("GUIOnEventMode", 1) 

Global $Ini = @ScriptDir & "\test.ini"

; GUI
$MyGUI = GuiCreate("Flash", 533, 634, -1, -1, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $MyGUI)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)

; TAB
GuiCtrlCreateTab(0, 0, 480, 500)
GuiCtrlCreateTabItem("TreeView")
GuiCtrlCreateLabel("Location (Value) ", 40, 40)
    
; TREEVIEW DAYLIGHT
$Mommy = GuiCtrlCreateTreeView(20, 60, 220, 420,BitOr($TVS_HASBUTTONS,$TVS_SINGLEEXPAND,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE)

    $A = GuiCtrlCreateTreeViewItem("A", $Mommy)
        $A1 = GuiCtrlCreateTreeViewItem("A 1 (130)", $A)
            GuiCtrlCreateTreeViewItem("Light", $A1);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $A1);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $A1);0x0B1931

        $A2 = GuiCtrlCreateTreeViewItem("A 2 (130)", $A)
            GuiCtrlCreateTreeViewItem("Light", $A2);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $A2);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $A2);0x0B1931

        $A3 = GuiCtrlCreateTreeViewItem("A 3 (330)", $A)
            GuiCtrlCreateTreeViewItem("Light", $A3);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $A3);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $A3);0x0B1931
            
    $B = GuiCtrlCreateTreeViewItem("B", $Mommy)

        $B1 = GuiCtrlCreateTreeViewItem("B 1 (330)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B1);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B1);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B1);0x0B1931

        $B2 = GuiCtrlCreateTreeViewItem("B 2 (1)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B2);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B2);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B2);0x0B1931

        $B3 = GuiCtrlCreateTreeViewItem("B 3 (55)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B3);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B3);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B3);0x0B1931

        $B4 = GuiCtrlCreateTreeViewItem("B 4 (330)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B4);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B4);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B4);0x0B1931

        $B5 = GuiCtrlCreateTreeViewItem("B 5 (1)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B5);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B5);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B5);0x0B1931

        $B6 = GuiCtrlCreateTreeViewItem("B 6 (20)", $B)
            GuiCtrlCreateTreeViewItem("Light", $B6);0x0B15C0
            GuiCtrlCreateTreeViewItem("Green", $B6);0xA72C0B
            GuiCtrlCreateTreeViewItem("Dark", $B6);0x0B1931
            

    
    $Custom = GuiCtrlCreateTreeViewItem("Custom", $Mommy)
        GuiCtrlCreateTreeViewItem("Custom Light", $Custom)

For $i = $A To $Custom
    GUICtrlSetOnEvent($i, "Event")
Next    

$Label = GuiCtrlCreateLabel("", 420, 60, 40, 40,-1,$WS_EX_CLIENTEDGE)
GuiCtrlSetBkColor(-1, 0x00FF00)
GuiCtrlCreateButton("GO!", 380, 460, 80, 30)


GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            Switch GUICtrlRead(@GUI_CtrlId, 1)
                Case "Light"
                    GUICtrlSetBkColor($Label, 0x0B15C0)
                    IniWrite($Ini, "Color", GUICtrlRead(_GUICtrlTreeView_GetParentParam($Mommy, @GUI_CtrlId),1), "0x0B15C0")
                Case "Green"
                    GUICtrlSetBkColor($Label, 0xA72C0B)
                    IniWrite($Ini, "Color", GUICtrlRead(_GUICtrlTreeView_GetParentParam($Mommy, @GUI_CtrlId),1), "0xA72C0B")
                Case "Dark"
                    GUICtrlSetBkColor($Label, 0x0B1931)
                    IniWrite($Ini, "Color", GUICtrlRead(_GUICtrlTreeView_GetParentParam($Mommy, @GUI_CtrlId),1), "0x0B1931")
                Case Else
                    GUICtrlSetBkColor($Label, 0x00FF00)
            EndSwitch
    EndSwitch       
EndFunc

If I knew how many items and there names then I could probable supply a briefer bit of code for the creation treeview of items.

Cheers

Yeah that is something like it! =)

One minor adjustment is that the color values at each one of those are different. and some name exaples in this one. just made A123 and B123 for the simple look of it

$Annette = GuiCtrlCreateTreeViewItem("A", $Mommy)
        $Larsson = GuiCtrlCreateTreeViewItem("Anette Larsson  (130)", $Anette)
            GuiCtrlCreateTreeViewItem("Light", $Larsson);0x011002
            GuiCtrlCreateTreeViewItem("Green", $Larsson);0x00FF00
            GuiCtrlCreateTreeViewItem("Dark", $Larsson);0xFB19FF

        $Magnusson = GuiCtrlCreateTreeViewItem("Anette Magnusson (130)", $Anette)
            GuiCtrlCreateTreeViewItem("Light", $Magnusson);0x0B0500
            GuiCtrlCreateTreeViewItem("Green", $Magnusson);0x47AA0B
            GuiCtrlCreateTreeViewItem("Dark", $Magnusson);0xDBB9A1

        $Östberg = GuiCtrlCreateTreeViewItem("Anette Östberg (330)", $Anette)
            GuiCtrlCreateTreeViewItem("Light", $ÖstBerg);0x0B0001
            GuiCtrlCreateTreeViewItem("Green", $Östeberg);0x23FF07
            GuiCtrlCreateTreeViewItem("Dark", $ÖstBerg);0xBB99FF

And it continues. so all "Light" "Green" "Dark" Labels are all the same just that the treeviewitem above change name. But its still the Subtree label that I want to change what value to write to the exact same string in the ini file and that will set the BkColor "box" ($Label)

Edited by PrinsBertil

Share this post


Link to post
Share on other sites

Hi, based on the $Annette snippet

#include <GuiConstants.au3>
#Include <GuiTreeView.au3>

Opt("GUIOnEventMode", 1) 

Global $Ini = @ScriptDir & "\test.ini"
Global $Color = StringSplit("Anette Larsson  (130),0xFB19FF,0x00FF00,0x011002|" & _
                                "Anette Magnusson (130),0xDBB9A1,0x47AA0B,0x0B0500|" & _
                                "Anette Östberg (330),0xBB99FF,0x23FF07,0x0B0001", "|")
; GUI
$MyGUI = GuiCreate("Flash", 533, 634, -1, -1, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $MyGUI)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)

; TAB
GuiCtrlCreateTab(0, 0, 480, 500)
GuiCtrlCreateTabItem("TreeView")
GuiCtrlCreateLabel("Location (Value) ", 40, 40)
    
; TREEVIEW DAYLIGHT
$Mommy = GuiCtrlCreateTreeView(20, 60, 220, 420,BitOr($TVS_HASBUTTONS,$TVS_SINGLEEXPAND,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE)

    $Annette = GuiCtrlCreateTreeViewItem("A", $Mommy)
        $Larsson = GuiCtrlCreateTreeViewItem("Anette Larsson  (130)", $Annette)
            GuiCtrlCreateTreeViewItem("Light", $Larsson);0xFB19FF
            GuiCtrlCreateTreeViewItem("Green", $Larsson);0x00FF00
            GuiCtrlCreateTreeViewItem("Dark", $Larsson);0x011002

        $Magnusson = GuiCtrlCreateTreeViewItem("Anette Magnusson (130)", $Annette)
            GuiCtrlCreateTreeViewItem("Light", $Magnusson);0xDBB9A1
            GuiCtrlCreateTreeViewItem("Green", $Magnusson);0x47AA0B
            GuiCtrlCreateTreeViewItem("Dark", $Magnusson);0x0B0500

        $Ostberg = GuiCtrlCreateTreeViewItem("Anette Östberg (330)", $Annette)
            GuiCtrlCreateTreeViewItem("Light", $OstBerg);0xBB99FF
            GuiCtrlCreateTreeViewItem("Green", $Ostberg);0x23FF07
            GuiCtrlCreateTreeViewItem("Dark", $OstBerg);0x0B0001
    
    $Dummy = GUICtrlCreateDummy()

For $i = $Annette To $Dummy
    GUICtrlSetOnEvent($i, "Event")
Next    

$Label = GuiCtrlCreateLabel("", 420, 60, 40, 40,-1,$WS_EX_CLIENTEDGE)
GuiCtrlSetBkColor(-1, 0x00FF00)
GuiCtrlCreateButton("GO!", 380, 460, 80, 30)


GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            Switch GUICtrlRead(@GUI_CtrlId, 1)
                Case "Light"
                    Local $clr = FindColor(@GUI_CtrlId, 1)
                    GUICtrlSetBkColor($Label, $clr[1])
                    IniWrite($Ini, "Color", $clr[0], $clr[1])
                Case "Green"
                    Local $clr = FindColor(@GUI_CtrlId, 2)
                    GUICtrlSetBkColor($Label, $clr[1])
                    IniWrite($Ini, "Color", $clr[0], $clr[1])
                Case "Dark"
                    Local $clr = FindColor(@GUI_CtrlId, 3)
                    GUICtrlSetBkColor($Label, $clr[1])
                    IniWrite($Ini, "Color", $clr[0], $clr[1])
                Case Else
                    GUICtrlSetBkColor($Label, 0x00FF00)
            EndSwitch
    EndSwitch       
EndFunc

Func FindColor($cID, $LGD)
    For $i = 1 To $Color[0]
        If StringInStr($Color[$i], GUICtrlRead(_GUICtrlTreeView_GetParentParam($Mommy, $cID),1)) Then
            Local $SSC = StringSplit($Color[$i], ","), $aRet[2]
            $aRet[0] = GUICtrlRead(_GUICtrlTreeView_GetParentParam($Mommy, $cID),1)
            $aRet[1] = $SSC[$LGD + 1]
            Return $aRet
        EndIf   
    Next
EndFunc

Cheers

Share this post


Link to post
Share on other sites

Hi, based on the $Annette snippet

#include <GuiConstants.au3>
#Include <GuiTreeView.au3>

Opt("GUIOnEventMode", 1) 

Global $Ini = @ScriptDir & "\test.ini"
Global $Color = StringSplit("Anette Larsson  (130),0xFB19FF,0x00FF00,0x011002|" & _
                                "Anette Magnusson (130),0xDBB9A1,0x47AA0B,0x0B0500|" & _
                                "Anette Östberg (330),0xBB99FF,0x23FF07,0x0B0001", "|")
; GUI
$MyGUI = GuiCreate("Flash", 533, 634, -1, -1, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $MyGUI)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)

; TAB
GuiCtrlCreateTab(0, 0, 480, 500)
GuiCtrlCreateTabItem("TreeView")
GuiCtrlCreateLabel("Location (Value) ", 40, 40)
    
; TREEVIEW DAYLIGHT
$Mommy = GuiCtrlCreateTreeView(20, 60, 220, 420,BitOr($TVS_HASBUTTONS,$TVS_SINGLEEXPAND,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE)

    $Annette = GuiCtrlCreateTreeViewItem("A", $Mommy)
        $Larsson = GuiCtrlCreateTreeViewItem("Anette Larsson  (130)", $Annette)
            GuiCtrlCreateTreeViewItem("Light", $Larsson);0xFB19FF
            GuiCtrlCreateTreeViewItem("Green", $Larsson);0x00FF00
            GuiCtrlCreateTreeViewItem("Dark", $Larsson);0x011002

        $Magnusson = GuiCtrlCreateTreeViewItem("Anette Magnusson (130)", $Annette)
            GuiCtrlCreateTreeViewItem("Light", $Magnusson);0xDBB9A1
            GuiCtrlCreateTreeViewItem("Green", $Magnusson);0x47AA0B
            GuiCtrlCreateTreeViewItem("Dark", $Magnusson);0x0B0500

        $Ostberg = GuiCtrlCreateTreeViewItem("Anette Östberg (330)", $Annette)
            GuiCtrlCreateTreeViewItem("Light", $OstBerg);0xBB99FF
            GuiCtrlCreateTreeViewItem("Green", $Ostberg);0x23FF07
            GuiCtrlCreateTreeViewItem("Dark", $OstBerg);0x0B0001
    
    $Dummy = GUICtrlCreateDummy()

For $i = $Annette To $Dummy
    GUICtrlSetOnEvent($i, "Event")
Next    

$Label = GuiCtrlCreateLabel("", 420, 60, 40, 40,-1,$WS_EX_CLIENTEDGE)
GuiCtrlSetBkColor(-1, 0x00FF00)
GuiCtrlCreateButton("GO!", 380, 460, 80, 30)


GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            Switch GUICtrlRead(@GUI_CtrlId, 1)
                Case "Light"
                    Local $clr = FindColor(@GUI_CtrlId, 1)
                    GUICtrlSetBkColor($Label, $clr[1])
                    IniWrite($Ini, "Color", $clr[0], $clr[1])
                Case "Green"
                    Local $clr = FindColor(@GUI_CtrlId, 2)
                    GUICtrlSetBkColor($Label, $clr[1])
                    IniWrite($Ini, "Color", $clr[0], $clr[1])
                Case "Dark"
                    Local $clr = FindColor(@GUI_CtrlId, 3)
                    GUICtrlSetBkColor($Label, $clr[1])
                    IniWrite($Ini, "Color", $clr[0], $clr[1])
                Case Else
                    GUICtrlSetBkColor($Label, 0x00FF00)
            EndSwitch
    EndSwitch       
EndFunc

Func FindColor($cID, $LGD)
    For $i = 1 To $Color[0]
        If StringInStr($Color[$i], GUICtrlRead(_GUICtrlTreeView_GetParentParam($Mommy, $cID),1)) Then
            Local $SSC = StringSplit($Color[$i], ","), $aRet[2]
            $aRet[0] = GUICtrlRead(_GUICtrlTreeView_GetParentParam($Mommy, $cID),1)
            $aRet[1] = $SSC[$LGD + 1]
            Return $aRet
        EndIf   
    Next
EndFunc

Cheers

WOW! this one I could not even imagine when reading help files and studying forums.

I can follow what you have done very nicely.

That is exactly how I wanted it,when displaying different colors. Is it just possible to write the displayed color to one single line in the ini file? eg. Color = 0x23FF07 and not different strings on each name. just one line and 1 value

Thanks you so much!

Share this post


Link to post
Share on other sites

Hi, Color to 1 line in the ini file no probs. It makes the code mildly shorter :D

#include <GuiConstants.au3>
#Include <GuiTreeView.au3>

Opt("GUIOnEventMode", 1)

Global $Ini = @ScriptDir & "\test.ini"
Global $Color = StringSplit("Anette Larsson  (130),0xFB19FF,0x00FF00,0x011002|" & _
                                "Anette Magnusson (130),0xDBB9A1,0x47AA0B,0x0B0500|" & _
                                "Anette Östberg (330),0xBB99FF,0x23FF07,0x0B0001", "|")
; GUI
$MyGUI = GuiCreate("Flash", 533, 634, -1, -1, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $MyGUI)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)

; TAB
GuiCtrlCreateTab(0, 0, 480, 500)
GuiCtrlCreateTabItem("TreeView")
GuiCtrlCreateLabel("Location (Value) ", 40, 40)
   
; TREEVIEW DAYLIGHT
$Mommy = GuiCtrlCreateTreeView(20, 60, 220, 420,BitOr($TVS_HASBUTTONS,$TVS_SINGLEEXPAND,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE)

    $Annette = GuiCtrlCreateTreeViewItem("A", $Mommy)
        $Larsson = GuiCtrlCreateTreeViewItem("Anette Larsson  (130)", $Annette)
            GuiCtrlCreateTreeViewItem("Light", $Larsson);0xFB19FF
            GuiCtrlCreateTreeViewItem("Green", $Larsson);0x00FF00
            GuiCtrlCreateTreeViewItem("Dark", $Larsson);0x011002

        $Magnusson = GuiCtrlCreateTreeViewItem("Anette Magnusson (130)", $Annette)
            GuiCtrlCreateTreeViewItem("Light", $Magnusson);0xDBB9A1
            GuiCtrlCreateTreeViewItem("Green", $Magnusson);0x47AA0B
            GuiCtrlCreateTreeViewItem("Dark", $Magnusson);0x0B0500

        $Ostberg = GuiCtrlCreateTreeViewItem("Anette Östberg (330)", $Annette)
            GuiCtrlCreateTreeViewItem("Light", $OstBerg);0xBB99FF
            GuiCtrlCreateTreeViewItem("Green", $Ostberg);0x23FF07
            GuiCtrlCreateTreeViewItem("Dark", $OstBerg);0x0B0001
   
    $Dummy = GUICtrlCreateDummy()

For $i = $Annette To $Dummy
    GUICtrlSetOnEvent($i, "Event")
Next   

$Label = GuiCtrlCreateLabel("", 420, 60, 40, 40,-1,$WS_EX_CLIENTEDGE)
GuiCtrlSetBkColor(-1, 0x00FF00)
GuiCtrlCreateButton("GO!", 380, 460, 80, 30)


GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            Switch GUICtrlRead(@GUI_CtrlId, 1)
                Case "Light"
                    GUICtrlSetBkColor($Label, FindColor(@GUI_CtrlId, 1))
                Case "Green"
                    GUICtrlSetBkColor($Label, FindColor(@GUI_CtrlId, 2))
                Case "Dark"
                    GUICtrlSetBkColor($Label, FindColor(@GUI_CtrlId, 3))
                Case Else
                    GUICtrlSetBkColor($Label, 0x00FF00)
            EndSwitch
    EndSwitch      
EndFunc

Func FindColor($cID, $LGD)
    For $i = 1 To $Color[0]
        If StringInStr($Color[$i], GUICtrlRead(_GUICtrlTreeView_GetParentParam($Mommy, $cID),1)) Then
            Local $SSC = StringSplit($Color[$i], ",")
            IniWrite($Ini, "Color", "ColorChosen", $SSC[$LGD + 1])
            Return $SSC[$LGD + 1]
        EndIf   
    Next
EndFunc

Cheers

Share this post


Link to post
Share on other sites

Hi, Color to 1 line in the ini file no probs. It makes the code mildly shorter :D

#include <GuiConstants.au3>
#Include <GuiTreeView.au3>

Opt("GUIOnEventMode", 1)

Global $Ini = @ScriptDir & "\test.ini"
Global $Color = StringSplit("Anette Larsson  (130),0xFB19FF,0x00FF00,0x011002|" & _
                                "Anette Magnusson (130),0xDBB9A1,0x47AA0B,0x0B0500|" & _
                                "Anette Östberg (330),0xBB99FF,0x23FF07,0x0B0001", "|")
; GUI
$MyGUI = GuiCreate("Flash", 533, 634, -1, -1, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $MyGUI)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)

; TAB
GuiCtrlCreateTab(0, 0, 480, 500)
GuiCtrlCreateTabItem("TreeView")
GuiCtrlCreateLabel("Location (Value) ", 40, 40)
   
; TREEVIEW DAYLIGHT
$Mommy = GuiCtrlCreateTreeView(20, 60, 220, 420,BitOr($TVS_HASBUTTONS,$TVS_SINGLEEXPAND,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE)

    $Annette = GuiCtrlCreateTreeViewItem("A", $Mommy)
        $Larsson = GuiCtrlCreateTreeViewItem("Anette Larsson  (130)", $Annette)
            GuiCtrlCreateTreeViewItem("Light", $Larsson);0xFB19FF
            GuiCtrlCreateTreeViewItem("Green", $Larsson);0x00FF00
            GuiCtrlCreateTreeViewItem("Dark", $Larsson);0x011002

        $Magnusson = GuiCtrlCreateTreeViewItem("Anette Magnusson (130)", $Annette)
            GuiCtrlCreateTreeViewItem("Light", $Magnusson);0xDBB9A1
            GuiCtrlCreateTreeViewItem("Green", $Magnusson);0x47AA0B
            GuiCtrlCreateTreeViewItem("Dark", $Magnusson);0x0B0500

        $Ostberg = GuiCtrlCreateTreeViewItem("Anette Östberg (330)", $Annette)
            GuiCtrlCreateTreeViewItem("Light", $OstBerg);0xBB99FF
            GuiCtrlCreateTreeViewItem("Green", $Ostberg);0x23FF07
            GuiCtrlCreateTreeViewItem("Dark", $OstBerg);0x0B0001
   
    $Dummy = GUICtrlCreateDummy()

For $i = $Annette To $Dummy
    GUICtrlSetOnEvent($i, "Event")
Next   

$Label = GuiCtrlCreateLabel("", 420, 60, 40, 40,-1,$WS_EX_CLIENTEDGE)
GuiCtrlSetBkColor(-1, 0x00FF00)
GuiCtrlCreateButton("GO!", 380, 460, 80, 30)


GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            Switch GUICtrlRead(@GUI_CtrlId, 1)
                Case "Light"
                    GUICtrlSetBkColor($Label, FindColor(@GUI_CtrlId, 1))
                Case "Green"
                    GUICtrlSetBkColor($Label, FindColor(@GUI_CtrlId, 2))
                Case "Dark"
                    GUICtrlSetBkColor($Label, FindColor(@GUI_CtrlId, 3))
                Case Else
                    GUICtrlSetBkColor($Label, 0x00FF00)
            EndSwitch
    EndSwitch      
EndFunc

Func FindColor($cID, $LGD)
    For $i = 1 To $Color[0]
        If StringInStr($Color[$i], GUICtrlRead(_GUICtrlTreeView_GetParentParam($Mommy, $cID),1)) Then
            Local $SSC = StringSplit($Color[$i], ",")
            IniWrite($Ini, "Color", "ColorChosen", $SSC[$LGD + 1])
            Return $SSC[$LGD + 1]
        EndIf   
    Next
EndFunc

Cheers

Wonderfull

It looks so easy and it is fairly simple to understand when you see it. Even though I would never have comed up with this.

Another knowledge gained. :D

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