Jump to content

Multiple GUI in one AU3 file ?


Bot
 Share

Recommended Posts

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("About", 324, 241, 303, 219)
GUISetIcon("D:06.ico")
$GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
$Image1 = GUICtrlCreatePic("", 16, 24, 105, 97, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("Product Name", 152, 24, 72, 17, $WS_GROUP)
$Label2 = GUICtrlCreateLabel("Version", 152, 48, 39, 17, $WS_GROUP)
$Label4 = GUICtrlCreateLabel("Comments", 16, 160, 53, 17, $WS_GROUP)
$Label3 = GUICtrlCreateLabel("Copyright", 16, 136, 48, 17, $WS_GROUP)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("&OK", 112, 208, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Password Dialog", 251, 100, -1, -1)
GUISetIcon("D:08.ico")
$PasswordEdit = GUICtrlCreateInput("password", 8, 32, 233, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$ButtonOk = GUICtrlCreateButton("&OK", 86, 64, 75, 25, 0)
$ButtonCancel = GUICtrlCreateButton("&Cancel", 167, 64, 75, 25, 0)
$EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 12, 77, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

I'm having two GUI in a AU3 file but when I click on the close button then both of them disappear. How can I handle $nMsg for each GUI or do I need something extra ? :)

Link to comment
Share on other sites

That is because Exit is called when closing the application.

I changed the name of your second form and modified the GUI close function:

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("About", 324, 241, 303, 219)
;GUISetIcon("D:06.ico")
$GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
$Image1 = GUICtrlCreatePic("", 16, 24, 105, 97, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("Product Name", 152, 24, 72, 17, $WS_GROUP)
$Label2 = GUICtrlCreateLabel("Version", 152, 48, 39, 17, $WS_GROUP)
$Label4 = GUICtrlCreateLabel("Comments", 16, 160, 53, 17, $WS_GROUP)
$Label3 = GUICtrlCreateLabel("Copyright", 16, 136, 48, 17, $WS_GROUP)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("&OK", 112, 208, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

#Region ### START Koda GUI section ### Form=
$Form1pwd = GUICreate("Password Dialog", 251, 100, -1, -1)
;GUISetIcon("D:08.ico")
$PasswordEdit = GUICtrlCreateInput("password", 8, 32, 233, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$ButtonOk = GUICtrlCreateButton("&OK", 86, 64, 75, 25, 0)
$ButtonCancel = GUICtrlCreateButton("&Cancel", 167, 64, 75, 25, 0)
$EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 12, 77, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            If WinActive ($Form1pwd) Then
                GUIDelete ($Form1pwd)
            Else
                Exit
            EndIf
    EndSwitch
WEnd

:)

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Hi,

Use advanced mode for GuiGetMsg(1)...

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("About", 324, 241, 303, 219)
GUISetIcon("D:06.ico")
$GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
$Image1 = GUICtrlCreatePic("", 16, 24, 105, 97, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("Product Name", 152, 24, 72, 17, $WS_GROUP)
$Label2 = GUICtrlCreateLabel("Version", 152, 48, 39, 17, $WS_GROUP)
$Label4 = GUICtrlCreateLabel("Comments", 16, 160, 53, 17, $WS_GROUP)
$Label3 = GUICtrlCreateLabel("Copyright", 16, 136, 48, 17, $WS_GROUP)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("&OK", 112, 208, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Password Dialog", 251, 100, -1, -1)
GUISetIcon("D:08.ico")
$PasswordEdit = GUICtrlCreateInput("password", 8, 32, 233, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$ButtonOk = GUICtrlCreateButton("&OK", 86, 64, 75, 25, 0)
$ButtonCancel = GUICtrlCreateButton("&Cancel", 167, 64, 75, 25, 0)
$EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 12, 77, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg(1)
    Select
        Case $nMsg[0] = $GUI_EVENT_CLOSE And $nMsg[1] = $Form1
            Exit
        Case $nMsg[0] = $GUI_EVENT_CLOSE And $nMsg[1] = $Form2
            GUIDelete($Form2)
    EndSelect
WEnd

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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