Jump to content

How to make parent & child window?


 Share

Recommended Posts

hello everyone

I want to create a parent window with several child windows, I did something in koda but I had some problems!

Problem: when I close the child window... the parent window also closes!

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 779, 501, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 352, 128, 75, 25)
GUISetState(@SW_SHOW)

$Form2 = GUICreate("Form2", 505, 350, 184, 116, -1, -1, $Form1)
$Input1 = GUICtrlCreateInput("Input1", 184, 80, 121, 21)
$Button2 = GUICtrlCreateButton("Button2", 208, 120, 75, 25)
GUISetState(@SW_HIDE)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            WinSetState("Form2", '', @SW_SHOW)
    EndSwitch
WEnd

 

Link to comment
Share on other sites

  • Moderators

Reza10101,

I suggest reading the Managing Multiple GUIs tutorial in the Wiki - it explains how to avoid this problem.

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

  • Developers
4 minutes ago, Reza10101 said:

 I'm in a hurry!

:) Iam pretty sure you aren't willing to cough up €100 per hour to do the coding for you ...right?

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I found a function that I solved my problem!

GUIGetMsg

tnx everybody

also I found this code from other topics:

#Include <GuiConstantsEx.au3>

Opt("MustDeclareVars",1)

Dim $guimain, $guichild, $guibutton, $array_msg

$guimain = GUICreate("",400,400)
$guibutton = GUICtrlCreateButton("child",165,180,60,20)

GUISetState(@SW_SHOW, $guimain)

While 1
    $array_msg = GUIGetMsg(1)
    Switch $array_msg[0]
        Case $guibutton
            $guichild = GUICreate("",200,200)
            GUISetState(@SW_SHOW, $guichild)
        Case $GUI_EVENT_CLOSE
            Switch $array_msg[1]
                Case $guichild
                    GUISetState(@SW_HIDE, $guichild)
                Case $guimain
                    Exit
            EndSwitch
    EndSwitch
WEnd

Solved!

Link to comment
Share on other sites

You can do this:

 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", 779, 501, 192, 124)
Local $Button1 = GUICtrlCreateButton("Button1", 352, 128, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    Switch GUIGetMsg()
        Case -3
        GUIDelete($Form1)
            Exit
        Case $Button1
            _a()
    EndSwitch
Sleep(10)
WEnd

Func _a($a = '')
Local $Form2 = GUICreate("Form2", 505, 350, 184, 116, -1, -1, $Form1)
Local $Input1 = GUICtrlCreateInput("Input1", 184, 80, 121, 21),$Button2 = GUICtrlCreateButton("Button2", 208, 120, 75, 25)
GUISetState(@SW_SHOW,$Form2)
While 1
Switch GUIGetMsg()
Case -3
GUIDelete($Form2)
WinActivate($Form1)
ExitLoop
EndSwitch
Sleep(10)
WEnd
EndFunc

 

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