Sign in to follow this  
Followers 0
faustf

close second gui on event mode

4 posts in this topic

#1 ·  Posted (edited)

hi guy i have a  script  very long   the structure  is composed  in onevent mode system  

 

----------

include
Opt("GuiOnEventMode", 1)
Opt("GUICloseOnESC", 0)

global varible

----------

func _gui1()

$Form1_1 = GUICreate("........

.....

...

endfunc



func _sql()

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")      ; for controll error

endfunc
Func _ErrFunc($oError)
    ; Do anything here.

    $Form2 = GUICreate("Error", 493, 277, 852, 219)
    $Edit1 = GUICtrlCreateEdit("", 6, 66, 481, 203, BitOR($ES_AUTOVSCROLL, $WS_HSCROLL,$ES_AUTOHSCROLL, $ES_WANTRETURN, $ES_READONLY))
    GUICtrlSetData(-1, @ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode))

    $Pic1 = GUICtrlCreatePic(@ScriptDir & "\config\white.jpg", -2, -2, 493, 64)
    $Label1 = GUICtrlCreateLabel("Il Programma ha riscontrato un errore  grave", 30, 11, 308, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0xFFFFFF)

    GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")
#cs
While 1

        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
            GUISetOnEvent($GUI_EVENT_CLOSE, "_chiudi")
                ExitLoop
                Exit
                GUIDelete($Form2)
        EndSwitch
WEnd
#ce
EndFunc   ;==>_ErrFunc
Func On_Close()
     Switch @GUI_WINHANDLE ; See which GUI sent the CLOSE message
         Case $Form1_1
             Exit ; If it was this GUI - we exit <<<<<<<<<<<<<<<
         Case $Form2
             GUIDelete($Form2) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<<

     EndSwitch
 EndFunc
Func _chiudi()
;GUIDelete($Form2)
    Exit
    EndFunc
;===============================================================

;Keep the GUI alive

;===============================================================

While 1

    Sleep(1000)

WEnd

 

the problem is , when  run  the  error Gui ($form2) , appear  one  second  , and  close  all  , like i pressed  button |X| , how  is possible?? 

thankz  for  help at  all

 

Edited by faustf

Share this post


Link to post
Share on other sites



can you please edit your post to 1 wellformated script in the autoit tags?

Share this post


Link to post
Share on other sites

hi guy  i   did  do  a little step , so i  tryed  to create  a  3° form gui and use the same  sistem for close  and  work good ,  i think  the problem is  ObjEvent , in practical i want  write a  log   not in console  but  in edit  like this 

but  if insert while cicle  not intercept  a $GUI_EVENT_CLOSE or  exit  o guidelete

some one  have  idea?? 

thankz

 

Untitled.jpg

Share this post


Link to post
Share on other sites

Post your script so we can see what you're doing. The code you posted isn't runnable and we have no idea what you're trying to do or where it is going wrong.


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

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  
Followers 0