Jump to content
Sign in to follow this  
Anonymouse

TreeView multiple functions under each option

Recommended Posts

Anonymouse

This is a bit difficult to explain, so I'll do my best. I'm leaving an example, below.

I wish to click an item on the treeview (ie:dining subitem under food) and in GROUP1 and the title of GROUP1 be changed to "Food - Dining", then in GROUP1 a list of combo boxes be listed with Labels, (ie: Deny's with a combo box under it that includes all of the items sold at Deny's) etc. etc. with other treeview items.

I wish for it to store all of these items (maybe in a temporary file?) until I am finished with that day. I also wish to be able to select what type of day it is and have that stored to the Day aswell (ie: Day1 = Weekday)

Now I don't know if I need a load button at the bottom of this tab, or maybe on the next tab to send all of this data to Tab 2 in designated area's.

I will also provide some coding that I have written, as well as some that I have searched for and found.

Posted Image

Posted Image

This is coding I came up with for sending information from an input box to a label, I assume it should be close to the same with Combo boxes:

#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("Form3", 163, 115, 311, 345)
$Input1 = GUICtrlCreateInput("Input1", 24, 16, 121, 21, 0)
GUICtrlSetLimit(-1, 26)
$Label1 = GUICtrlCreateLabel("Label1", 24, 48, 124, 17)
$Save = GUICtrlCreateButton("Save", 40, 80, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $Answer, $msg, $nMsg
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Form3
    $Answer = GUICtrlRead($Input1)
    $msg = GUIGetMsg()
                    Case $msg = $Save
    GUICtrlSetData($Label1, $Answer)
    EndSwitch
WEnd

I also don't quite understand this code, or atleast how to make it work for combo boxes, as it only defines text. This code takes a TreeView and sets text to each item on the tree:

#include <GuiConstants.au3>
#include <GuiTreeView.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

Global $aTreeItemDesc[4] = ["Description of Car", "Description of SUV", "Description of Truck", "Description of Motorcycle"]

$hGUI = GUICreate("Test", 300, 200)

$hTab = GUICtrlCreateTab(10, 10, 280, 180)

$TabItem1 = GUICtrlCreateTabItem("TabItem 1")

$hTreeView1 = GUICtrlCreateTreeView(25, 40, 100, 140, -1, $WS_EX_CLIENTEDGE)

GUICtrlCreateTreeViewItem("Car" & 1, $hTreeView1)
GUICtrlCreateTreeViewItem("SUV" & 2, $hTreeView1)
GUICtrlCreateTreeViewItem("Truck" & 2, $hTreeView1)
GUICtrlCreateTreeViewItem("Motorcycle" & 4, $hTreeView1)

$hEdit1 = GUICtrlCreateEdit("", 150, 80, 110, 60, $ES_WANTRETURN)

GUICtrlCreateTabItem("")

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local $tNMHDR, $IdFrom, $iCode
   
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $IdFrom = DllStructGetData($tNMHDR, "IdFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
   
    Switch $IdFrom
        Case $hTreeView1
            Switch $iCode
                Case $NM_CLICK
                    Local $tPoint = _WinAPI_GetMousePos(True, GUICtrlGetHandle($hTreeView1))
                   
                    Local $iX = DllStructGetData($tPoint, "X")
                    Local $iY = DllStructGetData($tPoint, "Y")
                   
                    Local $iItem = _GUICtrlTreeView_HitTestItem($hTreeView1, $iX, $iY)
                   
                    If $iItem <> 0 Then
                        GUICtrlSetData($hEdit1, $aTreeItemDesc[_GUICtrlTreeView_Index($hTreeView1, $iItem)])
                    EndIf
            EndSwitch
    EndSwitch
   
    Return $GUI_RUNDEFMSG
EndFunc

And finally the code for the GUI structure without any functions yet coded into it, just if you want to actually see what my base example is in realtime:

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Price of Life", 398, 529, 320, 194)
GUISetIcon("D:\005.ico")
$PageControl1 = GUICtrlCreateTab(8, 8, 380, 512)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Input Information")
$Combo1 = GUICtrlCreateCombo("", 24, 80, 81, 25)
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Combo2 = GUICtrlCreateCombo("", 136, 80, 89, 25)
GUICtrlSetData(-1, "Weekday|Weekend|Holiday")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$TreeView1 = GUICtrlCreateTreeView(248, 40, 121, 57, BitOR($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS,$WS_GROUP,$WS_TABSTOP,$WS_HSCROLL))
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$TreeView1_0 = GUICtrlCreateTreeViewItem("Food", $TreeView1)
$TreeView1_1 = GUICtrlCreateTreeViewItem("Fast Food", $TreeView1_0)
$TreeView1_2 = GUICtrlCreateTreeViewItem("Dining", $TreeView1_0)
$TreeView1_3 = GUICtrlCreateTreeViewItem("5 Star", $TreeView1_0)
$TreeView1_4 = GUICtrlCreateTreeViewItem("Groceries", $TreeView1_0)
$TreeView1_5 = GUICtrlCreateTreeViewItem("Drink", $TreeView1)
$TreeView1_6 = GUICtrlCreateTreeViewItem("Coffee", $TreeView1_5)
$TreeView1_7 = GUICtrlCreateTreeViewItem("Alcohol", $TreeView1_5)
$TreeView1_8 = GUICtrlCreateTreeViewItem("Caffeine", $TreeView1_5)
$Label1 = GUICtrlCreateLabel("Day Number:", 24, 56, 66, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label2 = GUICtrlCreateLabel("Day Type:", 136, 56, 53, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Group1 = GUICtrlCreateGroup("Title Of Tree Item Selected", 24, 120, 345, 377, $WS_VSCROLL)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet2 = GUICtrlCreateTabItem("Output Information")
$Combo3 = GUICtrlCreateCombo("", 32, 56, 73, 25)
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label3 = GUICtrlCreateLabel("Day Number:", 32, 40, 66, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label4 = GUICtrlCreateLabel("Day Type:", 248, 40, 53, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label5 = GUICtrlCreateLabel("Day Type Goes Here", 248, 56, 116, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label6 = GUICtrlCreateLabel("Food:", 32, 88, 31, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label7 = GUICtrlCreateLabel("Fast Food Cost Goes Here", 248, 112, 132, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label8 = GUICtrlCreateLabel("Fast Food-", 48, 112, 56, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label9 = GUICtrlCreateLabel("Dining-", 48, 136, 37, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label10 = GUICtrlCreateLabel("Dining Cost Goes Here", 248, 136, 113, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label11 = GUICtrlCreateLabel("5 Star Dining-", 48, 160, 69, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label12 = GUICtrlCreateLabel("5 Star Dining Cost Here", 248, 160, 116, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label13 = GUICtrlCreateLabel("Groceries-", 48, 184, 56, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label14 = GUICtrlCreateLabel("Grocery Costs Goes Here", 248, 184, 130, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label15 = GUICtrlCreateLabel("Total Cost Of Food:", 40, 208, 97, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label16 = GUICtrlCreateLabel("Total Cost Goes Here", 248, 208, 107, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

[EDIT1] Forgot to add, I'm not just asking for coding. I wish to learn, so any hints or shoves in the right direction would be greatly appreciated. If you think I'll learn better from code, or it's easier to explain that way - please also give a brief explanation. thanks a bunches :)[/EDIT1]

[EDIT2] I understand a bit more of it now, and also fixed a problem with a loop that slowed down my code.[/EDIT2]

Edited by Anonymouse

children may smile; the wise ponder- Dr. Holmes of Hardvard Medical School on an Ether BingeLove Makes The World Go Round?So does five shots of tequila. What's your point?[quote name='Valik' date='Jun 5 2008, 05:13 PM']wraithdu, 24 hours. Said I have a bad attitude, just driving the point home with a ban.[/quote]This is classic. :)

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.