Sign in to follow this  
Followers 0
TehDag

Help with Child Window with this tab setup.

6 posts in this topic

Usual tag that i'm very new to this. I've read a ton of the help files and can normally find and then understand what i need through examples but I've hit a wall on this. It's either a bit above my understanding or I just need one of those oh yeah moments. I'm using a portion of Yashied's Simple tab code and that part works great.. I've got a GUI that i think looks amazing thanks to him/her and a bit of photoshop. The problem i'm running into though is getting Child windows to work with it. Specifically the closing of the window without closing both.

I can get Child windows to work fine in other GUI configs but i think it's the GUIGetMsg() call in tab code that is throwing me off. If i add the child code from the examples the tabs stop working. I've tried a few different ways. Any help that can be given would be greatly appreciated. Here is a basic code example of what i'm using. 

Here is a shell of what I'm working with. I had to remove the bulk of the info on the Tabs/Cases due to work related things.

#Include


#Include
#Include
#Include
#Include
#include
#include
#include
#include
#include
#include

Dim $Pic[3]

$hGUI1 = GUICreate("Gui 1", 410, 295)
GUISetBkColor(0xFFFFFF)
GUICtrlCreatePic(@ScriptDir & 'background.gif', 0, 0, 410, 295)
GUICtrlSetState(-1, $GUI_DISABLE)
$hPic_Servers = GUICtrlCreatePic(@ScriptDir& "logo.gif", 270, 252, 131, 35)
GUICtrlSetState(-1, $GUI_DISABLE)

For $t = 0 To 2
$Pic[$t] = GUICtrlCreatePic(@ScriptDir & 'BtnUP.gif', 0 + 86 * $t, 0, 87, 35)
$Pic0 = GUICtrlCreateLabel('Tab 1', 17, 8, 50, 18, $SS_CENTER)
GUICtrlSetFont(-1, 9, 400, 0, 'Tahoma')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetcolor(-1, 0xFFFFFF)

Next

GUICtrlCreateLabel('Tab 2', 103, 8, 50, 18, $SS_CENTER)
GUICtrlSetFont(-1, 9, 400, 0, 'Tahoma')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetcolor(-1, 0xFFFFFF)

GUICtrlCreateLabel('Tab 3', 181, 8, 70, 18, $SS_CENTER)
GUICtrlSetFont(-1, 9, 400, 0, 'Tahoma')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetcolor(-1, 0xFFFFFF)


$Tab = GUICtrlCreateTab(0 + 2, 50 + 2, 410 - 4, 245 - 4)
GUICtrlSetState(-1, $GUI_DISABLE)

; Tab 1 info here ***********************************************************************
GUICtrlCreateTabItem('Tab 1')
$DOH = GUICtrlCreateButton("Button 1", 95, 260, 75, 20)

; Tab 2 info here ***********************************************************************
GUICtrlCreateTabItem('Tab 2')


; Tab 3 info here ***********************************************************************
GUICtrlCreateTabItem('Tab 3')

GUICtrlCreateTabItem('')

GUISetState()

$Item = -1
$Over = -1

While 1
$Msg = GUIGetMsg()
If $Item = -1 Then
$Msg = $Pic[0]
$Item = 1
EndIf
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Pic[0] To $Pic[uBound($Pic) - 1]
If $Msg <> $Pic[$Item] Then
GUICtrlSetImage($Pic[$Item], @ScriptDir & 'BtnUP.gif')
GUICtrlSetcolor($Pic[$Item] + 1, 0xFFFFFF)
GUICtrlSetImage($Msg, @ScriptDir & 'BtnDN.gif')
GUICtrlSetcolor($Msg + 1, 0xFFFFFF)
$Item = _Index($Msg)
GUICtrlSendMsg($Tab, $TCM_SETCURFOCUS, $Item, 0)
$Over = -1
EndIf
Case $DOH
_gui2()
EndSwitch
WEnd

Func _Index($CtrlID)
For $t = 0 To UBound($Pic) - 1
If ($CtrlID = $Pic[$t]) Or ($CtrlID = $Pic[$t] + 1) Then
Return $t
EndIf
Next
Return -1
EndFunc ;==>_Index

Func _gui2()
$hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350)
GUISetState()
EndFunc ;==>gui2

Share this post


Link to post
Share on other sites



TehDag,

Have you read the Managing Multiple GUIs tutorial in the Wiki? That explains how to deal with child GUIs and prevent the "closing" error. ;)

Here is the basis of your code working as you want:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

Global $Pic[3]  ; Use explicit scope declarations
Global $hGUI2 = 9999

$hGUI1 = GUICreate("Gui 1", 410, 295)

$Tab = GUICtrlCreateTab(0 + 2, 50 + 2, 410 - 4, 245 - 4)
;GUICtrlSetState(-1, $GUI_DISABLE)

GUICtrlCreateTabItem('Tab 1')
$DOH = GUICtrlCreateButton("Button 1", 95, 260, 75, 20)

GUICtrlCreateTabItem('Tab 2')

GUICtrlCreateTabItem('Tab 3')

GUICtrlCreateTabItem('')

GUISetState()

While 1

    $aMsg = GUIGetMsg(1)

    Switch $aMsg[1]
        Case $hGUI1
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $Tab
                    ConsoleWrite("Tab selected: " & GUICtrlRead($Tab) & @CRLF)
                Case $DOH
                    GUICtrlSetState($DOH, $GUI_DISABLE)
                    _gui2()
            EndSwitch
        Case $hGUI2
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    GUIDelete($hGUI2)
                    $hGUI2 = 9999
                    GUICtrlSetState($DOH, $GUI_ENABLE)
            EndSwitch
    EndSwitch
WEnd


Func _gui2()
    $hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350)
    GUISetState()
EndFunc   ;==>_gui2
I removed a lot of code as I had no idea what you wanted it to do - if you can explain we should be able to produce some less complicated code in its place. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

Hello Melba23! First, thank you for your time. I can get the child window to work with that code from the help file as well if i remove the other stuff. but that other code removed is what is making the tab's in my GUI work. It has a Skin of sorts that allows me to choose a up-down pic, etc. 

Here is what the code does: '?do=embed' frameborder='0' data-embedContent>> - I've just modified it to be horizontal and no hover over stuff. I don't think i have the ability to attach a file so you have the gif's to see what it looks like when it works. but the tabs at the top have a up and sunken button graphic. which changes when you click each tab.

I read the wiki before posting and tried a couple versions form the examples. It seems once i interact with the GUIGETMSG portion it breaks the Tabs because it is also using that. I've tried as an array and also by trying to use a second variable.

Thanks Again.

Share this post


Link to post
Share on other sites

TehDag,

Apologies, I forgot to welcome you to the forum earlier - better late then never! :D

Here is Yashied's example modified to run a child GUI using the advanced GUIGetMsg - works alright for me:

#Include <Constants.au3>
#Include <GUIConstantsEx.au3>
#Include <StaticConstants.au3>
#Include <TabConstants.au3>
#Include <WindowsConstants.au3>

Dim $Pic[5]
Global $hGUI_Child = 9999

$hGUI_Main = GUICreate('MyGUI', 705, 369)
GUISetBkColor(0xFFFFFF)
GUICtrlCreatePic('img_bg.bmp', 0, 0, 705, 369)
GUICtrlSetState(-1, $GUI_DISABLE)

For $i = 0 To 4
    $Pic[$i] = GUICtrlCreatePic(@ScriptDir & '\img_black.bmp', 10, 24 + 50 * $i, 162, 49)
    GUICtrlCreateLabel('Tabsheet' & $i, 21, 40 + 50 * $i, 140, 18, $SS_CENTER)
    GUICtrlSetFont(-1, 11, 400, 0, 'Tahoma')
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetcolor(-1, 0xFFFFFF)
Next

$Tab = GUICtrlCreateTab(172 + 4, 10 + 4, 523 - 8, 349 - 8)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateTabItem('Tabsheet0')
GUICtrlCreateEdit('', 190, 28, 487, 313)
GUICtrlCreateTabItem('Tabsheet1')
$cOK = GUICtrlCreateButton('OK', 398, 319, 70, 23)
GUICtrlCreateTabItem('Tabsheet2')
GUICtrlCreateTabItem('Tabsheet3')
GUICtrlCreateTabItem('Tabsheet4')
GUICtrlCreateTabItem('')

GUISetState()

$Item = -1
$Over = -1

While 1
    $Info = GUIGetCursorInfo()
    If @error Then
        If $Over <> -1 Then
            GUICtrlSetImage($Pic[$Over], @ScriptDir & '\img_black.bmp')
        EndIf
        $Over = -1
    Else
        $Index = _Index($Info[4])
        If $Index <> $Over Then
            If $Over <> -1 Then
                GUICtrlSetImage($Pic[$Over], @ScriptDir & '\img_black.bmp')
            EndIf
            If ($Index <> -1) And ($Index <> $Item) Then
                GUICtrlSetImage($Pic[$Index], @ScriptDir & '\img_over.bmp')
                $Over = $Index
            Else
                $Over = -1
            EndIf
        EndIf
    EndIf
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        Case $hGUI_Main
            If $Item = -1 Then
                $aMsg[0] = $Pic[0]
                $Item = 1
            EndIf
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $cOK
                    GUICtrlSetState($cOK, $GUI_DISABLE)
                    $hGUI_Child = GUICreate("Gui 2", 200, 200, 350, 350)
                    GUISetState()
                Case $Pic[0] To $Pic[UBound($Pic) - 1]
                    If $aMsg[0] <> $Pic[$Item] Then
                        GUICtrlSetImage($Pic[$Item], @ScriptDir & '\img_black.bmp')
                        GUICtrlSetcolor($Pic[$Item] + 1, 0xFFFFFF)
                        GUICtrlSetImage($aMsg[0], @ScriptDir & '\img_white.bmp')
                        GUICtrlSetcolor($aMsg[0] + 1, 0x313A42)
                        $Item = _Index($aMsg[0])
                        GUICtrlSendMsg($Tab, $TCM_SETCURFOCUS, $Item, 0)
                        $Over = -1
                    EndIf
            EndSwitch
        Case $hGUI_Child
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    GUIDelete($hGUI_Child)
                    GUICtrlSetState($cOK, $GUI_ENABLE)
            EndSwitch
    EndSwitch

WEnd

Func _Index($CtrlID)
    For $i = 0 To UBound($Pic) - 1
        If ($CtrlID = $Pic[$i]) Or ($CtrlID = $Pic[$i] + 1) Then
            Return $i
        EndIf
    Next
    Return -1
EndFunc   ;==>_Index
How about you? Please ask if you have any questions. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

No problem and Thank you, I've lurked for quite a while. I've learned from and used a lot of your examples.

That is beautiful.. I see where i was failing now. My switch work was a bit off and i had missed the [0] calls in one of the cases. I have a much better understanding on how the GUIGetMsg(1) works with the [] and where in relation to the switches.  Thanks again you have helped greatly!

Share this post


Link to post
Share on other sites

TehDag,

Glad I could help. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

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
Sign in to follow this  
Followers 0