computergroove Posted January 25, 2018 Posted January 25, 2018 (edited) I've made a form in Koda where I make a list of 3 user definable elements that I want to be able to replicate with a button press so a user can add data that can be used as part of the program. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=D:\Carbonite Important\0 - Programing\Scite and Autoit\Koda 1.7.3.0\Forms\Mileage Estimator.kxf $Form1 = GUICreate("Save Project", 614, 1126, 298, 141) $Location = GUICtrlCreateInput("Location", 40, 112, 345, 21) $Distance = GUICtrlCreateInput("Distance", 400, 112, 89, 21) $AddLocation = GUICtrlCreateButton("AddLocation", 288, 80, 97, 25) $Label1 = GUICtrlCreateLabel("Location", 40, 88, 45, 17) $Label2 = GUICtrlCreateLabel("Distance", 400, 88, 46, 17) $HomeBase = GUICtrlCreateInput("HomeBase", 312, 32, 121, 21) $LeapYear = GUICtrlCreateCheckbox("LeapYear", 464, 32, 17, 17) $Label3 = GUICtrlCreateLabel("Leap Year?", 488, 32, 59, 17) $Variance = GUICtrlCreateInput("Variance", 504, 112, 81, 21) $Label4 = GUICtrlCreateLabel("Variance", 504, 88, 46, 17) $Label5 = GUICtrlCreateLabel("Home Base", 312, 8, 59, 17) $Button1 = GUICtrlCreateButton("Button1", 144, 56, 1, 57) $Save = GUICtrlCreateButton("Save Project", 40, 16, 121, 25) $Load = GUICtrlCreateButton("Load Project", 176, 16, 121, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Form1 Case $AddLocation EndSwitch WEnd I want to press the "add location" button and have the fields {Location, Distance and variance} create a new blank record located under the existing 3 input boxes. Since the fields can number over 30 locations in some examples I am thinking about having these items in a scrolling window. What is the best way to do this and can auto it add a variable while running by pressing a button? Edited January 25, 2018 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
Moonscarlet Posted January 25, 2018 Posted January 25, 2018 (edited) Hello, See my comments: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=D:\Carbonite Important\0 - Programing\Scite and Autoit\Koda 1.7.3.0\Forms\Mileage Estimator.kxf $Form1 = GUICreate("Save Project", 614, 1126, 298, 141) ;~ $Location = GUICtrlCreateInput("Location", 40, 112, 345, 21) ;COMMENTED HERE TO START ADDING USING THE "ADDLOCATION" BUTTON ;~ $Distance = GUICtrlCreateInput("Distance", 400, 112, 89, 21) ;COMMENTED HERE TO START ADDING USING THE "ADDLOCATION" BUTTON $AddLocation = GUICtrlCreateButton("AddLocation", 288, 80, 97, 25) $Label1 = GUICtrlCreateLabel("Location", 40, 88, 45, 17) $Label2 = GUICtrlCreateLabel("Distance", 400, 88, 46, 17) $HomeBase = GUICtrlCreateInput("HomeBase", 312, 32, 121, 21) $LeapYear = GUICtrlCreateCheckbox("LeapYear", 464, 32, 17, 17) $Label3 = GUICtrlCreateLabel("Leap Year?", 488, 32, 59, 17) ;~ $Variance = GUICtrlCreateInput("Variance", 504, 112, 81, 21) ;COMMENTED HERE TO START ADDING USING THE "ADDLOCATION" BUTTON $Label4 = GUICtrlCreateLabel("Variance", 504, 88, 46, 17) $Label5 = GUICtrlCreateLabel("Home Base", 312, 8, 59, 17) $Button1 = GUICtrlCreateButton("Button1", 144, 56, 1, 57) $Save = GUICtrlCreateButton("Save Project", 40, 16, 121, 25) $Load = GUICtrlCreateButton("Load Project", 176, 16, 121, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $AddLocationNextTop = 0 ;To increase "Top" value and move it below the previous row Global $AddLocationCounter = 0 ;counter for the array index below for controlids Global $NewLocation[30] ;Array to store the control ids change the limit if u want Global $NewDistance[30] ;Array to store the control ids change the limit if u want Global $NewVariance[30] ;Array to store the control ids change the limit if u want While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $AddLocation $NewLocation[$AddLocationCounter] = GUICtrlCreateInput("Location", 40, 112 + $AddLocationNextTop, 345, 21) ;STORE IN THE ARRAY WITH INDEX (COUNTER) WHICH INCREASES EVERYTIME U ADD A NEWONE $NewDistance[$AddLocationCounter] = GUICtrlCreateInput("Distance", 400, 112 + $AddLocationNextTop, 89, 21) ;STORE IN THE ARRAY WITH INDEX (COUNTER) WHICH INCREASES EVERYTIME U ADD A NEWONE $NewVariance[$AddLocationCounter] = GUICtrlCreateInput("Variance", 504, 112 + $AddLocationNextTop, 81, 21) ;STORE IN THE ARRAY WITH INDEX (COUNTER) WHICH INCREASES EVERYTIME U ADD A NEWONE $AddLocationNextTop = $AddLocationNextTop + 25 ;NEXT ROW $AddLocationCounter = $AddLocationCounter + 1 ;NEXT ARRAY INDEX Case $Save ;SAVE PROJECT BUTTON WILL SHOW THE VALUES JUST FOR TESTING For $i = 0 To $AddLocationCounter - 1 MsgBox(0, "", "Location " & $i & ": " & GUICtrlRead($NewLocation[$i]) & @CRLF & _ "Distance " & $i & ": " & GUICtrlRead($NewDistance[$i]) & @CRLF & _ "Variance " & $i & ": " & GUICtrlRead($NewVariance[$i]) & @CRLF) Next EndSwitch WEnd Edited January 25, 2018 by Moonscarlet
computergroove Posted January 25, 2018 Author Posted January 25, 2018 This is part of it. When I run what you made I get what I am looking for with the new elements but if I go over the length of the screen then the screen wont give me any way to scroll. Can this be done? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
Moonscarlet Posted January 25, 2018 Posted January 25, 2018 I think this should be done from the start for the window itself, see the style parameter, you should give it a scroll bar: https://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm
jdelaney Posted January 26, 2018 Posted January 26, 2018 (edited) It seems to me this can be much more easily maintained with a list view...you can have three initial inputs, and an 'add' button...on click of the add, add the data to the listview. There are then functions to save the whole thing to an array, which you can write to a file to 'save'...and on 'load', there is another function to read the file into an array, and load that into the list view. The list view will also auto add in the scrollbars as necessary. Check out the example for this one to see it: _GUICtrlListView_AddArray Edited January 26, 2018 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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