Jump to content

help: ControlTreeView


usera
 Share

Recommended Posts

Greeting,

According to example file: c:\Program Files\AutoIt3\Examples\Helpfile\ControlTreeView.au3

I did some changes for my request as below:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

; Author: Zedna

#include <GUIConstantsEx.au3>

#include <TreeviewConstants.au3>

#include <WindowsConstants.au3>

$gui = GUICreate("ControlTreeview test", 212, 212)

$treeview = GUICtrlCreateTreeView(6, 6, 200, 160, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE)

$h_tree = ControlGetHandle($gui, "", $treeview)

$root = GUICtrlCreateTreeViewItem("Root", $treeview)

$item1 = GUICtrlCreateTreeViewItem("Copy file", $root)

$item2 = GUICtrlCreateTreeViewItem("Delete File", $root)

$item3 = GUICtrlCreateTreeViewItem("Rename File", $root)

$item4 = GUICtrlCreateTreeViewItem("Print", $root)

$item41 = GUICtrlCreateTreeViewItem("Report 1", $item4)

$item42 = GUICtrlCreateTreeViewItem("Report 2", $item4)

$item5 = GUICtrlCreateTreeViewItem("Item 5", $root)

GUISetState(@SW_SHOW)

; some examples

ControlTreeView ($gui, "", $h_tree, "Expand", "Root")

ControlTreeView ($gui, "", $h_tree, "Exists", "Root|Print")

ControlTreeView ($gui, "", $h_tree, "Check", "Root|Print")

ControlTreeView ($gui, "", $h_tree, "Select", "Root|Print")

ControlTreeView ($gui, "", $h_tree, "Expand", "Root|Print")

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

-------------------------------------------------------------------------------------------------------------------------

just want to know how:

1. can I get the information what the user did check. for example usera want to copy file and print report1 ; but userb want to rename file and print report1 and report2.

2. How can I add an ok button blew, let the user close the selection windows and the program go ahead do what they want to do.

Thanks

Link to comment
Share on other sites

  • Moderators

usera,

First point: Please do not bump your own thread within 24 hours. ;-)

Second point: As you evidently do not yet know enough about AutoIt to solve this very simple question yourself, I recommend reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) as this will help you enormously. You should also look at the excellent tutorials that you will find here and here.

To give you an idea of what you can do, this amended version of your script will write to the SciTE console window when you check the 'Copy file' box. To complete the script you would need to write functions for each of the checkboxes (the very simple version of the Copy_File function should give you the idea) so that each time you press the button you run the relevant functions:

#include <GUIConstantsEx.au3>
#include <TreeviewConstants.au3>
#include <WindowsConstants.au3>

$gui = GUICreate("ControlTreeview test", 200, 220)
$treeview = GUICtrlCreateTreeView(10, 10, 180, 160, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE)
$h_tree = ControlGetHandle($gui, "", $treeview)

$root = GUICtrlCreateTreeViewItem("Root", $treeview)
$item1 = GUICtrlCreateTreeViewItem("Copy file", $root)
$item2 = GUICtrlCreateTreeViewItem("Delete File", $root)
$item3 = GUICtrlCreateTreeViewItem("Rename File", $root)
$item4 = GUICtrlCreateTreeViewItem("Print", $root)
$item41 = GUICtrlCreateTreeViewItem("Report 1", $item4)
$item42 = GUICtrlCreateTreeViewItem("Report 2", $item4)
$item5 = GUICtrlCreateTreeViewItem("Item 5", $root)

$hButton = GUICtrlCreateButton("Go!", 60, 180, 80, 30)

GUISetState(@SW_SHOW)

Global $aAction[$item5 + 1]
$aAction[$item1] = "Copy_File"
$aAction[$item2] = "Delete_File"
$aAction[$item3] = "Rename_File"
$aAction[$item41] = "Print_Report_1"
$aAction[$item42] = "Print_Report_2"
$aAction[$item5] = "Do_Item_5"

ControlTreeView ($gui, "", $h_tree, "Expand", "Root")
ControlTreeView ($gui, "", $h_tree, "Expand", "Root|Print")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $hButton
            For $i = $root To $item5
                If BitAnd(GUICtrlRead($i), $GUI_CHECKED) = $GUI_CHECKED Then Call($aAction[$i])
            Next
    EndSwitch
WEnd

Func Copy_File()
    ConsoleWrite("Copy File" & @CRLF)
EndFunc

If you do not understand the advice or the amended code - you really do need to read the Help file and tutorials! But do not get discouraged - everyone has to start somewhere.

Have a go at writing another version of the script yourself - we are here if you run into problems.

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

Thanks, that is what I am looking for. you are GREAT!!!

usera,

First point: Please do not bump your own thread within 24 hours. ;-)

Second point: As you evidently do not yet know enough about AutoIt to solve this very simple question yourself, I recommend reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) as this will help you enormously. You should also look at the excellent tutorials that you will find here and here.

To give you an idea of what you can do, this amended version of your script will write to the SciTE console window when you check the 'Copy file' box. To complete the script you would need to write functions for each of the checkboxes (the very simple version of the Copy_File function should give you the idea) so that each time you press the button you run the relevant functions:

#include <GUIConstantsEx.au3>
#include <TreeviewConstants.au3>
#include <WindowsConstants.au3>

$gui = GUICreate("ControlTreeview test", 200, 220)
$treeview = GUICtrlCreateTreeView(10, 10, 180, 160, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE)
$h_tree = ControlGetHandle($gui, "", $treeview)

$root = GUICtrlCreateTreeViewItem("Root", $treeview)
$item1 = GUICtrlCreateTreeViewItem("Copy file", $root)
$item2 = GUICtrlCreateTreeViewItem("Delete File", $root)
$item3 = GUICtrlCreateTreeViewItem("Rename File", $root)
$item4 = GUICtrlCreateTreeViewItem("Print", $root)
$item41 = GUICtrlCreateTreeViewItem("Report 1", $item4)
$item42 = GUICtrlCreateTreeViewItem("Report 2", $item4)
$item5 = GUICtrlCreateTreeViewItem("Item 5", $root)

$hButton = GUICtrlCreateButton("Go!", 60, 180, 80, 30)

GUISetState(@SW_SHOW)

Global $aAction[$item5 + 1]
$aAction[$item1] = "Copy_File"
$aAction[$item2] = "Delete_File"
$aAction[$item3] = "Rename_File"
$aAction[$item41] = "Print_Report_1"
$aAction[$item42] = "Print_Report_2"
$aAction[$item5] = "Do_Item_5"

ControlTreeView ($gui, "", $h_tree, "Expand", "Root")
ControlTreeView ($gui, "", $h_tree, "Expand", "Root|Print")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $hButton
            For $i = $root To $item5
                If BitAnd(GUICtrlRead($i), $GUI_CHECKED) = $GUI_CHECKED Then Call($aAction[$i])
            Next
    EndSwitch
WEnd

Func Copy_File()
    ConsoleWrite("Copy File" & @CRLF)
EndFunc

If you do not understand the advice or the amended code - you really do need to read the Help file and tutorials! But do not get discouraged - everyone has to start somewhere.

Have a go at writing another version of the script yourself - we are here if you run into problems.

M23

Link to comment
Share on other sites

  • Moderators

usera,

Glad I could help, but please use the 'Add Reply' button which is about 1cm lower then the 'Reply' button you pressed to post the above. That way you do not copy the entire preceding post into your post.

It makes the thread much easier to read! :-)

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

  • Recently Browsing   0 members

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