Guest Posted October 1, 2012 Share Posted October 1, 2012 Hello, I wrote this GUI: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> $Form2 = GUICreate("Settings", 388, 377, 245, 195) $Tab1 = GUICtrlCreateTab(16, 8, 353, 289) $SearchL = GUICtrlCreateTabItem("List") $List1 = GUICtrlCreateList("", 20, 37, 201, 202) GUICtrlSetData(-1, "") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Radio1 = GUICtrlCreateRadio("a", 228, 61, 89, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Radio2 = GUICtrlCreateRadio("b", 228, 93, 81, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Radio3 = GUICtrlCreateRadio("", 332, 125, 17, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Add = GUICtrlCreateButton("Add >>", 28, 261, 81, 25) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $remove = GUICtrlCreateButton("remove", 228, 157, 81, 25) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Other = GUICtrlCreateInput("Other", 228, 125, 97, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Input1 = GUICtrlCreateInput("Input1", 120, 264, 137, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $TabSheet2 = GUICtrlCreateTabItem("List") GUICtrlCreateEdit("", 20, 37, 337, 249) GUICtrlSetData(-1, "Edit1") GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateTabItem("") $Save = GUICtrlCreateButton("Save", 48, 304, 137, 49) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $Exit = GUICtrlCreateButton("Exit", 200, 304, 137, 49) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Add GUICtrlSetData($List1, GUICtrlRead($Input1)) Case $remove Case $Exit Exit EndSwitch WEnd There's something I can not manage to do .. If I click on the button "ADD>" So it adds what I wrote .. But that's all I success to do .. If I click on the button "remove" then nothing happens .. I know why this happens. And that because I did not write anything under Case $ remove. And that because I do not know how to write it. Can anyone give me an example of that? Link to comment Share on other sites More sharing options...
BrewManNH Posted October 1, 2012 Share Posted October 1, 2012 What are you trying to remove with the button, the entire contents of the Listbox? if so, just use GUICtrlSetData($list1, "|"). This will clear the contents of the listbox. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
abberration Posted October 2, 2012 Share Posted October 2, 2012 If you use _GUICtrlListBox_Create instead of GUICtrlCreateList, you will have a lot more options. In the help file, look under the index tab for _GUICtrlListBox_Create and you will see about 50 options related to it. I modified your script to utilize the more advanced list box. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $Form2 = GUICreate("Settings", 388, 377, 245, 195) $Tab1 = GUICtrlCreateTab(16, 8, 353, 289) $SearchL = GUICtrlCreateTabItem("List") $List1 = _GUICtrlListBox_Create($Form2, "", 20, 37, 201, 202) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Radio1 = GUICtrlCreateRadio("a", 228, 61, 89, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Radio2 = GUICtrlCreateRadio("b", 228, 93, 81, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Radio3 = GUICtrlCreateRadio("", 332, 125, 17, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Add = GUICtrlCreateButton("Add >>", 28, 261, 81, 25) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $remove = GUICtrlCreateButton("remove", 228, 157, 81, 25) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Other = GUICtrlCreateInput("Other", 228, 125, 97, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Input1 = GUICtrlCreateInput("Input1", 120, 264, 137, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $TabSheet2 = GUICtrlCreateTabItem("List") GUICtrlCreateEdit("", 20, 37, 337, 249) GUICtrlSetData(-1, "Edit1") GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateTabItem("") $Save = GUICtrlCreateButton("Save", 48, 304, 137, 49) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $Exit = GUICtrlCreateButton("Exit", 200, 304, 137, 49) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Add _GUICtrlListBox_AddString($List1, GUICtrlRead($Input1)) Case $remove $itemPos = _GUICtrlListBox_GetCurSel($List1) _GUICtrlListBox_DeleteString($List1, $itemPos) Case $Exit Exit EndSwitch WEnd Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
BrewManNH Posted October 2, 2012 Share Posted October 2, 2012 abberration You can use GUICtrlCreateList with your script and it will accomplish the same thing, just an FYI. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
abberration Posted October 2, 2012 Share Posted October 2, 2012 abberrationYou can use GUICtrlCreateList with your script and it will accomplish the same thing, just an FYI.I assumed they were different. Kind of how FileWrite is different from _FileWriteToLine. I will have to look into it further.Thanks, BrewManNH! Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
Guest Posted October 3, 2012 Share Posted October 3, 2012 If you use _GUICtrlListBox_Create instead of GUICtrlCreateList, you will have a lot more options. In the help file, look under the index tab for _GUICtrlListBox_Create and you will see about 50 options related to it. I modified your script to utilize the more advanced list box. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $Form2 = GUICreate("Settings", 388, 377, 245, 195) $Tab1 = GUICtrlCreateTab(16, 8, 353, 289) $SearchL = GUICtrlCreateTabItem("List") $List1 = _GUICtrlListBox_Create($Form2, "", 20, 37, 201, 202) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Radio1 = GUICtrlCreateRadio("a", 228, 61, 89, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Radio2 = GUICtrlCreateRadio("b", 228, 93, 81, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Radio3 = GUICtrlCreateRadio("", 332, 125, 17, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Add = GUICtrlCreateButton("Add >>", 28, 261, 81, 25) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $remove = GUICtrlCreateButton("remove", 228, 157, 81, 25) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Other = GUICtrlCreateInput("Other", 228, 125, 97, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Input1 = GUICtrlCreateInput("Input1", 120, 264, 137, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $TabSheet2 = GUICtrlCreateTabItem("List") GUICtrlCreateEdit("", 20, 37, 337, 249) GUICtrlSetData(-1, "Edit1") GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateTabItem("") $Save = GUICtrlCreateButton("Save", 48, 304, 137, 49) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $Exit = GUICtrlCreateButton("Exit", 200, 304, 137, 49) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Add _GUICtrlListBox_AddString($List1, GUICtrlRead($Input1)) Case $remove $itemPos = _GUICtrlListBox_GetCurSel($List1) _GUICtrlListBox_DeleteString($List1, $itemPos) Case $Exit Exit EndSwitch WEnd Thank you very much! Only one thing - I need that $Radio1, $Radio2, $Radio3 will be related to each line in the ListBox.. I do not know how to explain it in English but it's something familiar, you probably know what I mean .. 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