Jump to content

Recommended Posts

Posted

I have a form entry "Add customer" which I want to allow the ability to enter many customers until they Cancel or "X" out of screen.

After entering the first customer, I reset all form values to defaults and the form stays out front. However the old values

are still shown on the form. How do I do a refresh of the form with the new values?

Do I have to call each individual field with a specific GUICtrlSetData() or is it better practice to destroy the form and

call the CreateForm to init the values and re-create the form?

Any examples to look at?

Also, I need to understand how to update the Customer TAB with a ListView of customers entered.

Please point me in the right direction with an example.

  • Moderators
Posted

Garp99HasSpoken,

If you store the ControlIDs of the various inputs in an array, then clearing them is just a simple loop around a GUICtrlSetData line. :)

As to your second question, I assume you have a listview somewhere, so just add the content of the "customer name" input to the listview before you clear it. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

I agree that using an array is always simpler but not easier from an understanding of the code if you son't readily know what key 3 or 21 is.

Which means L_LABELS for each when needed. It's a different approach than having a variable for each field.

In the end I just decided to create a function to set all the values, so it could be re-used elsewhere.

Question about question etiquette on the forum:

Should I start a new thread for *each* problem I run into / need help with, so that others can find it via search, or

is it ok to just start a thread about my project and ask the problems as they occur, this way those that follow it will better

understand what I am working on and the problems I am running into -- in my first AutoIt GUI.

Posted

One method of making your array elements easier to reference is to use Enum with the names of the controls you want in each position.

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $msg
    Local Enum $Run, $ButtonTest
    Local $aHandles[2]
    GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered

    Opt("GUICoordMode", 2)
    $aHandles[$Run] = GUICtrlCreateButton("Run Notepad", 10, 30, 100)
    $aHandles[$ButtonTest] = GUICtrlCreateButton("Button Test", 0, -1)

    GUISetState() ; will display an  dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $aHandles[$Run]
                Run('notepad.exe') ; Will Run/Open Notepad
            Case $msg = $aHandles[$ButtonTest]
                MsgBox(4096, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed
        EndSelect
    WEnd
EndFunc

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 Gude
How 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

  • Moderators
Posted

Garp99HasSpoken,

I am not sure I agree with you there. You could always have the array as well as the normal variables - then you can use whichever is best suited to the requirement. And if you structure your code you might well be able to use a Local array and so not waste resources. Or you could use an "associative array" so that you can use descriptive names - my personal favourite is here. I use it often when I have controls that I need to reference within another function - just pass the whole array rather than a whole list of variables - and I can still use the descriptive names. An example: ;)

; Create checkboxes
AssocArrayAssign($aParam_List, "GUI", GUICtrlCreateCheckbox(" GUI visible", 10, 95))
AssocArrayAssign($aParam_List, "Status", GUICtrlCreateCheckbox(" Statusbar", 10, 125))
AssocArrayAssign($aParam_List, "Taskbar", GUICtrlCreateCheckbox(" Taskbar Button", 10, 155))
AssocArrayAssign($aParam_List, "Scroll", GUICtrlCreateCheckbox(" Details Scroll", 10, 185))
AssocArrayAssign($aParam_List, "Drop", GUICtrlCreateCheckbox(" Drop accept", 10, 215))

I would suggest opening a new thread for each problem, unless they are very closely related. People normally only read the first few posts unless they are already involved personally in the thread - so if you change tack once well into a thread you might not get the correct people reading about the new problem. So start a new thread, correctly titled, and attract those who know about that particular aspect of AutoIt. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...