Jump to content

GUICreate Question


Recommended Posts

Hi.

I have some problem with following code:

;   Here is GUI_1


$Form1 = GUICreate("Form1", 378, 256, 193, 125)
$Button3 = GUICtrlCreateButton("create", 248, 224, 89, 25, 0)
GUISetState(@SW_SHOW)

$listview = GUICtrlCreateListView (" Num",10,10,361,201)

GUICtrlCreateListViewItem("1",$listview)

GUICtrlSetState(-1,$GUI_DROPACCEPTED)  ; to allow drag and dropping
GUISetState()
Next

Do
  $msg = GUIGetMsg ()
     
   Select
      Case $msg = $listview
         MsgBox(0,"listview", "clicked="& GUICtrlGetState($listview),2)
      Case $msg = $Button3
         create()
   EndSelect
Until $msg = $GUI_EVENT_CLOSE

func create()


; here is GUI_2


$Form2 = GUICreate("Form2", 378, 256, 193, 125)
$cancel = GUICtrlCreateButton("cancel", 248, 224, 89, 25, 0)
GUISetState(@SW_SHOW)

$listview = GUICtrlCreateListView (" Num",10,10,361,201)

GUICtrlCreateListViewItem("1",$listview)

GUICtrlSetState(-1,$GUI_DROPACCEPTED)  ; to allow drag and dropping
GUISetState()
Next

Do
  $msg = GUIGetMsg ()
     
   Select
      Case $msg = $cancel
         exit
   EndSelect
Until $msg = $GUI_EVENT_CLOSE

endfunc

My question is:

When i exit GUI_2, GUI_1 exit too. How to exit GUI_2 but GUI_1 do not exit.

Thanks

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>

$Form1 = GUICreate("Form1", 378, 256, 193, 125)
$Button3 = GUICtrlCreateButton("create", 248, 224, 89, 25, 0)

$listview = GUICtrlCreateListView (" Num",10,10,361,201)

GUICtrlCreateListViewItem("1",$listview)

GUICtrlSetState(-1,$GUI_DROPACCEPTED)  ; to allow drag and dropping
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg ()
    Switch $msg
        Case $listview
            MsgBox(0,"listview", "clicked="& GUICtrlGetState($listview),2)
        Case $Button3
            create()
        case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

func create()

$Form2 = GUICreate("Form2", 378, 256, 193, 125, -1, -1, $Form1)
$cancel = GUICtrlCreateButton("cancel", 248, 224, 89, 25, 0)

$listview = GUICtrlCreateListView (" Num",10,10,361,201)

GUICtrlCreateListViewItem("1",$listview)

GUICtrlSetState(-1,$GUI_DROPACCEPTED)  ; to allow drag and dropping
GUISetState(@SW_SHOW)

    While 1
        $msg = GUIGetMsg ()
        Switch $msg
            Case $cancel
                ExitLoop
            case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
GUIDelete($Form2)
endfunc

exit = will exit entire script

guidelete = will close only selected window (GUI)

Link to comment
Share on other sites

sandin

Why need to create 2 main loops blink.gif

luckyluke

See here

#include <GuiConstants.au3>

$hMainGUI = GUICreate("Main GUI", 300, 200)

$SwitchButton = GUICtrlCreateButton("Switch", 100, 50, 60, 25)

$hChildGUI = GUICreate("Child GUI", 200, 100, -1, -1, -1, -1, $hMainGUI)
$SwitchButton1 = GUICtrlCreateButton("cancel", 100, 50, 55, 20)

GUISetState(@SW_SHOW, $hMainGUI)

While 1
    $msg = GUIGetMsg(1)
    Select
        Case $msg[0] = $GUI_EVENT_CLOSE  And $msg[1] = $hMainGUI
            ExitLoop
        Case $msg[0] = $GUI_EVENT_CLOSE  And $msg[1] = $hChildGUI
            GUISetState(@SW_ENABLE, $hMainGUI)
            GUISetState(@SW_HIDE, $hChildGUI)
        Case $msg[0] = $SwitchButton
            GUISetState(@SW_DISABLE, $hMainGUI)
            GUISetState(@SW_SHOW, $hChildGUI)
        Case $msg[0] = $SwitchButton1
            GUISetState(@SW_ENABLE, $hMainGUI)
            GUISetState(@SW_HIDE, $hChildGUI)
    EndSelect
WEnd

It look good to have a simple code. Thank you so much

Edited by luckyluke
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...