Jump to content

problem with gui


Zithen
 Share

Recommended Posts

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")
    Else
        GUICreate("Printer Viewer")
        $viewedit = GUICtrlCreateEdit("Printers included in load file:" & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL+$WS_VSCROLL)
        GUISetState()
        For $i = 1 To $view[0]
            $name = IniRead($viewfile, $view[$i], "Name", "Null")
            GUICtrlSetData($viewedit, $name, 1)
        Next
        while 1
            $msg = GUIGetMsg()
            if $msg = $GUI_EVENT_CLOSE Then ExitLoop
        WEnd
    EndIf
EndFunc  ;==>view
Link to comment
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) 
   GUISetState(@SW_SHOW)


While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $ohide_button
        ExitLoop
    Case $msg = $oselect_button
        GUICtrlSetData($olabel, GUICtrlRead($display))
    Case Else
   ;;;;;;;
    EndSelect
WEnd
Exit

8)

NEWHeader1.png

Link to comment
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)
    Else
        $intLblLoad = GUICtrlCreateLabel("Load File", 20, 70, 320, 20)
    EndIf
    $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)
    
    GUISetState()
    While 1
        $intMsg = GUIGetMsg()
        Select
            Case $intMsg = $GUI_EVENT_CLOSE Or $intMsg = $intBtnExit
                ExitLoop
            Case $intMsg = $intBtnSave
                saveprinter()
            Case $intMsg = $intBtnSelect
                GUICtrlSetData($intLblLoad, FileOpenDialog("Select Printer Load File", $filepath, "Printer (*.PRN)"), "Load File")
            Case $intMsg = $intBtnLoad
                loadprinter()
            Case $intMsg = $intBtnDelete
                deleteprinter()
            Case $intMsg = $intBtnHelp
                help()
            Case $intMsg = $intBtnView
                view()
        EndSelect
    WEnd
    $Save = GUICtrlRead($intLblSave)
    $Load = GUICtrlRead($intLblLoad)
    GUIDelete($intWindow)
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

Link to comment
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.

JS

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)

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