Jump to content

Why this not work ?


BJJ
 Share

Recommended Posts

Hi

My next problem i dont know why that not work

Local $nMsg , $BackButton_all 


$Form1 = GUICreate("Form1", 340, 557, 387, 236)
$Button1 = GUICtrlCreateButton("Button1", 16, 16, 121, 17, 0)
$Button2 = GUICtrlCreateButton("Button2", 16, 40, 121, 17, 0)
$Button3 = GUICtrlCreateButton("Button3", 16, 64, 121, 17, 0)
GUISetState()

While 1
$nMsg = GUIGetMsg()

 Select
    
    Case $nMsg = $GUI_EVENT_CLOSE
        GUIDelete()
        Exit



    case $nMsg = $Button1
    
        $Form2 = GUICreate("Form1", 258, 274, 351, 323)
        $BackButton1 = GUICtrlCreateButton("back", 192, 240, 57, 25, 0)
        GUISetState()
        
        case $nMsg = $Button2
    
        $Form3 = GUICreate("Form1", 258, 274, 351, 323)
        $BackButton2 = GUICtrlCreateButton("back", 192, 240, 57, 25, 0)
        GUISetState()
        
    case $nMsg = $Button3
    
        $Form4 = GUICreate("Form1", 258, 274, 351, 323)
        $BackButton3 = GUICtrlCreateButton("back", 192, 240, 57, 25, 0)
        GUISetState()

$BackButton_all = $BackButton1 or $BackButton2 or $BackButton3  
        
    While 2
         $nMsg = GUIGetMsg()
             select 
                 case $nMsg = $GUI_EVENT_CLOSE
        GUIDelete()
        Exit
        
         case $nMsg = $BackButton_all
    GUISetState(@SW_HIDE)
    
    ExitLoop
    EndSelect
    WEnd
Exit
Link to comment
Share on other sites

I add this but stil dont work

BackButtons :/

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Array.au3>
#include <StaticConstants.au3>
#Include <File.au3>
#include <ComboConstants.au3>
#include <GUIListBox.au3>

Local $nMsg , $BackButton_all


$Form1 = GUICreate("Form1", 340, 557, 387, 236)
$Button1 = GUICtrlCreateButton("Button1", 16, 16, 121, 17, 0)
$Button2 = GUICtrlCreateButton("Button2", 16, 40, 121, 17, 0)
$Button3 = GUICtrlCreateButton("Button3", 16, 64, 121, 17, 0)
GUISetState()

While 1
$nMsg = GUIGetMsg()

 Select
   
    Case $nMsg = $GUI_EVENT_CLOSE
        GUIDelete()
        Exit



    case $nMsg = $Button1
   
        $Form2 = GUICreate("Form1", 258, 274, 351, 323)
        $BackButton1 = GUICtrlCreateButton("back", 192, 240, 57, 25, 0)
        GUISetState()
       
        case $nMsg = $Button2
   
        $Form3 = GUICreate("Form1", 258, 274, 351, 323)
        $BackButton2 = GUICtrlCreateButton("back", 192, 240, 57, 25, 0)
        GUISetState()
       
    case $nMsg = $Button3
   
        $Form4 = GUICreate("Form1", 258, 274, 351, 323)
        $BackButton3 = GUICtrlCreateButton("back", 192, 240, 57, 25, 0)
        GUISetState()
        
EndSelect
WEnd

$BackButton_all = $BackButton1 or $BackButton2 or $BackButton3 
       
    While 2
         $nMsg = GUIGetMsg()
             select
                 case $nMsg = $GUI_EVENT_CLOSE
        GUIDelete()
        Exit
       
         case $nMsg = $BackButton_all
    GUISetState(@SW_HIDE)
   
    ExitLoop
    EndSelect
   
WEnd

Exit
Link to comment
Share on other sites

  • Developers

What is this section supposed to do?

$BackButton_all = $BackButton1 Or $BackButton2 Or $BackButton3
While 2
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
        Case $nMsg = $BackButton_all
            GUISetState(@SW_HIDE)
            ExitLoop
    EndSelect
WEnd

Also, the first line doesn't make any sence to me.

Jos

Edited by Jos

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

  • Developers

any gui have button close this while make when you click on close button gui be close and back to program window

not sure what you are trying to tell me here, but the second while will never ever be executed.

Also, as mentioned, this line does not make any sence:

$BackButton_all = $BackButton1 Or $BackButton2 Or $BackButton3

You need to put all you GUI logic within the first Whille-Wend loop.

Jos

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

just add the statements in the while 1 loop

take a look at guigetmsg and other gui functions in the helpfile

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

eh i try but stil my cod be wrong

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Array.au3>
#include <StaticConstants.au3>
#Include <File.au3>
#include <ComboConstants.au3>
#include <GUIListBox.au3>

Local $nMsg , $BackButton_all

$Form1 = GUICreate("Form1", 340, 557, 387, 236)
$Button1 = GUICtrlCreateButton("Button1", 16, 16, 121, 17, 0)
$Button2 = GUICtrlCreateButton("Button2", 16, 40, 121, 17, 0)
$Button3 = GUICtrlCreateButton("Button3", 16, 64, 121, 17, 0)
GUISetState()

While 1
$nMsg = GUIGetMsg()

 Select
   
    Case $nMsg = $GUI_EVENT_CLOSE
        GUIDelete()
        Exit
        
    case $nMsg = $Button1
   
        $Form2 = GUICreate("Form1", 258, 274, 351, 323)
        $BackButton1 = GUICtrlCreateButton("back", 192, 240, 57, 25, 0)
        GUISetState()
       
        case $nMsg = $Button2
   
        $Form3 = GUICreate("Form1", 258, 274, 351, 323)
        $BackButton2 = GUICtrlCreateButton("back", 192, 240, 57, 25, 0)
        GUISetState()
       
    case $nMsg = $Button3
   
        $Form4 = GUICreate("Form1", 258, 274, 351, 323)
        $BackButton3 = GUICtrlCreateButton("back", 192, 240, 57, 25, 0)
        GUISetState()
        
        
        case $nMsg = $BackButton1 
    GUISetState(@SW_HIDE)
        
EndSelect
WEnd
Exit
Link to comment
Share on other sites

  • Developers

I can see that it is wrong.... what are you trying to do when creating the new GUI's after a button is clicked?

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

  • Moderators

Quzziy,

Hi again. This is a simple example of what I think you are looking for:

#include <GUIConstantsEx.au3>

Global $nMsg, $Form2 = 9999, $BackButton2 = 9999

$Form1 = GUICreate("Form1", 340, 557, 387, 236)
$Button1 = GUICtrlCreateButton("Button1", 16, 16, 121, 17, 0)

GUISetState()

While 1

$aMsg = GUIGetMsg(1)

    Select
        Case $aMsg[0] = $GUI_EVENT_CLOSE And $aMsg[1] = $Form1
            GUIDelete($Form1)
            Exit
            
        Case $aMsg[0] = $GUI_EVENT_CLOSE And $aMsg[1] = $Form2
            GUIDelete($Form2)
            
        Case $aMsg[0] = $Button1
            If Not WinExists("Form2", "") Then
                $Form2 = GUICreate("Form2", 258, 274, 351, 323)
                $BackButton2 = GUICtrlCreateButton("Back", 192, 240, 57, 25, 0)
            EndIf
            GUISetState(@SW_SHOW, $Form2)

        Case $aMsg[0] = $BackButton2 
            GUISetState(@SW_HIDE, $Form2)
    EndSelect
    
WEnd

Two things to note:

1. You have to declare the $Form2 and $BackButton2 variables with some value or else the Select Case has nothing to compare. You cannot leave them at 0 as that is the "nothing happening" return from GUIGetMsg. You need to use a high number so that it is very unlikely to correspond with a valid control.

2. The use of GUIGetMsg(1) which returns an array so you can determine which window is responding (look in the Help file for details). Otherwise clicking the [X] on Form2 will exit the whole script - try using just GUIGetMsg() and see what happens.....

Enjoy your time with the dictionary (private joke!),

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

#include <GUIConstantsEx.au3>

Global $nMsg, $Form2 = 9999, $Form3 = 9999 , $BackButton2 = 9999 , $BackButton3 = 9999

$Form1 = GUICreate("Form1", 340, 557, 387, 236)
$Button1 = GUICtrlCreateButton("Button1", 16, 16, 121, 17, 0)
$Button2 = GUICtrlCreateButton("Button2", 16, 40, 121, 17, 0)
GUISetState()

While 1

$aMsg = GUIGetMsg(1)

    Select
        Case $aMsg[0] = $GUI_EVENT_CLOSE And $aMsg[1] = $Form1
            GUIDelete($Form1)
            Exit
            
        Case $aMsg[0] = $GUI_EVENT_CLOSE And $aMsg[1] = $Form2
            GUIDelete($Form2)
            
        Case $aMsg[0] = $Button1
            If Not WinExists("Form2", "") Then
                $Form2 = GUICreate("Form2", 258, 274, 351, 323)
                $BackButton2 = GUICtrlCreateButton("Back", 192, 240, 57, 25, 0)
            EndIf
            GUISetState(@SW_SHOW, $Form2)
            
                    Case $aMsg[0] = $Button2
            If Not WinExists("Form3", "") Then
                $Form3 = GUICreate("Form3", 258, 274, 351, 323)
                $BackButton3 = GUICtrlCreateButton("Back", 192, 240, 57, 25, 0)
            EndIf
            GUISetState(@SW_SHOW, $Form3)
            
            
Case $aMsg[0] = $BackButton3
            GUISetState(@SW_HIDE, $Form3)
Case $aMsg[0] = $BackButton2
            GUISetState(@SW_HIDE, $Form2)
    EndSelect
    
WEnd

Thats work good but if i want make 30 button't that dont be look good

and i dont understand why i must put " =9999" after variable

in past program i dont use this and all work greate

Edited by Quzziy
Link to comment
Share on other sites

  • Moderators

Quzziy,

Check your code for the second GUI carefully - you have 2 errors in that section:

1. If Not WinExists("Form", "") should read If Not WinExists("Form3", "")

2. GUISetState(@SW_SHOW, $Form2) should read GUISetState(@SW_SHOW, $Form3)

You should also add another $GUI_EVENT_CLOSE case for Form3:

#include <GUIConstantsEx.au3>

Global $nMsg, $Form2 = 9999, $Form3 = 9999 , $BackButton2 = 9999 , $BackButton3 = 9999

$Form1 = GUICreate("Form1", 340, 557, 387, 236)
$Button1 = GUICtrlCreateButton("Button1", 16, 16, 121, 17, 0)
$Button2 = GUICtrlCreateButton("Button2", 16, 40, 121, 17, 0)
GUISetState()

While 1

$aMsg = GUIGetMsg(1)

    Select
        Case $aMsg[0] = $GUI_EVENT_CLOSE And $aMsg[1] = $Form1
            GUIDelete($Form1)
            Exit
            
        Case $aMsg[0] = $GUI_EVENT_CLOSE And $aMsg[1] = $Form2
            GUIDelete($Form2)
        
        Case $aMsg[0] = $GUI_EVENT_CLOSE And $aMsg[1] = $Form3
            GUIDelete($Form3)
            
        Case $aMsg[0] = $Button1
            If Not WinExists("Form2", "") Then
                $Form2 = GUICreate("Form2", 258, 274, 351, 323)
                $BackButton2 = GUICtrlCreateButton("Back", 192, 240, 57, 25, 0)
            EndIf
            GUISetState(@SW_SHOW, $Form2)
            
        Case $aMsg[0] = $Button2
            If Not WinExists("Form3", "") Then
                $Form3 = GUICreate("Form3", 258, 274, 351, 323)
                $BackButton3 = GUICtrlCreateButton("Back", 192, 240, 57, 25, 0)
            EndIf
            GUISetState(@SW_SHOW, $Form3)
            
            
Case $aMsg[0] = $BackButton3
            GUISetState(@SW_HIDE, $Form3)
Case $aMsg[0] = $BackButton2
            GUISetState(@SW_HIDE, $Form2)
    EndSelect
    
WEnd

You must take great care when coding to avoid silly errors like those above. We all do it, but do proofread your code carefully if it does not work as expected - you will be surprised how many times it is your own coding error which is causing the problem.

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

  • Moderators

Quzziy,

No, you can have 1 declaration per line if you wish, although it does take up a lot of space. :-)

I usually break the variables into logical lines:

Global <everything to do with GUI>

Global <everything to do with this part of the script>

Global <everything to do with that part of the script>

and so on. Then if I change a section of the code and need to adjust the declarations, they are easy to find.

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

  • Moderators

Quzziy,

Have you tried?

M23

P.S. The answer is Tak.

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

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...