Jump to content
Sign in to follow this  
Omega

Create a ComboBox inside the cell of a List

Recommended Posts

Omega

Hi, I have been doing some script to manually add items from a treeview to a list, after an item is added to the list, columns 3, 4 and 5 should be composed by ComboBoxes so the user can choose the options for each chosen item, but I dunno if I can add ComboBoxes inside a List Cell. I have also thought that I could simulate it by simply overlapping a ComboBox into the List Area, but it won't Focus.

I'd really appreciate any help in this issue, thanks to all who will help :)

Another thing I do not understand is why the second button ($Delete) is not resizing correctly if it has the same style as $Add

My Script so far is:

#include <GuiConstants.au3>
#Include <GuiImageList.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiTreeView.au3>
#include <GuiToolbar.au3>
#include <GuiComboBox.au3>

Local $Limit = 99
Local $TreeItem_Action[$Limit + 1]

$Main = GuiCreate("SmartBot v1", 900, 500, 200, 250, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetIcon("shell32.dll", 14)
$Tab1 = GUICtrlCreateTab(0, 30, 900, 480)
GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP)

#region Tab1
    
    $Tab1 = GUICtrlCreateTabItem("Buying Mode")
    
    #region TreeView
        $Label1 = GUICtrlCreateLabel("Sets", 5, 60, 56, 12)
        GUICtrlSetResizing( -1, $GUI_DOCKALL )
        $TreeView = GUICtrlCreateTreeView(5, 75, 185, 380, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE )
        GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH)
        #region Sets
            $b = 1
            While $b < 15
                $TreeItem_Action[$b - 1] = GUICtrlCreateTreeViewItem($b, $TreeView)
                _GUICtrlTreeView_SetIcon($TreeView, $TreeItem_Action[$b - 1], "shell32.dll", $B)
                $b = $b + 1
            WEnd
        #endregion
    #endregion treeview
    
    #region Button1 and Button2
        $Add = GUICtrlCreateButton("Add >>", 196, 250, 75, 25)
        GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE)
        $Delete = GUICtrlCreateButton("<< Delete", 196, 280, 75, 25)
        GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE)
    #endregion
    
    #region ListView
        $ListView = _GUICtrlListView_Create($Main, "N°", 275, 75, 605, 380, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS))
        GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP)
        _GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))
        _GUICtrlListView_SetColumnWidth($ListView, 0, 40)
        $hImage = _GUIImageList_Create(16, 16, 5, 3)
        
        $b = 1
        While $b < 15
            _GUIImageList_AddIcon($hImage, "shell32.dll", $B)
            $b = $b + 1
        WEnd
        
        _GUICtrlListView_SetImageList($ListView, $hImage, 1)
        $listcolset = _GUICtrlListView_AddColumn($ListView, "Selected Sets", 160)
        $listcolrarity = _GUICtrlListView_AddColumn($ListView, "Rarity", 90)
        $listcolversion = _GUICtrlListView_AddColumn($ListView, "Version", 90)
        $listcolowned = _GUICtrlListView_AddColumn($ListView, "Owned", 60)
        $listcolfortrade = _GUICtrlListView_AddColumn($ListView, "For Trade", 60)
        $listcolsortby = _GUICtrlListView_AddColumn($ListView, "Sort By", 105)
    #endregion ListView
    
    #region ToolBar
        $hToolbar = _GUICtrlToolbar_Create($Main, BitOR($TBSTYLE_TOOLTIPS,$TBSTYLE_FLAT))
        _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        _GUICtrlToolbar_AddButtonSep($hToolbar)
        _GUICtrlToolbar_AddButton($hToolbar, 1000, $STD_FILENEW)
        _GUICtrlToolbar_AddButtonSep($hToolbar)
        _GUICtrlToolbar_AddButton($hToolbar, 1002, $STD_FILESAVE)
        _GUICtrlToolbar_AddButtonSep($hToolbar)
        _GUICtrlToolbar_AddButton($hToolbar, 1002, $STD_HELP)
        _GUICtrlToolbar_AddButtonSep($hToolbar)
    #endregion
    
    #region MenuBar
        $MenuItem1 = GUICtrlCreateMenu("&File")
        $MenuItem_File1 = GUICtrlCreateMenuItem("Open", $MenuItem1)
        $MenuItem_File2 = GUICtrlCreateMenuItem("Save", $MenuItem1)
        $MenuItem_File2 = GUICtrlCreateMenuItem("Close", $MenuItem1)
        $MenuItem2 = GUICtrlCreateMenu("&Credits")
        $MenuItem_File1 = GUICtrlCreateMenuItem("About", $MenuItem2)
    #endregion
    
    #region ComboTest
        $ComboBox1 = GUICtrlCreateCombo("", 500, 200, 50, 20, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL, $CBS_NOINTEGRALHEIGHT), BitOR($WS_EX_TOPMOST, $WS_EX_APPWINDOW))
        GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH)
        GUICtrlSetData(-1,"item2|item3","item3") 
    #endregion
    
#endregion

GUICtrlCreateTabItem("")
GUICtrlSetState($Tab1,$GUI_SHOW)
;~ GUICtrlSetState($ComboBox1,$GUI_SHOW)
GUISetState(@SW_SHOW, $Main)
While 1
    $Msg = GUIGetMsg(1)
    Select
        Case $Msg[0] = $GUI_EVENT_CLOSE
            
            If $Msg[1] = $Main Then
                ExitLoop
            EndIf
            
        Case $Msg[0] = $Add
            
            $Search = 0
            While 1
                If _GUICtrlTreeView_GetSelected($TreeView, $TreeItem_Action[$Search]) = True Or $Search = $Limit Then
                    ExitLoop
                EndIf
                $Search = $Search + 1
            WEnd
            If $Search = $Limit Then
                MsgBox(0, "Message", "You Can't Add More Sets")
            Else
                _GUICtrlListView_AddItem($ListView, _GUICtrlListView_GetItemCount($ListView) + 1, $Search)
                _GUICtrlListView_AddSubItem($ListView, _GUICtrlListView_GetItemCount($ListView) - 1, _GUICtrlTreeView_GetText($TreeView, $TreeItem_Action[$Search]), 1)
                GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_DISABLED), -1, $Main)
                MsgBox(4144, "Message", "Set Added Successfully")
                GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX), -1, $Main)
            EndIf
            
        Case $Msg[0] = $Delete
            
            $Search = 0
            While 1
                If _GUICtrlListView_GetItemSelected($ListView, $Search) = True or $Search = $Limit Then
                    ExitLoop
                EndIf
                $Search = $Search + 1
            WEnd
            If $Search = $Limit Then
                MsgBox(0, "Message", "You Haven't Choosed a Set to Delete")
            Else
                _GUICtrlListView_DeleteItem($ListView, $Search)
                For $i = $Search To _GUICtrlListView_GetItemCount($ListView) - 1
                    _GUICtrlListView_SetItem($ListView, $i + 1, $i)
                Next
                GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_DISABLED), -1, $Main)
                MsgBox(4144, "Message", "Set Deleted")
                GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX), -1, $Main)
            EndIf
            
    EndSelect

WEnd

Share this post


Link to post
Share on other sites
martin

Hi, I have been doing some script to manually add items from a treeview to a list, after an item is added to the list, columns 3, 4 and 5 should be composed by ComboBoxes so the user can choose the options for each chosen item, but I dunno if I can add ComboBoxes inside a List Cell. I have also thought that I could simulate it by simply overlapping a ComboBox into the List Area, but it won't Focus.

I'd really appreciate any help in this issue, thanks to all who will help :)

Another thing I do not understand is why the second button ($Delete) is not resizing correctly if it has the same style as $Add

My Script so far is:

#include <GuiConstants.au3>
#Include <GuiImageList.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiTreeView.au3>
#include <GuiToolbar.au3>
#include <GuiComboBox.au3>

Local $Limit = 99
Local $TreeItem_Action[$Limit + 1]

$Main = GuiCreate("SmartBot v1", 900, 500, 200, 250, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetIcon("shell32.dll", 14)
$Tab1 = GUICtrlCreateTab(0, 30, 900, 480)
GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP)

#region Tab1
    
    $Tab1 = GUICtrlCreateTabItem("Buying Mode")
    
    #region TreeView
        $Label1 = GUICtrlCreateLabel("Sets", 5, 60, 56, 12)
        GUICtrlSetResizing( -1, $GUI_DOCKALL )
        $TreeView = GUICtrlCreateTreeView(5, 75, 185, 380, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE )
        GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH)
        #region Sets
            $b = 1
            While $b < 15
                $TreeItem_Action[$b - 1] = GUICtrlCreateTreeViewItem($b, $TreeView)
                _GUICtrlTreeView_SetIcon($TreeView, $TreeItem_Action[$b - 1], "shell32.dll", $B)
                $b = $b + 1
            WEnd
        #endregion
    #endregion treeview
    
    #region Button1 and Button2
        $Add = GUICtrlCreateButton("Add >>", 196, 250, 75, 25)
        GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE)
        $Delete = GUICtrlCreateButton("<< Delete", 196, 280, 75, 25)
        GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE)
    #endregion
    
    #region ListView
        $ListView = _GUICtrlListView_Create($Main, "N°", 275, 75, 605, 380, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS))
        GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP)
        _GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))
        _GUICtrlListView_SetColumnWidth($ListView, 0, 40)
        $hImage = _GUIImageList_Create(16, 16, 5, 3)
        
        $b = 1
        While $b < 15
            _GUIImageList_AddIcon($hImage, "shell32.dll", $B)
            $b = $b + 1
        WEnd
        
        _GUICtrlListView_SetImageList($ListView, $hImage, 1)
        $listcolset = _GUICtrlListView_AddColumn($ListView, "Selected Sets", 160)
        $listcolrarity = _GUICtrlListView_AddColumn($ListView, "Rarity", 90)
        $listcolversion = _GUICtrlListView_AddColumn($ListView, "Version", 90)
        $listcolowned = _GUICtrlListView_AddColumn($ListView, "Owned", 60)
        $listcolfortrade = _GUICtrlListView_AddColumn($ListView, "For Trade", 60)
        $listcolsortby = _GUICtrlListView_AddColumn($ListView, "Sort By", 105)
    #endregion ListView
    
    #region ToolBar
        $hToolbar = _GUICtrlToolbar_Create($Main, BitOR($TBSTYLE_TOOLTIPS,$TBSTYLE_FLAT))
        _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        _GUICtrlToolbar_AddButtonSep($hToolbar)
        _GUICtrlToolbar_AddButton($hToolbar, 1000, $STD_FILENEW)
        _GUICtrlToolbar_AddButtonSep($hToolbar)
        _GUICtrlToolbar_AddButton($hToolbar, 1002, $STD_FILESAVE)
        _GUICtrlToolbar_AddButtonSep($hToolbar)
        _GUICtrlToolbar_AddButton($hToolbar, 1002, $STD_HELP)
        _GUICtrlToolbar_AddButtonSep($hToolbar)
    #endregion
    
    #region MenuBar
        $MenuItem1 = GUICtrlCreateMenu("&File")
        $MenuItem_File1 = GUICtrlCreateMenuItem("Open", $MenuItem1)
        $MenuItem_File2 = GUICtrlCreateMenuItem("Save", $MenuItem1)
        $MenuItem_File2 = GUICtrlCreateMenuItem("Close", $MenuItem1)
        $MenuItem2 = GUICtrlCreateMenu("&Credits")
        $MenuItem_File1 = GUICtrlCreateMenuItem("About", $MenuItem2)
    #endregion
    
    #region ComboTest
        $ComboBox1 = GUICtrlCreateCombo("", 500, 200, 50, 20, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL, $CBS_NOINTEGRALHEIGHT), BitOR($WS_EX_TOPMOST, $WS_EX_APPWINDOW))
        GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH)
        GUICtrlSetData(-1,"item2|item3","item3") 
    #endregion
    
#endregion

GUICtrlCreateTabItem("")
GUICtrlSetState($Tab1,$GUI_SHOW)
;~ GUICtrlSetState($ComboBox1,$GUI_SHOW)
GUISetState(@SW_SHOW, $Main)
While 1
    $Msg = GUIGetMsg(1)
    Select
        Case $Msg[0] = $GUI_EVENT_CLOSE
            
            If $Msg[1] = $Main Then
                ExitLoop
            EndIf
            
        Case $Msg[0] = $Add
            
            $Search = 0
            While 1
                If _GUICtrlTreeView_GetSelected($TreeView, $TreeItem_Action[$Search]) = True Or $Search = $Limit Then
                    ExitLoop
                EndIf
                $Search = $Search + 1
            WEnd
            If $Search = $Limit Then
                MsgBox(0, "Message", "You Can't Add More Sets")
            Else
                _GUICtrlListView_AddItem($ListView, _GUICtrlListView_GetItemCount($ListView) + 1, $Search)
                _GUICtrlListView_AddSubItem($ListView, _GUICtrlListView_GetItemCount($ListView) - 1, _GUICtrlTreeView_GetText($TreeView, $TreeItem_Action[$Search]), 1)
                GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_DISABLED), -1, $Main)
                MsgBox(4144, "Message", "Set Added Successfully")
                GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX), -1, $Main)
            EndIf
            
        Case $Msg[0] = $Delete
            
            $Search = 0
            While 1
                If _GUICtrlListView_GetItemSelected($ListView, $Search) = True or $Search = $Limit Then
                    ExitLoop
                EndIf
                $Search = $Search + 1
            WEnd
            If $Search = $Limit Then
                MsgBox(0, "Message", "You Haven't Choosed a Set to Delete")
            Else
                _GUICtrlListView_DeleteItem($ListView, $Search)
                For $i = $Search To _GUICtrlListView_GetItemCount($ListView) - 1
                    _GUICtrlListView_SetItem($ListView, $i + 1, $i)
                Next
                GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_DISABLED), -1, $Main)
                MsgBox(4144, "Message", "Set Deleted")
                GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX), -1, $Main)
            EndIf
            
    EndSelect

WEnd
You have tried to apply "GUICtrlSetResizing(-1,..." to the list view but the -1 will refer to the last control ID which is the button because _GUICtrlListView_Create returns a handle not a control ID.

Eltorro has an example of adding components to listviews here.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Omega

You have tried to apply "GUICtrlSetResizing(-1,..." to the list view but the -1 will refer to the last control ID which is the button because _GUICtrlListView_Create returns a handle not a control ID.

Eltorro has an example of adding components to listviews here.

I already saw Eltorro example, but I cannot test his script since I think the latest autoit changed some settings like include files and global constants + it is too much code to understand (I will do take another look though).

Hmmm. I used _GUICtrlListView_Create instead of GUICtrlCreateListView to be able to use icons, when using GUICtrlCreateListView I dunno how to use icons.

Thanks for your answer.

EDIT: Typo

Edited by Omega

Share this post


Link to post
Share on other sites
martin

I already saw Eltorro example, but I cannot test his script since I think the latest autoit changed some settings like include files and global constants + it is too much code to understand (I will do take another look though).

Hmmm. I used _GUICtrlListView_Create instead of GUICtrlCreateListView to be able to use icons, when using GUICtrlCreateListView I dunno how to use icons.

Thanks for your answer.

EDIT: Typo

You can use GuiCtrlCreateListView and then using the functions in GuiListView.au3 by passing GuiCtrlGetHandle($TreeView)

Try changing your script like this

$ListViewA = GUICtrlCreateListView( "N°", 275, 75, 605, 380, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS))
GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP)
$listview = GUICtrlGetHandle($listviewA)
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Omega

You can use GuiCtrlCreateListView and then using the functions in GuiListView.au3 by passing GuiCtrlGetHandle($TreeView)

Try changing your script like this

$ListViewA = GUICtrlCreateListView( "N°", 275, 75, 605, 380, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS))
GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP)
$listview = GUICtrlGetHandle($listviewA)
Thanks for the help, it actually helped me, I am starting to use GUI's so I am not sure to understand the difference between Handle and Control ID, what is the difference or where can I find the difference between them, Id like a good explanation of them, so I can fully understand how _GUIxxx and GUIxxx works.

Share this post


Link to post
Share on other sites
Linux

same problem here. to use the icon I lost the already implemented context menus!

the problem is that _GUICtrlListView_AddItem dont return the control Id! is there any way to get the control ID of an index of a listview?

very interested in this topic.

Kind regards, linux


You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!"

Share this post


Link to post
Share on other sites
Omega

same problem here. to use the icon I lost the already implemented context menus!

the problem is that _GUICtrlListView_AddItem dont return the control Id! is there any way to get the control ID of an index of a listview?

very interested in this topic.

Kind regards, linux

Well, in my very short experience working on my script I found out that GUICtrlCreateListViewItem returns a Control ID, however I created the items with _GUICtrlListView_AddItem and _GUICtrlListView_AddSubItem, what Martin suggested actually worked fine:

You can use GuiCtrlCreateListView and then using the functions in GuiListView.au3 by passing GuiCtrlGetHandle($ListView) *** I think he meant this not $TreeView

Try changing your script like this

$ListViewA = GUICtrlCreateListView( "N°", 275, 75, 605, 380, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS))
GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP)
$listview = GUICtrlGetHandle($listviewA)
This is how the code is now. But I am having problems to make ListView Cells bigger so the ComboBoxes do not overlap over the other, please try running my script and adding elements, you will understand me better.

#include <GuiConstants.au3>
#Include <GuiImageList.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiTreeView.au3>
#include <GuiToolbar.au3>
#include <GuiComboBox.au3>
#Include <GuiComboBoxEx.au3>

Local $Limit = 99
Local $TreeView_1_Item_1[$Limit + 1]
Local $TreeView_2_Item_2[$Limit + 1]
Local $ComboBox_1[$Limit + 1][5]
Local $Item[$Limit + 1]
Local $Number_Width = 40
Local $Set_Width = 160
Local $Rarity_Width = 90
Local $Version_Width = 90
Local $Owned_Width = 60
Local $ForTrade_Width = 60
Local $SortBy_Width = 105
Local $PosX_[5]

$Main = GuiCreate("SmartBot v1", 1024, 500, 125, 250, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetFont(8.5)
GUISetIcon("shell32.dll", 14)
$MainTab = GUICtrlCreateTab(0, 30, 1024, 480)
GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP)
#region Tab_1
    $Tab_Item_1 = GUICtrlCreateTabItem("Buying Mode")
    
    #region TreeView
        $Label_1 = GUICtrlCreateLabel("SETS", 5, 60, 56, 12)
        GUICtrlSetResizing( -1, $GUI_DOCKALL )
        $TreeView_1 = GUICtrlCreateTreeView(5, 75, 185, 380, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE )
        GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH)
        
        #region Sets
            $b = 1
            While $b < 15
                $TreeView_1_Item_1[$b - 1] = GUICtrlCreateTreeViewItem($b, $TreeView_1)
                _GUICtrlTreeView_SetIcon($TreeView_1, $TreeView_1_Item_1[$b - 1], "shell32.dll", $B)
                $b = $b + 1
            WEnd
        #endregion
        
    #endregion treeview
    
    #region Button_1 and Button2
        $Button_Add_1 = GUICtrlCreateButton("Add >>", 196, 250, 75, 25)
        GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKSIZE)
        $Button_Delete_1 = GUICtrlCreateButton("<< Delete", 196, 280, 75, 25)
        GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKSIZE)
    #endregion
    
    #region ListView
        $Pre_ListView_1 = GUICtrlCreateListView( "N°", 275, 75, 610, 380, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS))
        GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP)
        $ListView_1 = GUICtrlGetHandle($Pre_ListView_1)
        GUICtrlSetResizing( -1, $GUI_DOCKLEFT + $GUI_DOCKTOP)
        _GUICtrlListView_SetExtendedListViewStyle($ListView_1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))
        _GUICtrlListView_SetColumnWidth($ListView_1, 0, $Number_Width)
        $hImage_1 = _GUIImageList_Create(16, 16, 5, 3)
        
        $b = 1
        While $b < 15
            _GUIImageList_AddIcon($hImage_1, "shell32.dll", $B)
            $b = $b + 1
        WEnd
        
        _GUICtrlListView_SetImageList($ListView_1, $hImage_1, 1)
        $ListView_Col_Set_1 = _GUICtrlListView_AddColumn($ListView_1, "Selected Sets", $Set_Width)
        $ListView_Col_Rarity_1 = _GUICtrlListView_AddColumn($ListView_1, "Rarity", $Rarity_Width)
        $ListView_Col_Version_1 = _GUICtrlListView_AddColumn($ListView_1, "Version", $Version_Width)
        $ListView_Col_Owned_1 = _GUICtrlListView_AddColumn($ListView_1, "Owned", $Owned_Width)
        $ListView_Col_ForTrade_1 = _GUICtrlListView_AddColumn($ListView_1, "For Trade", $ForTrade_Width)
        $ListView_Col_SortBy_1 = _GUICtrlListView_AddColumn($ListView_1, "Sort By", $SortBy_Width)
    #endregion ListView
    
    #region
        GUICtrlCreateLabel("HOLA", 225, 75, 56, 12, -1, $WS_EX_MDICHILD)
    #endregion
    
#endregion

#region ToolBar
    $hToolbar = _GUICtrlToolbar_Create($Main,BitOR($TBSTYLE_TOOLTIPS,$TBSTYLE_FLAT))
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
    _GUICtrlToolbar_AddButton($hToolbar, 1000, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, 1001, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, 1002, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, 1003, $STD_PROPERTIES)
#endregion

#region MenuBar
    $MenuItem_1 = GUICtrlCreateMenu("&File")
    $MenuItem_1_File_1 = GUICtrlCreateMenuItem("Open", $MenuItem_1)
    $MenuItem_2 = GUICtrlCreateMenu("&Option")
#endregion

GUICtrlSetState($Tab_Item_1,$GUI_SHOW)

GUISetState(@SW_SHOW, $Main)

While 1
    $msg = GUIGetMsg(1)
    Select
        Case $msg[0] = $GUI_EVENT_CLOSE
            
            If $msg[1] = $Main Then
                ExitLoop
            EndIf
            
        Case $msg[0] = $Button_Add_1
            
            $SearchItem_1 = 0
            While 1
                If _GUICtrlTreeView_GetSelected($TreeView_1, $TreeView_1_Item_1[$SearchItem_1]) = True Or $SearchItem_1 = $Limit Then
                    ExitLoop
                EndIf
                $SearchItem_1 = $SearchItem_1 + 1
            WEnd
            Dim $Info[5]
            For $i = 0 to 4
                $Info[$i] = 0
            Next
            If $SearchItem_1 = $Limit Then
                MsgBox(0, "Message", "You Can't Add More Sets")
            Else
                _GUICtrlListView_AddItem($ListView_1, _GUICtrlListView_GetItemCount($ListView_1) + 1, $SearchItem_1)
                _GUICtrlListView_AddSubItem($ListView_1, _GUICtrlListView_GetItemCount($ListView_1) - 1, _GUICtrlTreeView_GetText($TreeView_1, $TreeView_1_Item_1[$SearchItem_1]), 1)
                Create_ComboBoxes((-2 + (_GUICtrlListView_GetItemCount($ListView_1) * 17)), _GUICtrlListView_GetItemCount($ListView_1), $Info)
                GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_DISABLED), -1, $Main)
                MsgBox(4144, "Message", "Set Added Successfully")
                GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX), -1, $Main)
            EndIf
            
            GUICtrlSetPos($ComboBox_1[3][0], 230, 150)
            
        Case $msg[0] = $Button_Delete_1
            
            $SearchItem_1 = 0
            While 1
                If _GUICtrlListView_GetItemSelected($ListView_1, $SearchItem_1) = True or $SearchItem_1 = $Limit Then
                    ExitLoop
                EndIf
                $SearchItem_1 = $SearchItem_1 + 1
            WEnd
            If $SearchItem_1 = $Limit Then
                MsgBox(0, "Message", "You Haven't Choosed a Set to Delete")
            Else
                For $i = 0 To 4
                    _GUICtrlComboBox_Destroy($ComboBox_1[$SearchItem_1 + 1][$i])
                Next
                _GUICtrlListView_DeleteItem($ListView_1, $SearchItem_1)
                For $i = $SearchItem_1 To _GUICtrlListView_GetItemCount($ListView_1) - 1
                    _GUICtrlListView_SetItem($ListView_1, $i + 1, $i)
                    For $j = 0 To 4
                        $Info[$j] = _GUICtrlComboBox_GetCurSel($ComboBox_1[$i + 2][$j])
                        _GUICtrlComboBox_Destroy($ComboBox_1[$i + 2][$j])
                    Next
                    Create_ComboBoxes((-2 + (($i + 1) * 17)), $i + 1, $Info)
                Next
                GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_DISABLED), -1, $Main)
                MsgBox(4144, "Message", "Set Deleted")
                GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX), -1, $Main)
            EndIf
            
        Case $msg[0] = $ListView_1
            MsgBox(4144, "Message", "Lista")
            
    EndSelect

WEnd

Func Create_ComboBoxes_2($PosX, $PosY, $Section, $Index_1, $Index_2, $Width, $Information)
    
    $a = 1
    $Data = ""
    $ComboText = ""
    For $i = 1 to 5
        $Data = $i
        $ComboText = $ComboText & $Data & "|"
        $a = $a + 1
    Next
    $ComboBox_1[$Index_1][$Index_2] = _GUICtrlComboBox_Create($ListView_1, StringTrimRight($ComboText, 1), $PosX, $PosY, $Width, 10, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL, $WS_VSCROLL))
    If $Information = 0 Then
        _GUICtrlComboBox_SetCurSel($ComboBox_1[$Index_1][$Index_2], 0)
    Else
        _GUICtrlComboBox_SetCurSel($ComboBox_1[$Index_1][$Index_2], $Information)
    EndIf
    GUICtrlDelete($ComboBox_1[$Index_1][$Index_2])
    
EndFunc

Func Create_ComboBoxes($PosY, $Index_1, $Info)
    
    $PosX = $Number_Width + $Set_Width
    $PosX_[0] = $PosX
    Create_ComboBoxes_2($PosX, $PosY, "Rarity", $Index_1, 0, $Rarity_Width, $Info[0])
    
    $PosX = $PosX + $Rarity_Width
    $PosX_[1] = $PosX
    Create_ComboBoxes_2($PosX, $PosY, "Version", $Index_1, 1, $Version_Width, $Info[1])
    
    $PosX = $PosX + $Version_Width
    $PosX_[2] = $PosX
    Create_ComboBoxes_2($PosX, $PosY, "Owned", $Index_1, 2, $Owned_Width, $Info[2])
    
    $PosX = $PosX + $Owned_Width
    $PosX_[3] = $PosX
    Create_ComboBoxes_2($PosX, $PosY, "ForTrade", $Index_1, 3, $ForTrade_Width, $Info[3])
    
    $PosX = $PosX + $ForTrade_Width
    $PosX_[4] = $PosX
    Create_ComboBoxes_2($PosX, $PosY, "SortBy", $Index_1, 4, $SortBy_Width, $Info[4])
    
EndFunc

By the way, how can you change the position of X and Y in a combobox created with _GUICtrlComboBox_Create? I had to do it manually, maybe adding some innecessary code :)

Share this post


Link to post
Share on other sites
ProgAndy

This is how the code is now. But I am having problems to make ListView Cells bigger so the ComboBoxes do not overlap over the other, please try running my script and adding elements, you will understand me better.

you have to Set the ImageList on size 20x20 and Create the Boxes with 0+_GUIListView...()*21 Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
Omega

you have to Set the ImageList on size 20x20 and Create the Boxes with 0+_GUIListView...()*21

Lol, I completely forgot that adjusting the ImageList size could do the trick; that worked fine for me, but maybe it won't work for other people who don't use images, is there some other way to accomplish the same?

Sorry, I am not understanding the part in which I have to create the ComboBoxes with 0+_GUIListView...()*21.

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  

×