Jump to content
Sign in to follow this  
kenneal

Child gui hangs up entire script

Recommended Posts

kenneal

I am trying to do a mini book system for my store and in the midst of it ran into problems trying to call up the child gui.

The entire script freezes up when I call up the childgui. Does anyone know why? I have seen examples on how to do this in the forums and have tried to apply the same way but it fails with either a crash with autoit3.exe or simply work.

This is the simplified version for easy viewing.. The code works when I remove the While loop on the child gui.

There is a version also that works at http://www.autoitscript.com/forum/index.ph...hild+gui+parent but I failed to get mine working like the above :mellow: any help is greatly appreciated :(

#include <GUIConstants.au3>
#include <array.au3>
#include <GuiTab.au3>
#include <GuiConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiMenu.au3>

$hGUI=GUICreate("BookSys", 400, 400)
    
$listview       = GUICtrlCreateListView("UserID|Name     |Category|Number|Lastview  ",10,10,380,150)
GUICtrlCreateListViewItem("001|Name|B|1234565677|1998", $listview)
GUISetState()
GUIRegisterMsg($WM_NOTIFY , "WME")

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd
Func WME($hWndGUI, $MsgID, $wParam, $lParam)
     #forceref $hWndGUI, $MsgID, $wParam
     Local $tagNMHDR, $event, $hwndFrom, $code 
     $tagNMHDR = DllStructCreate("int;int;int", $lParam) 
     If @error Then Return
     $event = DllStructGetData($tagNMHDR, 3)
     Select
     Case $wParam = $ListView
          Select
          Case $event = $NM_DBLCLK

                EditData(GUICtrlRead(GUICtrlRead($listview)))
                GuiSetState(@SW_ENABLE,$hGUI)
                GuiSetState(@SW_RESTORE,$hGUI)
        EndSelect
    EndSelect
endFunc 
Func EditData($data)
    $data2=StringSplit($data, "|")
    GUISetState(@SW_DISABLE, $hGUI)
    $Form1 = GUICreate("Form1", 321, 378, -1, -1, $WS_EX_TOOLWINDOW)
    $Input1 = GUICtrlCreateInput("Input1", 80, 40, 129, 21)
    GUISetState()

        While 1
        $msg = GUIGetMsg()
        Select
        Case $msg = $GUI_EVENT_CLOSE
            GUIDelete($Form1)
            ExitLoop
        EndSelect
    Wend
EndFunc
Edited by kenneal

Share this post


Link to post
Share on other sites
Wooltown

Try like this:

#include <GUIConstants.au3>
#include <array.au3>
#include <GuiTab.au3>
#include <GuiConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiMenu.au3>

Global $hGUI=GUICreate("BookSys", 400, 400)
Global $Form1   
$listview       = GUICtrlCreateListView("UserID|Name     |Category|Number|Lastview  ",10,10,380,150)
GUICtrlCreateListViewItem("001|Name|B|1234565677|1998", $listview)
GUISetState()
GUIRegisterMsg($WM_NOTIFY , "WME")

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE
            GUIExit()
    EndSwitch
WEnd
Func GUIExit()
    If WinExists("Form1") Then 
        GUIDelete($Form1)
    Else
        Exit
    EndIf
EndFunc
Func WME($hWndGUI, $MsgID, $wParam, $lParam)
     #forceref $hWndGUI, $MsgID, $wParam
     Local $tagNMHDR, $event, $hwndFrom, $code
     $tagNMHDR = DllStructCreate("int;int;int", $lParam)
     If @error Then Return
     $event = DllStructGetData($tagNMHDR, 3)
     Select
     Case $wParam = $ListView
          Select
          Case $event = $NM_DBLCLK

                EditData(GUICtrlRead(GUICtrlRead($listview)))
                GuiSetState(@SW_ENABLE,$hGUI)
                GuiSetState(@SW_RESTORE,$hGUI)
        EndSelect
    EndSelect
endFunc 
Func EditData($data)
    $data2=StringSplit($data, "|")
    GUISetState(@SW_DISABLE, $hGUI)
    $Form1 = GUICreate("Form1", 321, 378, -1, -1, $WS_EX_TOOLWINDOW,"",$hGUI)
    $Input1 = GUICtrlCreateInput("Input1", 80, 40, 129, 21)
    GUISetState()

;        While 1
;        $msg = GUIGetMsg()
;        Select
;        Case $msg = $GUI_EVENT_CLOSE
;            GUIDelete($Form1)
;            ExitLoop
;        EndSelect
;   Wend
EndFunc

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.