guwguw Posted February 25, 2013 Share Posted February 25, 2013 (edited) When using multiple tabs, I am not capable to make the status bar information change accordingly. Based on Autoit's help system's GUICtrlCreateTab example I tried the following expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <Date.au3> Example() Func Example() Local $msg, $StatusBar1 Local $a_PartsRightEdge[5] = [50, 150, 220, 280, 300] Local $a_PartsText[5] = [" Info", "Details", "some data", _NowCalcDate(), " date+5= " & _DateAdd('d', 5, _NowCalcDate())] $topWindow = GUICreate("My GUI Tab") ; will create a dialog box that when displayed is centered GUISetBkColor(0x00E0FFFF) GUISetFont(9, 300) $tab0 = GUICtrlCreateTab(10, 10, 200, 100) GUICtrlCreateTabItem("tab0") GUICtrlCreateLabel("label0", 30, 80, 50, 20) GUICtrlCreateButton("OK0", 20, 50, 50, 20) GUICtrlCreateInput("default", 80, 50, 70, 20) $tab1 = GUICtrlCreateTabItem("tab----1") GUICtrlCreateLabel("label1", 30, 80, 50, 20) GUICtrlCreateCombo("", 20, 50, 60, 120) GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon GUICtrlCreateButton("OK1", 80, 50, 50, 20) $tab2 = GUICtrlCreateTabItem("tab2") GUICtrlSetState(-1, $GUI_SHOW) ; will be display first GUICtrlCreateLabel("label2", 30, 80, 50, 20) GUICtrlCreateButton("OK2", 140, 50, 50) GUICtrlCreateTabItem("") ; end tabitem definition GUICtrlCreateLabel("label3", 20, 130, 50, 20) GUISetState() $StatusBarmain = _GUICtrlStatusBar_Create($topWindow, $a_PartsRightEdge, $a_PartsText) $StatusBar0 = _GUICtrlStatusBar_Create($tab0, $a_PartsRightEdge, $a_PartsText) $StatusBar1 = _GUICtrlStatusBar_Create($tab1, $a_PartsRightEdge, $a_PartsText) $StatusBar2 = _GUICtrlStatusBar_Create($tab2, $a_PartsRightEdge, $a_PartsText) _GUICtrlStatusBar_SetText($tab0, "Part 0", 2) _GUICtrlStatusBar_SetText($tab1, "Part 11", 2) _GUICtrlStatusBar_SetText($tab2, "Part 222", 2) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>Example What is the proper way of changing the bar text when the new tab gets focus? (if there is any, lol) Currently, only the $StatusBarmain can be altered ... Edited February 25, 2013 by guwguw Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 25, 2013 Moderators Share Posted February 25, 2013 guwguw, You cannot have a statusbar inside each tab - they are not GUIs. But you could have a child GUI just underneath the tab and show the statusbar associated with the selected tab like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <Date.au3> Example() Func Example() Local $msg, $StatusBar1 $topWindow = GUICreate("My GUI Tab", 500, 500) ; will create a dialog box that when displayed is centered GUISetBkColor(0x00E0FFFF) GUISetFont(9, 300) $cTab = GUICtrlCreateTab(10, 10, 480, 200) $tab0 = GUICtrlCreateTabItem("Tab 0") GUICtrlCreateLabel("label0", 30, 80, 50, 20) GUICtrlCreateButton("OK0", 20, 50, 50, 20) GUICtrlCreateInput("default", 80, 50, 70, 20) $tab1 = GUICtrlCreateTabItem("tab 1") GUICtrlCreateLabel("label1", 30, 80, 50, 20) GUICtrlCreateCombo("", 20, 50, 60, 120) GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon GUICtrlCreateButton("OK1", 80, 50, 50, 20) $tab2 = GUICtrlCreateTabItem("Tab 2") GUICtrlSetState(-1, $GUI_SHOW) ; will be display first GUICtrlCreateLabel("label2", 30, 80, 50, 20) GUICtrlCreateButton("OK2", 140, 50, 50) GUICtrlCreateTabItem("") ; end tabitem definition Local $a_PartsRightEdge[5] = [50, 150, 220, 300, 300] Local $a_PartsText[5] = [" Info", "Details", "some data", _NowCalcDate(), " date+5= " & _DateAdd('d', 5, _NowCalcDate())] $StatusBarmain = _GUICtrlStatusBar_Create($topWindow, $a_PartsRightEdge, $a_PartsText) GUISetState() $hGUI_tab = GUICreate("Tab status", 476, 20, 0, 0, BitOr($WS_BORDER, $WS_POPUP), $WS_EX_MDICHILD, $topWindow) GUISetBkColor(0xFF0000) $aMain_Pos = WinGetPos($topWindow) WinMove($hGUI_tab, "", $aMain_Pos[0] + 13, $aMain_Pos[1] + 232) GUISetState() $StatusBar0 = _GUICtrlStatusBar_Create($hGUI_tab, $a_PartsRightEdge, $a_PartsText) $StatusBar1 = _GUICtrlStatusBar_Create($hGUI_tab, $a_PartsRightEdge, $a_PartsText) ControlHide($hGUI_tab, "", $StatusBar1) $StatusBar2 = _GUICtrlStatusBar_Create($hGUI_tab, $a_PartsRightEdge, $a_PartsText) ControlHide($hGUI_tab, "", $StatusBar1) _GUICtrlStatusBar_SetText($StatusBar0, "Part 0", 2) _GUICtrlStatusBar_SetText($StatusBar1, "Part 11", 2) _GUICtrlStatusBar_SetText($StatusBar2, "Part 222", 2) ; Run the GUI until the dialog is closed While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cTab Switch GUICtrlRead($cTab) Case 0 ControlShow($hGUI_tab, "", $StatusBar0) ControlHide($hGUI_tab, "", $StatusBar1) ControlHide($hGUI_tab, "", $StatusBar2) Case 1 ControlHide($hGUI_tab, "", $StatusBar0) ControlShow($hGUI_tab, "", $StatusBar1) ControlHide($hGUI_tab, "", $StatusBar2) Case 2 ControlHide($hGUI_tab, "", $StatusBar0) ControlHide($hGUI_tab, "", $StatusBar1) ControlShow($hGUI_tab, "", $StatusBar2) EndSwitch EndSwitch WEnd EndFunc ;==>Example I hope that is a suitable solution. Please ask if you have any questions about the code. 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...
guwguw Posted February 25, 2013 Author Share Posted February 25, 2013 guwguw,You cannot have a statusbar inside each tab - they are not GUIs. But you could have a child GUI just underneath the tab and show the statusbar associated with the selected tab like this: Thanks, Melba!At least my ignorance (inability to find the proper context) was justified. Ultimately, your solution looks quite acceptable - way better than a frozen status bar, lol.Thanks for the help! Link to comment Share on other sites More sharing options...
sentry07 Posted February 26, 2013 Share Posted February 26, 2013 Alternatively, use a function to set your status bar text. Pass in the tab number as one of the parameters of the function and store the text in a global array using the tab number as the index. Then when you switch tabs and call the function to show or hide UI elements, just set the statusbar text along with it. 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