Jump to content

How to set active child GUI


Recommended Posts

Hi every one

Same with title, Help me set active Child GUI

how to set GUI1 is Active when i click "menu file/form1" (if form1 is hiding,minimized,maximized,deactived)
how to set GUI2 is Active when i click "menu file/form2" (if form2 is hiding,minimized,maximized,deactived)

 

Here my autoit code :

#include <GUIConstants.au3>

;---------------------------------------------------
Global $title = "Main"
Global $BgColor = 0x000000
Global $TextColor = 0xFFFFFF
Global $FontName = "Segoe UI"
Global $FontSide = 11
;---------------------------------------------------
Global $FormMain            = GUICreate( $title, 1200, 650, -1, -1, BitOR($WS_SYSMENU, $WS_MINIMIZEBOX,$WS_MAXIMIZEBOX))

Global $FormFile        = GUICtrlCreateMenu("&File")
    Global $Menu1   = GUICtrlCreateMenuItem("Form&1", $FormFile)
    Global $Menu2   = GUICtrlCreateMenuItem("Form&2", $FormFile)
    GUICtrlCreateMenuItem("", $FormFile, 4)
    Global $MenuExit        = GUICtrlCreateMenuItem("&Exit", $FormFile)

Global $Form1       = GUICreate( "Form1", 800, 500, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_MAXIMIZEBOX,$WS_BORDER,$WS_CAPTION,$WS_CHILD), -1, $FormMain)
    GUISetState(@SW_HIDE, $Form1)

Global $Form2       = GUICreate( "Form2", 800, 500, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_MAXIMIZEBOX,$WS_BORDER,$WS_CAPTION,$WS_CHILD), -1, $FormMain)
    GUISetState(@SW_HIDE, $Form2)

GUISetState(@SW_SHOW, $FormMain)

Global $MSG
While 1
    $MSG = GUIGetMsg(1)
    Switch $MSG[1]
        Case $FormMain
            Switch $MSG[0]
                Case $GUI_EVENT_CLOSE, $MenuExit
                    if MsgBox( 4, "MSG", "Quit ? ", 0, $FormMain) = 6 Then ExitLoop
                Case $Menu1
                    Child_Show($Form1)
                Case $Menu2
                    Child_Show($Form2)
            EndSwitch
        Case $Form1
            Switch $MSG[0]
                Case $GUI_EVENT_CLOSE
                    GUISetState(@SW_HIDE, $Form1)
            EndSwitch
        Case $Form2
            Switch $MSG[0]
                Case $GUI_EVENT_CLOSE
                    GUISetState(@SW_HIDE, $Form2)
            EndSwitch
    EndSwitch
WEnd

Func Child_Show($CID)
    Local $Status = WinGetState($CID)
    Switch $Status
        Case 5  ; Hiding
            GUISetState ( @SW_SHOW, $CID )
        Case 21 ; Hiding and MINIMIZED
            GUISetState ( @SW_SHOW , $CID )
        Case 37 ; Hiding and MAXIMIZED
            GUISetState ( @SW_SHOW , $CID )

        Case 7 ; Showing
            GUISetState ( @SW_SHOWNORMAL, $CID )
        Case 39 ; Showing and MAXIMIZED
            GUISetState ( @SW_RESTORE, $CID )
        Case 23 ; Showing and MINIMIZED
            GUISetState ( @SW_SHOWNORMAL, $CID )

        Case Else
    EndSwitch
EndFunc

 

Link to comment
Share on other sites

@123disconnect

Maybe:

Case $Menu1
    Child_Show($Form1)
    GUISetState ( @SW_HIDE, $Form2)
    GUISetState ( @SW_SHOW, $Form1)
Case $Menu2
    Child_Show($Form2)
    GUISetState ( @SW_HIDE, $Form1)
    GUISetState ( @SW_SHOW, $Form2)

 

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

@123disconnect

Yeah right, but you can form an array on that to make it short and some conditions to make it hidden and shown.^_^

For now, I'm on leave for Holidays so maybe when I came back I'll check on this later next week.

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

@123disconnect,

Sorry for the very late response, kind of busy right now in the office. Well, try below. Not sure if this is what you want.:sweating:

#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#Include <Array.au3>
#include <File.au3>

;---------------------------------------------------
Global $title = "Main"
Global $BgColor = 0x000000
Global $TextColor = 0xFFFFFF
Global $FontName = "Segoe UI"
Global $FontSide = 11
;---------------------------------------------------
Global $ChildGUI = 4, $iTem = 4
Global $Form[$ChildGUI]
Global $Menu[$iTem]

Global $FormMain            = GUICreate( $title, 1200, 650, -1, -1, BitOR($WS_SYSMENU, $WS_MINIMIZEBOX,$WS_MAXIMIZEBOX))
Global $FormFile        = GUICtrlCreateMenu("&File")
GUICtrlCreateMenuItem("", $FormFile, 4)

Global $MenuExit = GUICtrlCreateMenuItem("&Exit", $FormFile)

GUISetState(@SW_SHOW, $FormMain)

Global $MSG

For $x = 1 To $iTem - 1
   $Menu[$x] = GUICtrlCreateMenuItem("Form " & $x, $FormFile)
Next

For $i = 1 To $ChildGUI - 1
   $Form[$i] = GUICreate( "Form " & $i, 800, 500, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_MAXIMIZEBOX,$WS_BORDER,$WS_CAPTION,$WS_CHILD), -1, $FormMain)
   GUISetState(@SW_HIDE, $Form[$i])
Next

While 1
    $MSG = GUIGetMsg(1)
    Switch $MSG[1]
      Case $FormMain
         Switch $MSG[0]
            Case $GUI_EVENT_CLOSE, $MenuExit
               if MsgBox( 4, "MSG", "Quit ? ", 0, $FormMain) = 6 Then ExitLoop
               Case $Menu[1]
                Child_Show($Form[1])
                GUISetState(@SW_HIDE, $Form[2])
                GUISetState(@SW_HIDE, $Form[3])
                GUISetState(@SW_SHOW, $Form[1])
               Case $Menu[2]
                 Child_Show($Form[2])
                 GUISetState(@SW_HIDE, $Form[1])
                 GUISetState(@SW_HIDE, $Form[3])
                 GUISetState(@SW_SHOW, $Form[2])
                Case $Menu[3]
                  Child_Show($Form[3])
                  GUISetState(@SW_HIDE, $Form[1])
                  GUISetState(@SW_HIDE, $Form[2])
                  GUISetState(@SW_SHOW, $Form[3])
            EndSwitch
    EndSwitch
WEnd

Func Child_Show($CID)
    Local $Status = WinGetState($CID)
    Switch $Status
        Case 5  ; Hiding
            GUISetState ( @SW_SHOW, $CID)
        Case 21 ; Hiding and MINIMIZED
            GUISetState ( @SW_SHOW , $CID )
        Case 37 ; Hiding and MAXIMIZED
            GUISetState ( @SW_SHOW , $CID )

        Case 7 ; Showing
            GUISetState ( @SW_SHOWNORMAL, $CID )
        Case 39 ; Showing and MAXIMIZED
            GUISetState ( @SW_RESTORE, $CID )
        Case 23 ; Showing and MINIMIZED
            GUISetState ( @SW_SHOWNORMAL, $CID )

        Case Else
    EndSwitch
EndFunc

Creating multiple GUI is done by the below code:

For $i = 1 To $ChildGUI - 1
   $Form[$i] = GUICreate( "Form " & $i, 800, 500, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_MAXIMIZEBOX,$WS_BORDER,$WS_CAPTION,$WS_CHILD), -1, $FormMain)
   GUISetState(@SW_HIDE, $Form[$i])
Next

This what I've got so far for you, maybe there are other pep'z here that can help you more.^_^

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

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