TehDag Posted January 18, 2014 Share Posted January 18, 2014 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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 18, 2014 Moderators Share Posted January 18, 2014 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:expandcollapse popup#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 ;==>_gui2I 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
TehDag Posted January 18, 2014 Author Share Posted January 18, 2014 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. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 18, 2014 Moderators Share Posted January 18, 2014 TehDag,Apologies, I forgot to welcome you to the forum earlier - better late then never! Here is Yashied's example modified to run a child GUI using the advanced GUIGetMsg - works alright for me:expandcollapse popup#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 ;==>_IndexHow 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
TehDag Posted January 18, 2014 Author Share Posted January 18, 2014 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! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 18, 2014 Moderators Share Posted January 18, 2014 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now