Jump to content

gui while 1


adam162
 Share

Recommended Posts

- not sure if the title of this thread is what it should be -

2 guis

both guis - work great

however when you run the other gui from the 1st gui and use guidelete() to the new gui the old one stops working

Any ideas ?

Edited by adam162
Link to comment
Share on other sites

  • Moderators

adam162,

Try reading the Managing Multiple GUIs tutorial in the Wiki and see if it helps. :)

If not, then post some code so we can see what the problem might be. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Just gave it ago and its sill not working

With Managing_Multiple_GUIs

Func gui_show_about()
    Opt("TrayMenuMode", 1)
Opt("TrayMenuMode", 0)
$About = GUICreate("About", 324, 241, 302, 218)
$GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
$Image1 = GUICtrlCreatePic("images\logo2.ico", 16, 24, 105, 97, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("**", 152, 24, 121, 17, $WS_GROUP)
$Label2 = GUICtrlCreateLabel("1.0.1", 152, 48, 28, 17, $WS_GROUP)
$Label3 = GUICtrlCreateLabel("© Copyright 2010 ***", 16, 136, 260, 17, $WS_GROUP)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("&OK", 112, 208, 75, 25)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
    Case $About
        Switch $nMsg[0]
            
        Case $GUI_EVENT_CLOSE
            GuiDelete($About)
        Case $Button1
            GuiDelete($About)
        EndSwitch
        Endswitch
WEnd

endfunc

func gui_show_calendar()
    Opt("TrayMenuMode", 1)
Opt("TrayMenuMode", 0)
$Calendar = GUICreate("***", 631, 584, 187, 110)
$MenuItem1 = GUICtrlCreateMenu("&File")
$MenuItem4 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("&Help")
$MenuItem3 = GUICtrlCreateMenuItem("About", $MenuItem2)
$MonthCal1 = GUICtrlCreateMonthCal("2010/09/01", 10, 25, 606, 171)
$Progress1 = GUICtrlCreateProgress(10, 200, 601, 36, $PBS_SMOOTH, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$Edit1 = GUICtrlCreateEdit("", 15, 240, 606, 236, BitOR($ES_CENTER,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_NOHIDESEL,$ES_READONLY,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL))
GUICtrlSetData(-1, "****")
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Close", 190, 485, 226, 46, $WS_GROUP)
GUICtrlSetFont(-1, 20, 400, 0, "MS UI Gothic")
$Status = _GUICtrlStatusBar_Create($Calendar)
Dim $Status_PartsWidth[2] = [295, -1]
_GUICtrlStatusBar_SetParts($Status, $Status_PartsWidth)
_GUICtrlStatusBar_SetText($Status, "***", 0)
_GUICtrlStatusBar_SetText($Status, @TAB & "***", 1)
_GUICtrlStatusBar_SetMinHeight($Status, 26)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg(1)
Switch $nMsg[1]
Case $Calendar
    Switch $nMsg[0]
Case $GUI_EVENT_CLOSE

    GuiDelete($Calendar)
    
Case $MenuItem4 
  
    GuiDelete($Calendar)

Case $MenuItem3
     gui_show_about()
 Case $Button1
  
    GuiDelete($Calendar)
    
EndSwitch
Endswitch
WEnd
endfunc

With out Managing_Multiple_GUIs

Func gui_show_about()
    Opt("TrayMenuMode", 1)
Opt("TrayMenuMode", 0)
$About = GUICreate("About", 324, 241, 302, 218)
$GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
$Image1 = GUICtrlCreatePic("images\logo2.ico", 16, 24, 105, 97, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("**", 152, 24, 121, 17, $WS_GROUP)
$Label2 = GUICtrlCreateLabel("1.0.1", 152, 48, 28, 17, $WS_GROUP)
$Label3 = GUICtrlCreateLabel("© Copyright 2010 ***", 16, 136, 260, 17, $WS_GROUP)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("&OK", 112, 208, 75, 25)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
            
        Case $GUI_EVENT_CLOSE
            GuiDelete($About)
        Case $Button1
            GuiDelete($About)
        EndSwitch
WEnd

endfunc

func gui_show_calendar()
    Opt("TrayMenuMode", 1)
Opt("TrayMenuMode", 0)
$Calendar = GUICreate("***", 631, 584, 187, 110)
$MenuItem1 = GUICtrlCreateMenu("&File")
$MenuItem4 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("&Help")
$MenuItem3 = GUICtrlCreateMenuItem("About", $MenuItem2)
$MonthCal1 = GUICtrlCreateMonthCal("2010/09/01", 10, 25, 606, 171)
$Progress1 = GUICtrlCreateProgress(10, 200, 601, 36, $PBS_SMOOTH, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$Edit1 = GUICtrlCreateEdit("", 15, 240, 606, 236, BitOR($ES_CENTER,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_NOHIDESEL,$ES_READONLY,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL))
GUICtrlSetData(-1, "****")
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Close", 190, 485, 226, 46, $WS_GROUP)
GUICtrlSetFont(-1, 20, 400, 0, "MS UI Gothic")
$Status = _GUICtrlStatusBar_Create($Calendar)
Dim $Status_PartsWidth[2] = [295, -1]
_GUICtrlStatusBar_SetParts($Status, $Status_PartsWidth)
_GUICtrlStatusBar_SetText($Status, "***", 0)
_GUICtrlStatusBar_SetText($Status, @TAB & "***", 1)
_GUICtrlStatusBar_SetMinHeight($Status, 26)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg

Case $GUI_EVENT_CLOSE

    GuiDelete($Calendar)
    
Case $MenuItem4 
  
    GuiDelete($Calendar)

Case $MenuItem3
     gui_show_about()
 Case $Button1
  
    GuiDelete($Calendar)
    
EndSwitch

WEnd
endfunc

Now the problem I have is that when I open the About gui ( ex 1 and 3) and use the exit button the calendar gui ( ex 2 and 4) does not work

Link to comment
Share on other sites

  • Moderators

adam162,

Tutorial read, but not understood evidently. :P

But as the tutorial says: "it is nowhere near as difficult as it first appears" - so take a look at this: ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>
#include <EditConstants.au3>
#include <GuiStatusBar.au3>

; Declare Global variable swith placeholders so that the GUIGetMsg loop has something to work with if the GUIs are not yet created
Global $About = 9999, $Calendar = 9999, $Button1 = 9999, $Button2 = 9999, $MenuItem3 = 9999, $MenuItem4 = 9999, $fAbout_Showing = False, $fCalendar_Showing = False

; Create main GUI
$hGUI = GUICreate("Test", 500, 500)

$hButton_About = GUICtrlCreateButton("About", 10, 10, 80, 30)
$hButton_Calendar = GUICtrlCreateButton("Calendar", 10, 100, 80, 30)

GUISetState()

While 1

    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
        ; Look at the main GUI
        Case $hGUI
            Switch $nMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $hButton_About
                    ; If it is not showing then show it
                    If $fAbout_Showing = False Then gui_show_about()
                Case $hButton_Calendar
                    gui_show_calendar()
            EndSwitch
        ; Look at the About GUI
        Case $About
            Switch $nMsg[0]
                Case $GUI_EVENT_CLOSE, $Button1
                    GUIDelete($About)
                    ; It is not showing any more
                    $fAbout_Showing = False
            EndSwitch
        ; Look at the Calendar GUI
        Case $Calendar
            Switch $nMsg[0]
                Case $GUI_EVENT_CLOSE, $MenuItem4, $Button2
                    GuiDelete($Calendar)
                    ; It is not showing any more
                    $fCalendar_Showing = False
                Case $MenuItem3
                    ; If it is not showing then show it
                    If $fAbout_Showing = False Then gui_show_about()
            EndSwitch
    EndSwitch
WEnd

Func gui_show_about()

    ; Only show if it is not already showing 
    If $fAbout_Showing = True Then Return

    $About = GUICreate("About", 324, 241, 302, 218)
    $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
    ;$Image1 = GUICtrlCreatePic("images\logo2.ico", 16, 24, 105, 97, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    $Label1 = GUICtrlCreateLabel("**", 152, 24, 121, 17)
    $Label2 = GUICtrlCreateLabel("1.0.1", 152, 48, 28, 17)
    $Label3 = GUICtrlCreateLabel("© Copyright 2010 ***", 16, 136, 260, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button1 = GUICtrlCreateButton("&OK", 112, 208, 75, 25)
    GUISetState(@SW_SHOW)

    ; It is now showing
    $fAbout_Showing = True

EndFunc   ;==>gui_show_about

Func gui_show_calendar()

    ; Only show if not already showing
    If $fCalendar_Showing = True Then Return

    $Calendar = GUICreate("***", 631, 584, 187, 110)
    $MenuItem1 = GUICtrlCreateMenu("&File")
    $MenuItem4 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
    $MenuItem2 = GUICtrlCreateMenu("&Help")
    $MenuItem3 = GUICtrlCreateMenuItem("About", $MenuItem2)
    $MonthCal1 = GUICtrlCreateMonthCal("2010/09/01", 10, 25, 606, 171)
    $Progress1 = GUICtrlCreateProgress(10, 200, 601, 36, $PBS_SMOOTH, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))
    $Edit1 = GUICtrlCreateEdit("", 15, 240, 606, 236, BitOR($ES_CENTER, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_NOHIDESEL, $ES_READONLY, $ES_WANTRETURN, $WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetData(-1, "****")
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Button2 = GUICtrlCreateButton("Close", 190, 485, 226, 46) ; As we look for all controls in one loop we need unique names
    GUICtrlSetFont(-1, 20, 400, 0, "MS UI Gothic")
    $Status = _GUICtrlStatusBar_Create($Calendar)
    Dim $Status_PartsWidth[2] = [295, -1]
    _GUICtrlStatusBar_SetParts($Status, $Status_PartsWidth)
    _GUICtrlStatusBar_SetText($Status, "***", 0)
    _GUICtrlStatusBar_SetText($Status, @TAB & "***", 1)
    _GUICtrlStatusBar_SetMinHeight($Status, 26)
    GUISetState(@SW_SHOW)

    ; It is now showing
    $fCalendar_Showing = True

EndFunc   ;==>gui_show_calendar

Does this make more sense? :)

You need a SINGLE loop where you capture all the events within your script. So you must return there after each function - unless you want it to block the rest of the script. o:)

Please ask if you have questions. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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