solis Posted July 16, 2010 Share Posted July 16, 2010 Hi, can anybody help. I stopped at one point. If it possible, to create a different list in diferent TAB's ? Here's a code with TAB's, so I need that in different TAB, i see a different list. From that list i can choose one of the item. Thank you, I'm just a novice in AutoIt, so need a little help. #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TabConstants.au3> #Include <GuiListBox.au3> _main() Func _Main() Local $msg Local $MESSAGE = "The following buttons have been clicked" $GUI = GUICreate("TAB and ListView Create", 400, 400, -1, -1) GUISetState(@SW_SHOW) $TabWindow = GuiCtrlCreateTab(10, 10, 380, 380) $Tab1 = GuiCtrlCreateTabItem("1. TAB") $Tab2 = GuiCtrlCreateTabItem("2. TAB") $Tab3 = GuiCtrlCreateTabItem("3. TAB") GUICtrlCreateTabItem("") Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE EndFunc p.s. sorry for my english Link to comment Share on other sites More sharing options...
taietel Posted July 16, 2010 Share Posted July 16, 2010 (edited) Solis, yes, it is possible: #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TabConstants.au3> #Include <GuiListBox.au3> #include <ListViewConstants.au3> _main() Func _Main() Local $msg Local $MESSAGE = "The following buttons have been clicked" $GUI = GUICreate("TAB and ListView Create", 400, 400, -1, -1) Local $TabWindow = GuiCtrlCreateTab(10, 10, 380, 380) $Tab1 = GuiCtrlCreateTabItem("1. TAB") Local $LV1 = GUICtrlCreateListView("Name|ID", 20, 45, 360, 360, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) $LV1_0 = GUICtrlCreateListViewItem("John|123", $LV1) $LV1_1 = GUICtrlCreateListViewItem("Mary|456", $LV1) $Tab2 = GuiCtrlCreateTabItem("2. TAB") Local $LV2 = GUICtrlCreateListView("Fruit|Colour", 20, 45, 360, 360, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) $LV2_0 = GUICtrlCreateListViewItem("Orange|Orange", $LV2) $LV2_1 = GUICtrlCreateListViewItem("Lemon|Yellow", $LV2) $Tab3 = GuiCtrlCreateTabItem("3. TAB") GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE EndFunc P.S. My English is not so well either Edited July 16, 2010 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
solis Posted July 16, 2010 Author Share Posted July 16, 2010 Thanks for your reply, i try to understand, maybe it will help Link to comment Share on other sites More sharing options...
solis Posted July 17, 2010 Author Share Posted July 17, 2010 Thats OK, but i have another question. How to make the default selected item in every tab? And then, how to get correct ID, of which item is selected? I have no idea about that now. Here is a code, that i have now. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <Array.au3> #include <Excel.au3> #include <Date.au3> #include <GuiButton.au3> #include <TabConstants.au3> #Include <GuiListBox.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> __IfProcessExist() Opt("GUIOnEventMode", 1) Global $sUpper = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z " Global $sLower = "a b c d e f g h i j k l m n o p q r s t u v w x y z " Global $sNumbers = "0 1 2 3 4 5 6 7 8 9 " Global $bResultSwitch = False Global $sResult $winMain = GUICreate("S/N Generatorius", 1000, 680, -1, -1) $cbxUpper = GUICtrlCreateCheckbox("Didziosios raides", 8, 8, 113, 17) GUICtrlSetState(-1, $GUI_CHECKED) $cbxLower = GUICtrlCreateCheckbox("Mazosios raides", 8, 28, 113, 17) GUICtrlSetState(-1, $GUI_CHECKED) $cbxNumbers = GUICtrlCreateCheckbox("Skaiciai", 8, 48, 65, 17) GUICtrlSetState(-1, $GUI_CHECKED) $txtCount = GUICtrlCreateInput("6", 59, 80, 50, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL)) GUICtrlCreateLabel("Kodo ilgis:", 8, 83, 50, 17) GUISetState() GUICtrlCreateLabel("Sugeneruotas kodas:", 128, 43) $txtResult = GUICtrlCreateEdit("", 128, 58, 100, 20, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_HSCROLL)) GUICtrlCreateLabel("Paieska:", 128, 3) $search = GUICtrlCreateEdit("", 128, 18, 100, 20, BitOR($ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_HSCROLL)) GUICtrlCreateLabel("Aprasymas:", 650, 3) $description = GUICtrlCreateEdit("Aprasymas", 650, 18, 540, 650, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL, $ES_READONLY)) $rightButtonsToLeft = 240 $rightButtonsFromTop = 55 $btnGo = GUICtrlCreateButton("Generuoti", $rightButtonsToLeft, $rightButtonsFromTop, 100, 25, 0) GUICtrlSetState ($btnGO, $GUI_DISABLE) GUISetState() $savefile = GUICtrlCreateButton("Issaugoti koda", $rightButtonsToLeft -115, $rightButtonsFromTop + 30, 100, 25, 0) GUICtrlSetState ($savefile, $GUI_DISABLE) GUISetState() $btnCopy = GUICtrlCreateButton("Kopijuoti koda", $rightButtonsToLeft, $rightButtonsFromTop + 30, 100, 25, 0) $searchButton = GUICtrlCreateButton("Ieskoti", 240, 18, 100, 20, 0) $pasteButton = GUICtrlCreateButton("Iklijuoti", 340, 18, 100, 20, 0) Local $TabWindow = GuiCtrlCreateTab(10, 150, 630, 520) $TabA = GuiCtrlCreateTabItem("A.Product name") Local $LV1 = GUICtrlCreateListView("Description", 10, 170, 630, 500, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 900) $Start = __FindLine ("<product>") + 1 $End = __FindLine ("</product>") - 1 $HowItems = __CountReadableLines($Start, $End) dim $ListOfItems[50], $IDAndDescription[50] $u = 1 For $i = $Start To $End Step 1 $parameter2 = __ReadSettings ($i) $parameter = __ReadDescriptionOnly($parameter2) $ListOfItems[$u] = $parameter $Start = $Start + 1 $u = $u + 1 Next $Start = __FindLine ("<product>") + 1 $End = __FindLine ("</product>") - 1 $id = 1 $u = 1 For $i = $Start To $End Step 1 $IDAndDescription[$id] = GUICtrlCreateListViewItem( $ListOfItems[$u] , $LV1) $u = $u + 1 $Start = $Start + 1 $id = $id + 1 Next ;************************************************************************************************************************************ ; Here should something be, that it makes default first item, and gets correct ID of item what is choosed. $TabA = GuiCtrlCreateTabItem("B.Another TAB") Local $LV2 = GUICtrlCreateListView("Description", 10, 170, 630, 500, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 900) $Start = __FindLine ("<charger>") + 1 $End = __FindLine ("</charger>") - 1 $HowItems = __CountReadableLines($Start, $End) dim $ListOfItems[50], $IDAndDescription[50] $u = 1 For $i = $Start To $End Step 1 $parameter2 = __ReadSettings ($i) $parameter = __ReadDescriptionOnly($parameter2) $ListOfItems[$u] = $parameter $Start = $Start + 1 $u = $u + 1 Next $Start = __FindLine ("<charger>") + 1 $End = __FindLine ("</charger>") - 1 $id = 1 $u = 1 For $i = $Start To $End Step 1 $IDAndDescription[$id] = GUICtrlCreateListViewItem( $ListOfItems[$u] , $LV2) $u = $u + 1 $Start = $Start + 1 $id = $id + 1 Next ;************************************************************************************************************************************ ; Here should something be, that it makes default first item, and gets correct ID of item what is choosed. GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $winMain) _main() Func __ReadDescriptionOnly ($MyString) $ReturnStringPosition = StringInStr ($MyString, ";",0,1) $StringDescription = StringLeft($MyString, $ReturnStringPosition - 1) Return $StringDescription EndFunc Func __ReadSettings ($LineNo) $a = "settings.dat" $file = __OpenFileForReading ($a) $Parameter = FileReadLine($file, $LineNo) __CloseOpenedFile ($a) Return $Parameter EndFunc Func __OpenFileForReading ($fileName) $file = FileOpen($fileName, 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open "& $fileName &" file.") __CloseOpenedFile ($file) Exit EndIf Return $file EndFunc Func __CountReadableLines($StartString, $EndString) $readableLines = $EndString - $StartString + 1 Return $readableLines EndFunc Func __CloseOpenedFile ($fileName) FileClose($fileName) EndFunc Func __FindLine ($string) Local $line = 1 $file = __OpenFileForReading ("settings.dat") While 1 $Search_string = FileReadLine($file, $line) If $Search_string = $string Then ExitLoop $line = $line + 1 WEnd __CloseOpenedFile ($file) Return $line EndFunc Func __IfProcessExist() $list = ProcessList() Global $listnew[50] Local $f = 1 Local $u = 0 while 1 Sleep(10) if $u >= UBound($list) - 1 Then ExitLoop $listnew[$u] = $list[$f][0] $f = $f + 1 $u = $u + 1 WEnd $ProcessList = _ArrayToString($listnew, " ", 0, $list[0][0]) $thisProcess = @ScriptName $ProcessResult = StringRegExp($ProcessList, $thisProcess, 3) $ProcessResult = UBound($ProcessResult) If $ProcessResult >= 2 Then MsgBox(0, "Pranesimas", "Tokia programa jau yra paleista. ") Exit Endif EndFunc Func _Main() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc Func _Exit() Exit EndFunc And also there is a file name "settings.dat" in the same DIR. <product> Choose.....;AA 11111111111;A0 22222222222;A1 </product> <charger> Choose...;BB 1111111111;B0 2222222222;B1 3333333333;B2 4444444444;B3 </charger> Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 17, 2010 Moderators Share Posted July 17, 2010 (edited) solis, Welcome to the AutoIt forum. If you continue to ask here about every single thing you want to do, both you and we are going to get very frustrated very quickly. I suggest that you read the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) - this will help you enormously. You should also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading. I know you want to start coding NOW, but a little study will save you a lot of trouble later on, believe me. ; ---- Now to your 2 questions: How to make the default selected item in every tabUse _GUICtrlListView_SetItemSelected ($LV1, index) where index is the 0-based index of the item to select how to get correct ID, of which item is selectedUse _GUICtrlListView_GetSelectedIndices. Here is your script modified to show you how they both work. expandcollapse popup#include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TabConstants.au3> #include <GuiListBox.au3> #include <ListViewConstants.au3> _main() Func _Main() Local $msg Local $MESSAGE = "The following buttons have been clicked" $GUI = GUICreate("TAB and ListView Create", 400, 400, -1, -1) Local $TabWindow = GUICtrlCreateTab(10, 10, 380, 380) $Tab1 = GUICtrlCreateTabItem("1. TAB") Local $LV1 = GUICtrlCreateListView("Name|ID", 20, 45, 360, 340, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) $LV1_0 = GUICtrlCreateListViewItem("John|123", $LV1) $LV1_1 = GUICtrlCreateListViewItem("Mary|456", $LV1) _GUICtrlListView_SetItemSelected ($LV1, 1) ; Select item 1 - remember that it is 0-based so this is the second item <<<<<<<<<<<<<<< $Tab2 = GUICtrlCreateTabItem("2. TAB") Local $LV2 = GUICtrlCreateListView("Fruit|Colour", 20, 45, 360, 340, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) $LV2_0 = GUICtrlCreateListViewItem("Orange|Orange", $LV2) $LV2_1 = GUICtrlCreateListViewItem("Lemon|Yellow", $LV2) $Tab3 = GUICtrlCreateTabItem("3. TAB") GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) ; Wait 5 secs so you can see the selected item Sleep(5000) ; Now let us get the ControlID of the selected item in the ListView $iIndex = _GUICtrlListView_GetSelectedIndices($LV1, False) MsgBox(0, "Selected", "Item " & $iIndex) ; And we get the same index we selected earlier! Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>_Main All clear? M23 Edit: Typnig Edited July 17, 2010 by Melba23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
solis Posted July 18, 2010 Author Share Posted July 18, 2010 All clear! Thank you. But i have another problem. The function you said: $iIndex = _GUICtrlListView_GetSelectedIndices($LV1, False) gives back index, that's OK. But when i want to read, what is written on that index - i can't. I used this: _GUICtrlListView_GetItemText($LV1, $iIndex). Also i tried this: _GUICtrlListView_GetItemTextString, but it also didnt help. If you write instead of $iIndex a real number (1, 2, 3), than its ok, the text is given back. So, how to get text in this way, when you want to use index? Link to comment Share on other sites More sharing options...
solis Posted July 18, 2010 Author Share Posted July 18, 2010 Solved: Int($iIndex) - thats help. Link to comment Share on other sites More sharing options...
taietel Posted July 18, 2010 Share Posted July 18, 2010 (edited) When you try to read the text of the selected index, replace $iIndex with Int($iIndex), like this:_GUICtrlListView_GetItemText($LV1, Int($iIndex))[edit] You've find yourself the answer! Congrats!P.S. My internet connection sucks! Edited July 18, 2010 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now