Jump to content

GUI Treeview HELP


ioctl
 Share

Recommended Posts

Maybe its easy for you , but iam newbe to autoit and i cant find a solution.

We have a treeview example..

When i check an item , "Effect1" or "Style1" or both of them and click OK how can i make it to run an exe file or a function?

Thanks in advance!

#include <GUIConstants.au3>

GUICreate("GUI with more treeviews",340,200,-1,-1,BitOr($WS_MINIMIZEBOX,$WS_MAXIMIZEBOX,$WS_GROUP,$WS_CAPTION,$WS_POPUP,$WS_SYSMENU))

$maintree = GUICtrlCreateTreeView (10,10,120,150)

$aboutitem = GUICtrlCreateTreeViewItem ("About",$maintree)

$generalitem = GUICtrlCreateTreeViewItem ("General",$maintree)

$toolsitem = GUICtrlCreateTreeViewItem ("Tools",$maintree)

$effectitem = GUICtrlCreateTreeViewItem ("Effects",$generalitem)

$styleitem = GUICtrlCreateTreeViewItem ("Styles",$generalitem)

$cmditem = GUICtrlCreateTreeViewItem ("Commandline",$toolsitem)

$miscitem = GUICtrlCreateTreeViewItem ("Misc",$toolsitem)

$descgroup = GUICtrlCreateGroup ("Description",140,105,180,55)

GUICtrlSetState (-1,$GUI_HIDE)

$effectsgroup = GUICtrlCreateGroup ("Effects",140,5,180,95)

GUICtrlSetState (-1,$GUI_HIDE)

$effectstree = GUICtrlCreateTreeView (150,20,160,70,BitOr($TVS_CHECKBOXES,$TVS_DISABLEDRAGDROP),$WS_EX_CLIENTEDGE)

GUICtrlSetState (-1,$GUI_HIDE)

$effect1 = GUICtrlCreateTreeViewItem ("Effect 1",$effectstree)

$effect2 = GUICtrlCreateTreeViewItem ("Effect 2",$effectstree)

$effect3 = GUICtrlCreateTreeViewItem ("Effect 3",$effectstree)

$effect4 = GUICtrlCreateTreeViewItem ("Effect 4",$effectstree)

$effect5 = GUICtrlCreateTreeViewItem ("Effect 5",$effectstree)

$stylesgroup = GUICtrlCreateGroup ("Styles",140,5,180,95)

GUICtrlSetState (-1,$GUI_HIDE)

$stylestree = GUICtrlCreateTreeView (150,20,160,70,BitOr($TVS_CHECKBOXES,$TVS_DISABLEDRAGDROP),$WS_EX_CLIENTEDGE)

GUICtrlSetState (-1,$GUI_HIDE)

$style1 = GUICtrlCreateTreeViewItem ("Style 1",$stylestree)

$style2 = GUICtrlCreateTreeViewItem ("Style 2",$stylestree)

$style3 = GUICtrlCreateTreeViewItem ("Style 3",$stylestree)

$style4 = GUICtrlCreateTreeViewItem ("Style 4",$stylestree)

$style5 = GUICtrlCreateTreeViewItem ("Style 5",$stylestree)

$aboutlabel = GUICtrlCreateLabel ("Select the Encryption that you want to test.",133,10,210,15)

$cancelbutton = GUICtrlCreateButton ("Exit",130,170,70,20)

GUISetState()

GUIctrlSetState ($effect1,$GUI_CHECKED)

GUIctrlSetState ($effect3,$GUI_CHECKED)

GUIctrlSetState ($style4,$GUI_CHECKED)

GUIctrlSetState ($style5,$GUI_CHECKED)

While 1

$msg = GUIGetMsg()

Select

  Case $msg = -3 Or $msg = -1 Or $msg = $cancelbutton

  ExitLoop

  Case $msg = $aboutitem

  GUIctrlSetState ($descgroup,$GUI_HIDE)

  GUIctrlSetState ($effectstree,$GUI_HIDE)

  GUIctrlSetState ($effectsgroup,$GUI_HIDE)

  GUIctrlSetState ($stylestree,$GUI_HIDE)

  GUIctrlSetState ($stylesgroup,$GUI_HIDE)

  GUIctrlSetState ($aboutlabel,$GUI_SHOW)

 

  Case $msg = $effectitem

  GUIctrlSetState ($stylestree,$GUI_HIDE)

  GUIctrlSetState ($stylesgroup,$GUI_HIDE)

  GUIctrlSetState ($aboutlabel,$GUI_HIDE)

  GUIctrlSetState ($effectsgroup,$GUI_SHOW)

  GUIctrlSetState ($descgroup,$GUI_SHOW)

  GUICtrlSetState($effectstree,$GUI_SHOW)

  GUICtrlSetBkColor ($effectstree,0xD0F0F0)

  ;GUIctrlSetState...($effectstree,$GUI_SHOW)

   

  Case $msg = $styleitem

  GUIctrlSetState ($effectstree,$GUI_HIDE)

  GUIctrlSetState ($effectsgroup,$GUI_HIDE)

  GUIctrlSetState ($aboutlabel,$GUI_HIDE)

  GUIctrlSetState ($stylesgroup,$GUI_SHOW)

  GUIctrlSetState ($descgroup,$GUI_SHOW)

  ;GUIctrlSetState.($stylestree,$GUI_SHOW)

  GUICtrlSetState ($stylestree,$GUI_SHOW)

  GUICtrlSetColor ($stylestree,0xD00000)

  GUICtrlSetBkColor ($stylestree,0xD0FFD0)

 

EndSelect

WEnd

GUIDelete()

Exit

Link to comment
Share on other sites

#include <GUIConstants.au3>

GUICreate("GUI with more treeviews", 340, 200, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_GROUP, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))

$maintree = GUICtrlCreateTreeView(10, 10, 120, 150)
$aboutitem = GUICtrlCreateTreeViewItem("About", $maintree)
$generalitem = GUICtrlCreateTreeViewItem("General", $maintree)
$toolsitem = GUICtrlCreateTreeViewItem("Tools", $maintree)
$effectitem = GUICtrlCreateTreeViewItem("Effects", $generalitem)
$styleitem = GUICtrlCreateTreeViewItem("Styles", $generalitem)
$cmditem = GUICtrlCreateTreeViewItem("Commandline", $toolsitem)
$miscitem = GUICtrlCreateTreeViewItem("Misc", $toolsitem)

$descgroup = GUICtrlCreateGroup("Description", 140, 105, 180, 55)
GUICtrlSetState(-1, $GUI_HIDE)

$effectsgroup = GUICtrlCreateGroup("Effects", 140, 5, 180, 95)
GUICtrlSetState(-1, $GUI_HIDE)
$effectstree = GUICtrlCreateTreeView(150, 20, 160, 70, BitOR($TVS_CHECKBOXES, $TVS_DISABLEDRAGDROP), $WS_EX_CLIENTEDGE)
GUICtrlSetState(-1, $GUI_HIDE)
$effect1 = GUICtrlCreateTreeViewItem("Effect 1", $effectstree)
$effect2 = GUICtrlCreateTreeViewItem("Effect 2", $effectstree)
$effect3 = GUICtrlCreateTreeViewItem("Effect 3", $effectstree)
$effect4 = GUICtrlCreateTreeViewItem("Effect 4", $effectstree)
$effect5 = GUICtrlCreateTreeViewItem("Effect 5", $effectstree)

$stylesgroup = GUICtrlCreateGroup("Styles", 140, 5, 180, 95)
GUICtrlSetState(-1, $GUI_HIDE)
$stylestree = GUICtrlCreateTreeView(150, 20, 160, 70, BitOR($TVS_CHECKBOXES, $TVS_DISABLEDRAGDROP), $WS_EX_CLIENTEDGE)
GUICtrlSetState(-1, $GUI_HIDE)
$style1 = GUICtrlCreateTreeViewItem("Style 1", $stylestree)
$style2 = GUICtrlCreateTreeViewItem("Style 2", $stylestree)
$style3 = GUICtrlCreateTreeViewItem("Style 3", $stylestree)
$style4 = GUICtrlCreateTreeViewItem("Style 4", $stylestree)
$style5 = GUICtrlCreateTreeViewItem("Style 5", $stylestree)

$aboutlabel = GUICtrlCreateLabel("Select the Encryption that you want to test.", 133, 10, 210, 15)

$cancelbutton = GUICtrlCreateButton("Exit", 130, 170, 70, 20)
GUISetState()

GUICtrlSetState($effect1, $GUI_CHECKED)
GUICtrlSetState($effect3, $GUI_CHECKED)
GUICtrlSetState($style4, $GUI_CHECKED)
GUICtrlSetState($style5, $GUI_CHECKED)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = -3 Or $msg = -1 Or $msg = $cancelbutton
            ExitLoop
        Case $msg = $aboutitem
            GUICtrlSetState($descgroup, $GUI_HIDE)
            GUICtrlSetState($effectstree, $GUI_HIDE)
            GUICtrlSetState($effectsgroup, $GUI_HIDE)
            GUICtrlSetState($stylestree, $GUI_HIDE)
            GUICtrlSetState($stylesgroup, $GUI_HIDE)
            GUICtrlSetState($aboutlabel, $GUI_SHOW)
            
        Case $msg = $effectitem
            GUICtrlSetState($stylestree, $GUI_HIDE)
            GUICtrlSetState($stylesgroup, $GUI_HIDE)
            GUICtrlSetState($aboutlabel, $GUI_HIDE)
            GUICtrlSetState($effectsgroup, $GUI_SHOW)
            GUICtrlSetState($descgroup, $GUI_SHOW)
            GUICtrlSetState($effectstree, $GUI_SHOW)
            GUICtrlSetBkColor($effectstree, 0xD0F0F0)
        ;GUIctrlSetState...($effectstree,$GUI_SHOW)
            
        Case $msg = $styleitem
            GUICtrlSetState($effectstree, $GUI_HIDE)
            GUICtrlSetState($effectsgroup, $GUI_HIDE)
            GUICtrlSetState($aboutlabel, $GUI_HIDE)
            GUICtrlSetState($stylesgroup, $GUI_SHOW)
            GUICtrlSetState($descgroup, $GUI_SHOW)
        ;GUIctrlSetState.($stylestree,$GUI_SHOW)
            GUICtrlSetState($stylestree, $GUI_SHOW)
            GUICtrlSetColor($stylestree, 0xD00000)
            GUICtrlSetBkColor($stylestree, 0xD0FFD0)
            
        Case $msg = $cmditem
        ; do what you want here
        ; for example
            MsgBox(0, "Selected", "CommandLine")
        ; or for example
            Run(@ComSpec & ' /K DIR /W')
        ; or for example
            _MyFunc()
        Case $msg = $miscitem
        ; do what you want here
        ; for example
            MsgBox(0, "Selected", "Misc")
    EndSelect
WEnd

GUIDelete()
Exit

Func _MyFunc()
    MsgBox(0, "Selected", "CommandLine: In _MyFunc Now.")
EndFunc  ;==>_MyFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I still have a question. Lets make my example more clear to you.

Example : General -> Programs -> notepad - cmd - paint...

When i check some of these programs and click OK to open only the checked programs.

Thanks in advance again! :)

#include <GUIConstants.au3>

GUICreate("GUI with more treeviews", 340, 200, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_GROUP, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))

$maintree = GUICtrlCreateTreeView(10, 10, 120, 150)

$aboutitem = GUICtrlCreateTreeViewItem("About", $maintree)

$generalitem = GUICtrlCreateTreeViewItem("General", $maintree)

$toolsitem = GUICtrlCreateTreeViewItem("Tools", $maintree)

$effectitem = GUICtrlCreateTreeViewItem("Programs", $generalitem)

$styleitem = GUICtrlCreateTreeViewItem("Styles", $generalitem)

$cmditem = GUICtrlCreateTreeViewItem("Commandline", $toolsitem)

$miscitem = GUICtrlCreateTreeViewItem("Misc", $toolsitem)

$descgroup = GUICtrlCreateGroup("Description", 140, 105, 180, 55)

GUICtrlSetState(-1, $GUI_HIDE)

$effectsgroup = GUICtrlCreateGroup("Programs", 140, 5, 180, 95)

GUICtrlSetState(-1, $GUI_HIDE)

$effectstree = GUICtrlCreateTreeView(150, 20, 160, 70, BitOR($TVS_CHECKBOXES, $TVS_DISABLEDRAGDROP), $WS_EX_CLIENTEDGE)

GUICtrlSetState(-1, $GUI_HIDE)

$notepad = GUICtrlCreateTreeViewItem("notepad", $effectstree)

$command_line = GUICtrlCreateTreeViewItem("command_line", $effectstree)

$paint = GUICtrlCreateTreeViewItem("paint", $effectstree)

$effect4 = GUICtrlCreateTreeViewItem("program4", $effectstree)

$effect5 = GUICtrlCreateTreeViewItem("program5", $effectstree)

$stylesgroup = GUICtrlCreateGroup("Styles", 140, 5, 180, 95)

GUICtrlSetState(-1, $GUI_HIDE)

$stylestree = GUICtrlCreateTreeView(150, 20, 160, 70, BitOR($TVS_CHECKBOXES, $TVS_DISABLEDRAGDROP), $WS_EX_CLIENTEDGE)

GUICtrlSetState(-1, $GUI_HIDE)

$style1 = GUICtrlCreateTreeViewItem("Style 1", $stylestree)

$style2 = GUICtrlCreateTreeViewItem("Style 2", $stylestree)

$style3 = GUICtrlCreateTreeViewItem("Style 3", $stylestree)

$style4 = GUICtrlCreateTreeViewItem("Style 4", $stylestree)

$style5 = GUICtrlCreateTreeViewItem("Style 5", $stylestree)

$aboutlabel = GUICtrlCreateLabel("Select the Encryption that you want to test.", 133, 10, 210, 15)

$okbutton = GUICtrlCreateButton("OK", 250, 170, 70, 20)

$cancelbutton = GUICtrlCreateButton("Exit", 130, 170, 70, 20)

GUISetState()

GUICtrlSetState($notepad, $GUI_CHECKED)

GUICtrlSetState($style4, $GUI_CHECKED)

GUICtrlSetState($style5, $GUI_CHECKED)

While 1

    $msg = GUIGetMsg()

    Select

        Case $msg = -3 Or $msg = -1 Or $msg = $cancelbutton

            ExitLoop

        Case $msg = $aboutitem

            GUICtrlSetState($descgroup, $GUI_HIDE)

            GUICtrlSetState($effectstree, $GUI_HIDE)

            GUICtrlSetState($effectsgroup, $GUI_HIDE)

            GUICtrlSetState($stylestree, $GUI_HIDE)

            GUICtrlSetState($stylesgroup, $GUI_HIDE)

            GUICtrlSetState($aboutlabel, $GUI_SHOW)

           

        Case $msg = $effectitem

            GUICtrlSetState($stylestree, $GUI_HIDE)

            GUICtrlSetState($stylesgroup, $GUI_HIDE)

            GUICtrlSetState($aboutlabel, $GUI_HIDE)

            GUICtrlSetState($effectsgroup, $GUI_SHOW)

            GUICtrlSetState($descgroup, $GUI_SHOW)

            GUICtrlSetState($effectstree, $GUI_SHOW)

            GUICtrlSetBkColor($effectstree, 0xD0F0F0)

        ;GUIctrlSetState...($effectstree,$GUI_SHOW)

           

        Case $msg = $styleitem

            GUICtrlSetState($effectstree, $GUI_HIDE)

            GUICtrlSetState($effectsgroup, $GUI_HIDE)

            GUICtrlSetState($aboutlabel, $GUI_HIDE)

            GUICtrlSetState($stylesgroup, $GUI_SHOW)

            GUICtrlSetState($descgroup, $GUI_SHOW)

        ;GUIctrlSetState.($stylestree,$GUI_SHOW)

            GUICtrlSetState($stylestree, $GUI_SHOW)

            GUICtrlSetColor($stylestree, 0xD00000)

            GUICtrlSetBkColor($stylestree, 0xD0FFD0)

    MsgBox(0, "Selected", "CommandLine")

           

        Case $msg = $cmditem

        ; do what you want here

        ; for example

      MsgBox(0, "Selected", "CommandLine")

        ; or for example

            Run(@ComSpec & ' /K DIR /W')

        ; or for example

            _MyFunc()

        Case $msg = $miscitem

        ; do what you want here

        ; for example

            MsgBox(0, "Selected", "Misc")

 

 

 

    EndSelect

WEnd

GUIDelete()

Exit

Func _MyFunc()

    MsgBox(0, "FUNK", "CommandLine: In _MyFunc Now.")

EndFunc  ;==>_MyFunc

Link to comment
Share on other sites

up

<{POST_SNAPBACK}>

I am not sure to understand your problem. :">

Your script get call when you click commandline, misc and style (msgbox in action).

so you can do whatever you want in place of those msgbox.

you nead to use GuiCtrlRead/State of the control you want to know and act accordingly.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...