Jump to content

Next Button In A GUI


myxomatosii
 Share

Recommended Posts

Hey guys, if you'd like to help me, run this script and watch what it does, I want to make the next button take me to another GUI which I am about to create after I post this subject.. just not sure the best way to do the transition. No need for code, just advice and I can figure out the code myself, thanks!

Code and code examples are of course welcome, but mostly I need concepts :)

Also is having a long line like that for variable declaration normal? Is there a more efficient way of doing that? Actually if I'm doing anything inefficiently please point it out :)

dim $nl, $nl2, $nl3, $nl4, $nl5,$nl6, $info1, $info2, $info3, $info4,$info5,$info6
Func cityinput()
    GuiCreate("Ikariam City ID's.", 350, 200)
    GuiSetState(@SW_Show)
    GuiCtrlCreateLabel("Input City1 ID Here",20,10)
    $info1=GUICtrlCreateInput($nl,20,30,100,20)
    GuiCtrlCreateLabel("Input City2 ID Here",20,60)
    $info2=GUICtrlCreateInput($nl2,20,80,100,20)
    GuiCtrlCreateLabel("Input City3 ID Here",125,10)
    $info3=GuiCtrlCreateInput($nl3,125,30,100,20)
    GUICtrlCreateLabel("Input City4 ID Here",125,60)
    $info4=GuiCtrlCreateInput($nl4,125,80,100,20)
    GuiCtrlCreateLabel("Input City5 ID Here",230,10)
    $info5=GuiCtrlCreateInput($nl5,230,30)
    GuiCtrlCreateLabel("Input City6 ID Here",230,60)
    $info6=GUICtrlCreateInput($nl6,230,80)
    
    $button1=GuiCtrlCreateButton("Next", 280,170,60,20)
    While 1
        Local $msg=GUIGetMsg()
        Select
            Case $msg=$button1
                ExitLoop
        EndSelect       
    WEnd            
;MsgBox(0,"test",GuiCtrlRead($info1) & GuiCtrlRead($info2) & GUICtrlRead($info3) & GuiCtrlRead($info4),0)
EndFunc

cityinput()
Edited by myxomatosii
Link to comment
Share on other sites

  • Moderators

myxomatosii,

2 of the many ways you could proceed from one GUI to the next:

1. Delete the current GUI and call a different function to create a new one to do what ever you want to do next.

2. Create both GUIs initially and then use GUISetState with @SW_SHOW/@SW_HIDE to display the one you want. You might find this works better if you change your code to have a main section which calls the different functions related to the GUIs - if you keep linking directly from function to function as you proceed through your code you can end up too deeply buried and find it difficult to get back to a previous section without a lot of effort.

Of course, there are pros and cons for either method. For example, [1] is easy on resources as you destroy things you are not using, but could take a bit of time to draw if the GUIs are complicated. [2] is better if you think you might reuse a GUI at a later time in your script. And of course lots of other reasons why one might be better than the other for any given script.

Nothing to stop you using a mix of both - I tend to create any GUIs that I will use often at the start and then SHOW/HIDE them, while I create infrequent dialogs as they are needed.

As to the Dim statement - do NOT use Dim to declare variables! In my opinion it is much better practise to use Global or Local to make clear what scope you intend - I know Autoit will automatically set the scope depending on where you are in the script, but if you take the trouble to declare the variables, you might as well make the scope clear as you do it. The Dim/ReDim declarations for arrays are different - Dim empties existing elements, ReDim leaves them intact - as I am sure you know. But even here I would just reuse the initial declaration type rather than use Dim.

From SmOke_N (a Mod) - "I personally declare all variables in functions "Local" and all of them in the body as "Global". You won't find the word "Dim" in any of my AutoIt Scripts other than "ReDim" which works on both Local and Global anyway."

And Valik (a Dev) - "The safest is to just not use Dim. And that's doubly true if you're already using Global in some places. Consistency is also important and haphazardly using Global and Dim to mean the same thing is just needlessly confusing when you could use Global and be explicit all the time. I wish I could remove Dim from the language."

So you can see I am not alone!

Good luck with the script. Ask again if you need more concepts - it is a change from debugging code!

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

 

Link to comment
Share on other sites

hehe, i was already having trouble with dim before i came back and read this, my current code is...

i spaced it out a bit to make it easier to read

Func cityinput()
Local $a,$a1,$a2,$a3,$a4,$a5,$ci0,$ci1,$ci2,$ci3,$ci4,$ci5
    GuiCreate("Ikariam City ID's.", 350, 200)
    GuiSetState(@sw_show)

    GuiCtrlCreateLabel("Input City1 ID Here",20,10)
    $ci0=GUICtrlCreateInput($a,20,30,100,20)

    GuiCtrlCreateLabel("Input City2 ID Here",20,60)
    $ci1=GUICtrlCreateInput($a1,20,80,100,20)

    GuiCtrlCreateLabel("Input City3 ID Here",125,10)
    $ci2=GuiCtrlCreateInput($a2,125,30,100,20)

    GUICtrlCreateLabel("Input City4 ID Here",125,60)
    $ci3=GuiCtrlCreateInput($a3,125,80,100,20)

    GuiCtrlCreateLabel("Input City5 ID Here",230,10)
    $ci4=GuiCtrlCreateInput($a4,230,30)

    GuiCtrlCreateLabel("Input City6 ID Here",230,60)
    $ci5=GUICtrlCreateInput($a5,230,80) 

    $button1=GuiCtrlCreateButton("Next", 270,165,60,20)

    GuiCtrlCreateLabel("The city id can be found by right clicking on Show Town",25,110)
    GuiCtrlCreateLabel("and clicking Properties, city by city.",25,125)
    While 1
        Local $msg=GUIGetMsg()
        Select
            Case $msg=$button1
                ExitLoop
        EndSelect       
    WEnd
EndFunc

.. as far as the things "you are sure that i know", i hope you were just being flattering because really, i am merely a student of everyone here. never think you are talking down to me, if you tell me something i already know, thats fine :) i will not take it as an insult.

i mostly learn from reading the documentation and ask here when i have a question that may require dialogue.

anyway, to your post. as far as option[1] you mean just writing a separate function for each GUI element and ExitLoop'ing at the end of the function (what you mean by destroying?) then just creating the new GUI by calling the new function i am writing now? as to the "taking time to draw" i highly doubt it as i only wrote my first GUI yesterday so i don't think they will be complicated like some of the stuff i have seen here, so maybe its the best option

as far as option[2], do you mean to write both GUI's into the same function and just toggle between @sw_show and @sw_hide? interesting, if all my windows are as simple as the one in my original post though, would it really make a difference?

-"if you keep linking directly from function to function as you proceed through your code you can end up too deeply buried and find it difficult to get back to a previous section without a lot of effort. "

this is a con for [2] right? making it hard to keep track of what is being hidden/shown?

between [2] and [1] i think i will go with [2] since that seems to be what i want to do, for my purposes the GUI will always be up at any given time and options will merely be shifted to contort the scripts actions, the dot boxes, i think they are called radios? that is my current plan..

i apologize for my need to type out my understanding of what you are telling me to make sure i am understanding you, i am not fluent in tongue as many/most here..

Edited by myxomatosii
Link to comment
Share on other sites

  • Moderators

myxomatosii,

Your English is fine.

A little explanation of what I meant by "main section which calls the different functions" - it is fundamental to how you structure your script.

Most scripts have a main section, which often does little but call functions to do whatever the main section wants. An example in pseudo-code:

Create main GUI
Create lots of controls on the GUI
Show main GUI

While...WEnd loop

Function 1 - called by one of the controls

Function 2 - called by another of the controls

etc, etc....

So you return to the While...WEnd loop at the end of each function and can then easily move to a different function. This is true of both OnEvent and MessageLoop modes (look in the Help file under "GUI Reference" for the difference between these modes). This way you can write a nice structured script which is easy to follow - and allows you to easily insert functions that you "borrow" from elsewhere. There are ways to interrupt this flow, like Adlib, but let us leave them until later!

Now you might have some initialisation to do - I suspect that your ID collection GUI might be something like that - the code for which will not be used again. In this case, you might want to code this as a separate section of the main script before creating the main GUI. If so, you can delete the associated GUI with GUIDelete once you have finished with it and then move on to the main GUI creation.

Of course, there are scripts which do not need this constant return to a main loop. They are just strings of events which follow one another. However, I would venture that a script of any complexity would find it difficult to do that.

Like so much in life, programming is much easier if it is structured. I strongly recommend trying to create a logic flow diagram before you get too far in any coding. Such a diagram forces you to think about what it is you need to do, in what order, and how the various elements must interact. Such a diagram usually makes the overall structure of the script pretty easy to determine. It does not have to be too detailed, but needs to set out what it is you want to achieve. Starting to code without a clear idea of what the end result should do usually ends up with messy and very inefficient code.

This is one of the most difficult things to teach - everyone has their own ideas on how to structure a script - and most are perfectly acceptable. There is no "right" answer, although there are many, many "wrong" ones!

Why not have a go at developing a logic flow diagram for your project. I know it is less fun than coding, but believe me it is worth the effort in the long term. Then we could look at how you might structure your script.

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

 

Link to comment
Share on other sites

Sorry for how large this example is, I mostly pulled it from AAMP. It used arrays to hold controls and display them dynamically. Hope you can make sense of it. If not just tell me here, and ill comment it :P

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>

Global $frame[6][6]
Global $step = 1
Global $steps_min = 1
Global $steps_max = 5
Global $count
Global $scount
Global Const $AAMP_FILETYPES = "MP3|MP2|MP1|OGG|WAV|AIFF|MO3|IT|XM|S3M|MTM|MOD|UMX|MPG|MPEG|WMV|AVI|WMA|WAV"
Global Const $AAMP_MEDIA_FILETYPES = "Supported Media Files (*.mp3;*.mp2;*.mp1;*.ogg;*.wav;*.aiff;*.xm;*.it;*.s3m;*.mod;*.mtm;*.umx;*.flac)" & _
        "|MPEG Audio (*.mp3;*.mp2;*.mp1)|OGG Files (*.ogg)|WAV Files (*.wav)|AIFF Files (*.aiff)|XM Files (*.xm)" & _
        "|IT Files (*.it)|S3M Files (*.s3m)|MOD Files (*.mod)|UMX Files (*.umx)|FLAC Files (*.flac)|All Files (*.*)"

$Form1 = GUICreate("AAMP Library Wizard", 641, 481, 382, 192)
$Button1 = GUICtrlCreateButton("Previous", 392, 448, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Cancel", 472, 448, 75, 25, 0)
$Button3 = GUICtrlCreateButton("Next", 552, 448, 75, 25, 0)
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\Administrator\My Documents\AutoIt Software\Signa5\AAMP\Source\Images\Header.jpg", 0, 0, 640, 100, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
$Pic2 = GUICtrlCreatePic("C:\Documents and Settings\Administrator\My Documents\AutoIt Software\Signa5\AAMP\Source\Images\Footer.jpg", 0, 430, 640, 50, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("Library Wizard Title", 8, 16, 620, 41, $SS_RIGHT)
GUICtrlSetFont(-1, 24, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Label2 = GUICtrlCreateLabel("Subtitle", 8, 56, 615, 25, $SS_RIGHT)
GUICtrlSetFont(-1, 16, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
;Start creating frames
$offset_x = 8
$offset_y = 109
;Frame 1
$frame[1][0] = 1
$frame[1][1] = GUICtrlCreateLabel("Welcome Blah Blah Blah...", $offset_x, $offset_y, 625, 321)
;Frame 2
$frame[2][1] = GUICtrlCreateLabel("Please select the files you wish to associate with AAMP.", $offset_x + 8, $offset_y + 8, 268, 17)
$frame[2][2] = GUICtrlCreateGroup("", $offset_x + 8, $offset_y + 32, 609, 257)
$frame[2][3] = GUICtrlCreateButton("Select All", $offset_x + 539, $offset_y + 293, 80)
$frame[2][4] = GUICtrlCreateButton("Deselect All", $offset_x + 449, $offset_y + 293, 80)
$filetypes = StringSplit($AAMP_FILETYPES, "|")

$frame[2][0] = $filetypes[0] + 4
ConsoleWrite("Creating " & $filetypes[0] & " filetypes." & @CRLF)
ReDim $frame[$steps_max + 1][$filetypes[0] + 5]

$y = 48
$x = 16

$count = 4
For $i = 1 To $filetypes[0]
    $count += 1
    $frame[2][$count] = GUICtrlCreateCheckbox($filetypes[$i], $offset_x + $x, $offset_y + $y, 190, 17)
    ConsoleWrite("Created filetype: " & $filetypes[$i] & @CRLF)
    $y += 24
    If $y >= 256 Then
        $x += 196
        $y = 48
    EndIf
Next

;Frame 3
$frame[3][0] = 5
$frame[3][1] = GUICtrlCreateLabel("Please select any files and folders you wish to add to your library.", $offset_x + 8, $offset_y + 8, 610, 17)
$frame[3][2] = GUICtrlCreateList("", $offset_x + 8, $offset_y + 32, 609, 257)
$frame[3][3] = GUICtrlCreateButton("Add File", $offset_x + 539, $offset_y + 293, 80)
$frame[3][4] = GUICtrlCreateButton("Add Folder", $offset_x + 449, $offset_y + 293, 80)
$frame[3][5] = GUICtrlCreateButton("Delete", $offset_x + 359, $offset_y + 293, 80)

;Frame 4
$frame[4][0] = 5
$frame[4][1] = GUICtrlCreateLabel("Please wait while settings are applied, and media is added to your library.", $offset_x + 8, $offset_y + 8, 615, 17)
$frame[4][2] = GUICtrlCreateLabel("Total", $offset_x + 8, $offset_y + 30, 615, 17)
$frame[4][3] = GUICtrlCreateProgress($offset_x + 8, $offset_y + 48, 608, 17)
$frame[4][4] = GUICtrlCreateLabel("Applying File Associations", $offset_x + 8, $offset_y + 68, 615, 17)

;Frame 5
$frame[5][0] = 1
$frame[5][1] = GUICtrlCreateLabel("Process is complete.  You may now continue to use AAMP.", $offset_x + 8, $offset_y + 8, 615, 17)
_ShowScreen($step)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            Exit
        Case $Button1
            $step -= 1
            _ShowScreen($step)
        Case $Button3
            $step += 1
            _ShowScreen($step)
            If $step = 4 Then
                $cos = 0
                $list_total = _GUICtrlListBox_GetCount($frame[3][2])
                $total = $filetypes[0] + $list_total
                GUICtrlSetData($frame[4][4], "Applying File Associations...")
                For $i = 5 To $frame[2][0]
                    $cos += 1
                    GUICtrlSetData($frame[4][3], Int(($cos / $total) * 100))
                    If BitAND(GUICtrlRead($frame[2][$i]), $GUI_CHECKED) Then
                    ;   FileAssoc($filetypes[$i - 4])
                    EndIf
                Next
                GUICtrlSetData($frame[4][4], "Adding Files to Library...")
                For $i = 0 To $list_total
                    $cos += 1
                    GUICtrlSetData($frame[4][3], Int(($cos / $total) * 100))
                ;$arr = GetMediaInfo(_GUICtrlListBox_GetText($frame[3][2], $i))
                ;If $arr <> -1 Then
                ;_AMMP_Library_AddSong($arr)
                    GUICtrlSetData($frame[4][4], "Adding Files to Library... (" & $i & " of " & $list_total & ")")
                ;EndIf
                Next
                $step += 1
                _ShowScreen($step)
            ElseIf $step = $steps_max Then
                ExitLoop
            EndIf
        Case $frame[2][3]
            For $i = 5 To $frame[2][0]
                GUICtrlSetState($frame[2][$i], $GUI_CHECKED)
            Next
        Case $frame[2][4]
            For $i = 5 To $frame[2][0]
                GUICtrlSetState($frame[2][$i], $GUI_UNCHECKED)
            Next
        Case $frame[3][3]
            _GUICtrlListBox_BeginUpdate($frame[3][2])
            $aFile = _WinAPI_GetOpenFileName("Add Files", $AAMP_MEDIA_FILETYPES, ".", @ScriptName, "", 1, BitOR($OFN_ALLOWMULTISELECT, $OFN_EXPLORER), 0, $Form1)
            If $aFile[0] = 0 Then
                $sError = _WinAPI_CommDlgExtendedError()
                ConsoleWrite("CommDlgExtendedError (" & @error & "): " & $sError & @CRLF)
            Else
                For $x = 2 To $aFile[0]
                    _GUICtrlListBox_AddString($frame[3][2], $aFile[1] & $aFile[$x])
                Next
            EndIf
            _GUICtrlListBox_EndUpdate($frame[3][2])
        Case $frame[3][4]
            _GUICtrlListBox_BeginUpdate($frame[3][2])
            $folder = FileSelectFolder("Select a folder", "")
            If $folder <> "" Then
            ;$files2 = FindMediaFiles($folder)
            ;For $x = 1 To $files2[0]
            ;   _GUICtrlListBox_AddString($frame[3][2], $files2[$x])
            ;Next
            EndIf
            _GUICtrlListBox_EndUpdate($frame[3][2])
        Case $frame[3][5]
            _GUICtrlListBox_BeginUpdate($frame[3][2])
            _GUICtrlListBox_DeleteString($frame[3][2], _GUICtrlListBox_GetCurSel($frame[3][2]))
            _GUICtrlListBox_EndUpdate($frame[3][2])
    EndSwitch
WEnd
GUIDelete($Form1)

Func _ShowScreen(ByRef $screen)
    If $steps_min > $screen Then
        $screen = $steps_min
    EndIf
    If $steps_max < $screen Then
        $screen = $steps_max
    EndIf
    For $x = 0 To UBound($frame) - 1
        For $i = 1 To $frame[$x][0]
            ConsoleWrite("Setting $frame[" & $x & "][" & $i & "]" & @CRLF)
            GUICtrlSetState($frame[$x][$i], $GUI_HIDE)
        Next
    Next
    For $i = 0 To $frame[$step][0]
        GUICtrlSetState($frame[$screen][$i], $GUI_SHOW)
    Next
EndFunc  ;==>_ShowScreen
Link to comment
Share on other sites

Here's a simplified example with comments.

;Include files
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>

;Create array
Global $frame[6][6]
;current step
Global $step = 1
;min steps
Global $steps_min = 1
;last step
Global $steps_max = 6

;Main GUI
$Form1 = GUICreate("AAMP Library Wizard", 640, 480, 382, 192)
$Button1 = GUICtrlCreateButton("Previous", 392, 448, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Cancel", 472, 448, 75, 25, 0)
$Button3 = GUICtrlCreateButton("Next", 552, 448, 75, 25, 0)
$Pic1 = GUICtrlCreateLabel("", 0, 0, 640, 100)
GUICtrlSetBkColor (-1, 0x5555FF)
$Pic2 = GUICtrlCreatePic("", 0, 430, 640, 50)
GUICtrlSetBkColor (-1, 0x5555FF)
;Create title, set font etc
$Label1 = GUICtrlCreateLabel("Library Wizard Title", 8, 16, 620, 41, $SS_RIGHT)
GUICtrlSetFont(-1, 24, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
;create subtitle, set font etc
$Label2 = GUICtrlCreateLabel("Subtitle", 8, 56, 615, 25, $SS_RIGHT)
GUICtrlSetFont(-1, 16, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

;Start creating frames
;These are offsets.  Totally optional
$offset_x = 8
$offset_y = 109


;Frame 1
$frame[1][0] = 1;Total controls
;Controls
$frame[1][1] = GUICtrlCreateLabel("Welcome Blah Blah Blah...", $offset_x, $offset_y, 625, 321)

;Frame 2
$frame[2][0] = 2;Total controls
;controls
$frame[2][1] = GUICtrlCreateLabel("Please select the files you wish to associate with AAMP.", $offset_x + 8, $offset_y + 8, 268, 17)
$frame[2][2] = GUICtrlCreateGroup("", $offset_x + 8, $offset_y + 32, 609, 257)

;Frame 3
$frame[3][0] = 3;Total controls
;Controls
$frame[3][1] = GUICtrlCreateLabel("Please select any files and folders you wish to add to your library.", $offset_x + 8, $offset_y + 8, 610, 17)
$frame[3][2] = GUICtrlCreateList("", $offset_x + 8, $offset_y + 32, 609, 257)
$frame[3][3] = GUICtrlCreateButton("Add File", $offset_x + 539, $offset_y + 293, 80)

;Frame 4
$frame[4][0] = 5;Total controls
;Controls
$frame[4][1] = GUICtrlCreateLabel("Please wait while settings are applied, and media is added to your library.", $offset_x + 8, $offset_y + 8, 615, 17)
$frame[4][2] = GUICtrlCreateLabel("Total", $offset_x + 8, $offset_y + 30, 615, 17)
$frame[4][3] = GUICtrlCreateProgress($offset_x + 8, $offset_y + 48, 608, 17)
$frame[4][4] = GUICtrlCreateLabel("Applying File Associations", $offset_x + 8, $offset_y + 68, 615, 17)

;Frame 5
$frame[5][0] = 1;Total controls
;Controls
$frame[5][1] = GUICtrlCreateLabel("Process is complete.  You may now continue to use AAMP.", $offset_x + 8, $offset_y + 8, 615, 17)

;Show step 1
_ShowScreen($step)

;Show the GUI
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE; Close, exit
            Exit
        Case $Button2; Cancel, exit
            Exit
        Case $Button1; Previous, go back a step
            $step -= 1
            _ShowScreen($step)
        Case $Button3; next, go foward a step.  It is here we can do actions, like i have on step 4-5.
            $step += 1
            If $step = $steps_max Then
                Exit
            ElseIf $step = 4 Then
                For $i = 1 to 100 Step 2
                    GUICtrlSetData ($frame[4][3], $i)
                    Sleep (100)
                Next
            EndIf
            _ShowScreen($step)
        Case $frame[3][3];A control
            MsgBox (0, "", "CLICKED!")
    EndSwitch
WEnd
;Delte GUI
GUIDelete($Form1)

;Function for showing the screen
Func _ShowScreen(ByRef $screen)
;Check the step is in range
    If $steps_min > $screen Then
        $screen = $steps_min
    EndIf
    If $steps_max < $screen Then
        $screen = $steps_max
    EndIf
;Hide all controls
    For $x = 0 To UBound($frame) - 1
        For $i = 1 To $frame[$x][0]
            ConsoleWrite("Setting $frame[" & $x & "][" & $i & "]" & @CRLF)
            GUICtrlSetState($frame[$x][$i], $GUI_HIDE)
        Next
    Next
;Show the ones we want
    For $i = 0 To $frame[$step][0]
        GUICtrlSetState($frame[$screen][$i], $GUI_SHOW)
    Next
EndFunc  ;==>_ShowScreen

Cheers,

Brett

Link to comment
Share on other sites

  • 12 years later...
  • Moderators

Fadi,

Did you notice that the post above yours is from 12 years ago? And BrettF is a very infrequent visitor these days. Please do not necro-post like this - just start a new thread and  include a link to the old one if necessary.

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

 

Link to comment
Share on other sites

  • 2 months later...

 

On 2/28/2009 at 7:49 AM, BrettF said:

Here's a simplified example with comments.

 

 

;Include files
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>

;Create array
Global $frame[6][6]
;current step
Global $step = 1
;min steps
Global $steps_min = 1
;last step
Global $steps_max = 6

;Main GUI
$Form1 = GUICreate("AAMP Library Wizard", 640, 480, 382, 192)
$Button1 = GUICtrlCreateButton("Previous", 392, 448, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Cancel", 472, 448, 75, 25, 0)
$Button3 = GUICtrlCreateButton("Next", 552, 448, 75, 25, 0)
$Pic1 = GUICtrlCreateLabel("", 0, 0, 640, 100)
GUICtrlSetBkColor (-1, 0x5555FF)
$Pic2 = GUICtrlCreatePic("", 0, 430, 640, 50)
GUICtrlSetBkColor (-1, 0x5555FF)
;Create title, set font etc
$Label1 = GUICtrlCreateLabel("Library Wizard Title", 8, 16, 620, 41, $SS_RIGHT)
GUICtrlSetFont(-1, 24, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
;create subtitle, set font etc
$Label2 = GUICtrlCreateLabel("Subtitle", 8, 56, 615, 25, $SS_RIGHT)
GUICtrlSetFont(-1, 16, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

;Start creating frames
;These are offsets.  Totally optional
$offset_x = 8
$offset_y = 109


;Frame 1
$frame[1][0] = 1;Total controls
;Controls
$frame[1][1] = GUICtrlCreateLabel("Welcome Blah Blah Blah...", $offset_x, $offset_y, 625, 321)

;Frame 2
$frame[2][0] = 2;Total controls
;controls
$frame[2][1] = GUICtrlCreateLabel("Please select the files you wish to associate with AAMP.", $offset_x + 8, $offset_y + 8, 268, 17)
$frame[2][2] = GUICtrlCreateGroup("", $offset_x + 8, $offset_y + 32, 609, 257)

;Frame 3
$frame[3][0] = 3;Total controls
;Controls
$frame[3][1] = GUICtrlCreateLabel("Please select any files and folders you wish to add to your library.", $offset_x + 8, $offset_y + 8, 610, 17)
$frame[3][2] = GUICtrlCreateList("", $offset_x + 8, $offset_y + 32, 609, 257)
$frame[3][3] = GUICtrlCreateButton("Add File", $offset_x + 539, $offset_y + 293, 80)

;Frame 4
$frame[4][0] = 5;Total controls
;Controls
$frame[4][1] = GUICtrlCreateLabel("Please wait while settings are applied, and media is added to your library.", $offset_x + 8, $offset_y + 8, 615, 17)
$frame[4][2] = GUICtrlCreateLabel("Total", $offset_x + 8, $offset_y + 30, 615, 17)
$frame[4][3] = GUICtrlCreateProgress($offset_x + 8, $offset_y + 48, 608, 17)
$frame[4][4] = GUICtrlCreateLabel("Applying File Associations", $offset_x + 8, $offset_y + 68, 615, 17)

;Frame 5
$frame[5][0] = 1;Total controls
;Controls
$frame[5][1] = GUICtrlCreateLabel("Process is complete.  You may now continue to use AAMP.", $offset_x + 8, $offset_y + 8, 615, 17)

;Show step 1
_ShowScreen($step)

;Show the GUI
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE; Close, exit
            Exit
        Case $Button2; Cancel, exit
            Exit
        Case $Button1; Previous, go back a step
            $step -= 1
            _ShowScreen($step)
        Case $Button3; next, go foward a step.  It is here we can do actions, like i have on step 4-5.
            $step += 1
            If $step = $steps_max Then
                Exit
            ElseIf $step = 4 Then
                For $i = 1 to 100 Step 2
                    GUICtrlSetData ($frame[4][3], $i)
                    Sleep (100)
                Next
            EndIf
            _ShowScreen($step)
        Case $frame[3][3];A control
            MsgBox (0, "", "CLICKED!")
    EndSwitch
WEnd
;Delte GUI
GUIDelete($Form1)

;Function for showing the screen
Func _ShowScreen(ByRef $screen)
;Check the step is in range
    If $steps_min > $screen Then
        $screen = $steps_min
    EndIf
    If $steps_max < $screen Then
        $screen = $steps_max
    EndIf
;Hide all controls
    For $x = 0 To UBound($frame) - 1
        For $i = 1 To $frame[$x][0]
            ConsoleWrite("Setting $frame[" & $x & "][" & $i & "]" & @CRLF)
            GUICtrlSetState($frame[$x][$i], $GUI_HIDE)
        Next
    Next
;Show the ones we want
    For $i = 0 To $frame[$step][0]
        GUICtrlSetState($frame[$screen][$i], $GUI_SHOW)
    Next
EndFunc  ;==>_ShowScreen

 

Cheers,

 

Brett

i hope this help ya:)

this code is faster then your code :

;Include files
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>

;Create array
Global $frame[6][6]
;current step
Global $step = 1
;min steps
Global $steps_min = 1
;last step
Global $steps_max = 6

;Main GUI
$Form1 = GUICreate("AAMP Library Wizard", 640, 480, 382, 192)
$Button1 = GUICtrlCreateButton("Previous", 392, 448, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Cancel", 472, 448, 75, 25, 0)
$Button3 = GUICtrlCreateButton("Next", 552, 448, 75, 25, 0)
$Pic1 = GUICtrlCreateLabel("", 0, 0, 640, 100)
GUICtrlSetBkColor (-1, 0x5555FF)
$Pic2 = GUICtrlCreatePic("", 0, 430, 640, 50)
GUICtrlSetBkColor (-1, 0x5555FF)
;Create title, set font etc
$Label1 = GUICtrlCreateLabel("Library Wizard Title", 8, 16, 620, 41, $SS_RIGHT)
GUICtrlSetFont(-1, 24, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
;create subtitle, set font etc
$Label2 = GUICtrlCreateLabel("Subtitle", 8, 56, 615, 25, $SS_RIGHT)
GUICtrlSetFont(-1, 16, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

;Start creating frames
;These are offsets.  Totally optional
$offset_x = 8
$offset_y = 109


;Frame 1
$frame[1][0] = 1;Total controls
;Controls
$frame[1][1] = GUICtrlCreateLabel("Welcome Blah Blah Blah...", $offset_x, $offset_y, 625, 321)

;Frame 2
$frame[2][0] = 2;Total controls
;controls
$frame[2][1] = GUICtrlCreateLabel("Please select the files you wish to associate with AAMP.", $offset_x + 8, $offset_y + 8, 268, 17)
$frame[2][2] = GUICtrlCreateGroup("", $offset_x + 8, $offset_y + 32, 609, 257)

;Frame 3
$frame[3][0] = 3;Total controls
;Controls
$frame[3][1] = GUICtrlCreateLabel("Please select any files and folders you wish to add to your library.", $offset_x + 8, $offset_y + 8, 610, 17)
$frame[3][2] = GUICtrlCreateList("", $offset_x + 8, $offset_y + 32, 609, 257)
$frame[3][3] = GUICtrlCreateButton("Add File", $offset_x + 539, $offset_y + 293, 80)

;Frame 4
$frame[4][0] = 5;Total controls
;Controls
$frame[4][1] = GUICtrlCreateLabel("Please wait while settings are applied, and media is added to your library.", $offset_x + 8, $offset_y + 8, 615, 17)
$frame[4][2] = GUICtrlCreateLabel("Total", $offset_x + 8, $offset_y + 30, 615, 17)
$frame[4][3] = GUICtrlCreateProgress($offset_x + 8, $offset_y + 48, 608, 17)
$frame[4][4] = GUICtrlCreateLabel("Applying File Associations", $offset_x + 8, $offset_y + 68, 615, 17)

;Frame 5
$frame[5][0] = 1;Total controls
;Controls
$frame[5][1] = GUICtrlCreateLabel("Process is complete.  You may now continue to use AAMP.", $offset_x + 8, $offset_y + 8, 615, 17)

;Show step 1
_ShowScreen($step)

;Show the GUI
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE; Close, exit
            Exit
        Case $Button2; Cancel, exit
            Exit
        Case $Button1; Previous, go back a step
            $step -= 1
            _ShowScreen($step)
        Case $Button3; next, go foward a step.  It is here we can do actions, like i have on step 4-5.
            $step += 1
            If $step = $steps_max Then
                Exit
             ElseIf $step = 4 Then
                _ShowScreen($step)
 For $i = 1 to 100 Step 2
                    GUICtrlSetData ($frame[4][3], $i)
                    Sleep (1)
                Next
            EndIf
            _ShowScreen($step)
        Case $frame[3][3];A control
            MsgBox (0, "", "CLICKED!")
    EndSwitch
WEnd
;Delte GUI
GUIDelete($Form1)

;Function for showing the screen
Func _ShowScreen(ByRef $screen)
;Check the step is in range
    If $steps_min > $screen Then
        $screen = $steps_min
    EndIf
    If $steps_max < $screen Then
        $screen = $steps_max
    EndIf
;Hide all controls
    For $x = 0 To UBound($frame) - 1
        For $i = 1 To $frame[$x][0]
            ConsoleWrite("Setting $frame[" & $x & "][" & $i & "]" & @CRLF)
            GUICtrlSetState($frame[$x][$i], $GUI_HIDE)
        Next
    Next
;Show the ones we want
    For $i = 0 To $frame[$step][0]
        GUICtrlSetState($frame[$screen][$i], $GUI_SHOW)
    Next
EndFunc  ;==>_ShowScreen

 

Edited by ad777

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

Link to comment
Share on other sites

  • Moderators

ad777,

Did you not see my comment above?

Quote

Did you notice that the post above yours is from 12 years ago?

Stop necro-posting all over the forum - or you may find you cannot post at all for a while!

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

 

Link to comment
Share on other sites

  • Developers

On top of that: This is the second time we informed you about not resurrecting old threads. 

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

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