Jump to content
Reza10101

How to make parent & child window?

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

 

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites
Posted (edited)
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.
  :)

Share this post


Link to post
Share on other sites

@Jos You are absolutely right! I'm not an abuser bro ☹️ I never create a gui before like that and I don't have enough experience about parent and child windows. I 'm also studing the wiki... But I still haven't reached a conclusion.

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Hi @Reza10101, nice to meet you iranian boy :)

You can also use Koda Form Designer to create gui forms and easily set child window and etc.


I recommend to you to get COVID-19, but don't get Wife

Share this post


Link to post
Share on other sites
4 hours ago, Jos said:

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

those are some cheap prices... lol, I was thinking 250 per


My resources are limited. You must ask the right questions

 

Share this post


Link to post
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

 

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...