Sign in to follow this  
Followers 0

problem with gui

8 posts in this topic

have a little GUI script, when i load this function, runs another GUI window (witch is good), but i close this window it closes both GUI windows and exits the script..What needs to be changed so that it only closes this window and not the rest

Func view()
    Local $viewfile
;pick file to view
    $viewfile = FileOpenDialog("Select file to view", $filepath, "Printer Save (*.PRN;*.0*)", 1 + 2)
    $view = IniReadSectionNames($viewfile)
    If @error Then
        MsgBox(48, "Error", "Error: Can not read save file." & @CR & @CR & "Error: 1096")
        GUICreate("Printer Viewer")
        $viewedit = GUICtrlCreateEdit("Printers included in load file:" & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL+$WS_VSCROLL)
        For $i = 1 To $view[0]
            $name = IniRead($viewfile, $view[$i], "Name", "Null")
            GUICtrlSetData($viewedit, $name, 1)
        while 1
            $msg = GUIGetMsg()
            if $msg = $GUI_EVENT_CLOSE Then ExitLoop
EndFunc  ;==>view

Share this post

Link to post
Share on other sites

for the main i have $intmsg and second on is $msg

i try to keep all my main gui vars as $int for initial gui, but you probly didnt need to know that. B)

Share this post

Link to post
Share on other sites

heres another approach

#include <GUIConstants.au3>

; create a printer list 
   $printer_list = GUICreate("List of Printers", 210, 340, -1, -1, $WS_POPUP + $WS_CAPTION) 
   $display = GUICtrlCreateList("", 10, 10, 190, 260) 
   GUICtrlSetData($display, "Officejet 1200|HP 1000|Max Printer|Zerox 120|HP Inkject 1225|") 
   $olabel = GUICtrlCreateLabel("Select a Printer to use", 45, 280, 120, 20, $SS_SUNKEN + $SS_CENTER) 
   $ohide_button = GUICtrlCreateButton("H&ide List", 120, 310, 70, 20) 
   $oselect_button = GUICtrlCreateButton("&Select", 20, 310, 70, 20) 

While 1
    $msg = GuiGetMsg()
    Case $msg = $ohide_button
    Case $msg = $oselect_button
        GUICtrlSetData($olabel, GUICtrlRead($display))
    Case Else



Share this post

Link to post
Share on other sites

well the function i posted was already inside another function thats the main GUI. the main GUI is

Func DisplayGUI()
    Local $intWindow
    Local $intLblSave
    Local $intLblLoad
    Local $intBtnSave
    Local $intBtnSelect
    Local $intBtnLoad
    Local $intBtnConvert
    Local $intBtnExit
    Local $intBtnHelp
    Local $intBtnView
    Local $intMsg
    Local $intDelete
    Local $Save
    Local $Load
    Local $intdeletestatus
    $intWindow = GUICreate("Printer script - Version: " & $Version, 500, 180)
    $intLblSave = GUICtrlCreateLabel($file, 20, 30, 400, 20)
    If FileExists($file) Then
        $intLblLoad = GUICtrlCreateLabel($file, 20, 70, 320, 20)
        $intLblLoad = GUICtrlCreateLabel("Load File", 20, 70, 320, 20)
    $intBtnSave = GUICtrlCreateButton("Save", 410, 20, 70, 30)
    $intBtnSelect = GUICtrlCreateButton("Select", 330, 60, 70, 30)
    $intBtnLoad = GUICtrlCreateButton("Load", 410, 60, 70, 30)
    $intBtnView = GUICtrlCreateButton("View", 20, 130, 70, 30)
    $intBtnDelete = GUICtrlCreateButton("Delete", 100, 130, 70, 30)
    $intBtnExit = GUICtrlCreateButton("Exit", 385, 130, 70, 30)
    $intBtnHelp = GUICtrlCreateButton("?", 465, 130, 15, 30)
    While 1
        $intMsg = GUIGetMsg()
            Case $intMsg = $GUI_EVENT_CLOSE Or $intMsg = $intBtnExit
            Case $intMsg = $intBtnSave
            Case $intMsg = $intBtnSelect
                GUICtrlSetData($intLblLoad, FileOpenDialog("Select Printer Load File", $filepath, "Printer (*.PRN)"), "Load File")
            Case $intMsg = $intBtnLoad
            Case $intMsg = $intBtnDelete
            Case $intMsg = $intBtnHelp
            Case $intMsg = $intBtnView
    $Save = GUICtrlRead($intLblSave)
    $Load = GUICtrlRead($intLblLoad)
EndFunc  ;==>DisplayGUI

when u click the view button it launches the View function that i posted at the top, but when u close the view window it cloes both GUI's and the script, not just the view GUI

Share this post

Link to post
Share on other sites

i got it fixed, i added guidelete before the exitloop and now its working good

Share this post

Link to post
Share on other sites

One thing you may want to look into. I know you have fixed the problem you were having. What if someone wanted to just close the main window? They couldnt. (I dont know that this matters, but I thought I would bring it up to save you some debug time).

You may want to look into having second windows (child windows) in the same loop as the main (parent) windows. That way any function sent to either window would be accptable and able to be caught respectively.

One place to start is $msg = GUIGetMsg(1) for advanced. It will return an array. I just got all of this figured out the other day.


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post

Link to post
Share on other sites

actaully i never actally thought about it...that is a good point...i will defenitly be looking into that. thanks for the info

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