Moderators big_daddy Posted August 14, 2008 Moderators Posted August 14, 2008 (edited) How can I create a statusbar that only shows up on one tab? If I place the statusbar code below GUICtrlCreateTabItem("") it shows up, but on both tabs and that's not what I'm wanting. expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StatusBarConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <GuiTab.au3> Opt("GUIOnEventMode", 1) $Form1 = GUICreate("", 633, 447, 193, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem2 = GUICtrlCreateMenuItem("New", $MenuItem1) $Tab1 = GUICtrlCreateTab(0, 0, 632, 426) $hTab = GUICtrlGetHandle($Tab1) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("1") $Group1 = GUICtrlCreateGroup("1", 9, 30, 330, 210) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("2", 344, 30, 275, 210) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("3", 10, 245, 610, 170) GUICtrlCreateGroup("", -99, -99, 1, 1) $TabSheet2 = GUICtrlCreateTabItem("2") $ListView1 = GUICtrlCreateListView("1|2", 4, 25, 622, 375, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $ListView1_0 = GUICtrlCreateListViewItem("Item 1|Item 1-1", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("Item 2|Item 2-1", $ListView1) $StatusBar1 = _GUICtrlStatusBar_Create($Form1) Dim $StatusBar1_PartsWidth[2] = [150, -1] _GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth) _GUICtrlStatusBar_SetText($StatusBar1, " Panel 1", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Panel 2", 1) _GUICtrlStatusBar_ShowHide($StatusBar1, @SW_HIDE) GUICtrlCreateTabItem("") GUICtrlSetState($TabSheet1, $GUI_SHOW) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Sleep(50) WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTab, $fValid $hWndTab = $hTab $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndTab Switch $iCode Case $TCN_SELCHANGE If _GUICtrlTab_GetCurSel($hTab) = 1 Then ; zero based index of current selected TabItem _GUICtrlStatusBar_ShowHide($StatusBar1, @SW_SHOW) Else _GUICtrlStatusBar_ShowHide($StatusBar1, @SW_HIDE) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _Exit() Exit EndFunc ;==>_Exit Edited August 14, 2008 by big_daddy
ReFran Posted August 14, 2008 Posted August 14, 2008 $StatusBar1 = _GUICtrlStatusBar_Create($Form1_1)Mmmh,you create the statusBar on the mainGui.I would create sunken Labels on the tab as own created statusbar,or use Tab on Tab with different GUIs if I want to use _GUICtrlStatusBar_Create().http://www.autoitscript.com/forum/index.ph...st&p=473877HTH, Reinhard
Zedna Posted August 14, 2008 Posted August 14, 2008 Look here: http://www.autoitscript.com/forum/index.ph...mp;#entry531772Instead of _GUICtrlIpAddress() use _GUICtrlStatusBarShowHide() Resources UDF ResourcesEx UDF AutoIt Forum Search
Zedna Posted August 14, 2008 Posted August 14, 2008 Also main problem: GUICtrlCreateMenu() must be BEFORE _GUICtrlStatusBar_Create() expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StatusBarConstants.au3> #include <TabConstants.au3> #include <GuiTab.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> Opt("GUIOnEventMode", 1) $Form1_1 = GUICreate("", 633, 447, 193, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $MenuItem1 = GUICtrlCreateMenu("&File") $MenuItem2 = GUICtrlCreateMenuItem("New", $MenuItem1) $Tab1 = GUICtrlCreateTab(0, 0, 632, 406) $hTab = GUICtrlGetHandle($Tab1) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("1") $Group1 = GUICtrlCreateGroup("1", 9, 30, 330, 210) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("2", 344, 30, 275, 210) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("3", 10, 245, 610, 150) GUICtrlCreateGroup("", -99, -99, 1, 1) $TabSheet2 = GUICtrlCreateTabItem("2") ;~ $TabSheet2_hwnd = GUICtrlGetHandle($TabSheet2) $ListView1 = GUICtrlCreateListView("1|2", 4, 25, 622, 375, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $ListView1_0 = GUICtrlCreateListViewItem("Item 1|Item 1-1", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("Item 2|Item 2-1", $ListView1) GUICtrlCreateTabItem("") $StatusBar1 = _GUICtrlStatusBar_Create($Form1_1) Dim $StatusBar1_PartsWidth[2] = [150, -1] _GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth) _GUICtrlStatusBar_SetText($StatusBar1, " Panel 1", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Panel 2", 1) _GUICtrlStatusBar_ShowHide($StatusBar1 , @SW_HIDE) GUICtrlSetState($TabSheet1, $GUI_SHOW) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Sleep(50) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTab, $fValid $hWndTab = $hTab $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndTab Switch $iCode Case $TCN_SELCHANGE If _GUICtrlTab_GetCurSel($hTab) = 1 Then ; zero based index of current selected TabItem _GUICtrlStatusBar_ShowHide($StatusBar1 , @SW_SHOW) Else _GUICtrlStatusBar_ShowHide($StatusBar1 , @SW_HIDE) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Resources UDF ResourcesEx UDF AutoIt Forum Search
Moderators big_daddy Posted August 14, 2008 Author Moderators Posted August 14, 2008 That did it! Thank you for your help. I updated the first post with the code that does exactly what I was looking for.
ReFran Posted August 14, 2008 Posted August 14, 2008 (edited) Oh, I thought you meant statusbar "on tab". Attached a quick example. You may keep it for later. Best regards, Reinhard expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StatusBarConstants.au3> #include <TabConstants.au3> #include <GuiTab.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> Global $main_GUI,$ok_button,$cancel_button ; This window has 2 ok/cancel-buttons $main_GUI = GUICreate("Stab on TAB",260,250,-1,-1) $ok_button = GUICtrlCreateButton("OK",40,220,70,20) $cancel_button = GUICtrlCreateButton("Cancel",150,220,70,20) ; Create the first child window that is implemented into the main GUI $child1 = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI) $StatusBar1 = _GUICtrlStatusBar_Create($Child1) Dim $StatusBar1_PartsWidth[2] = [150, -1] _GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth) _GUICtrlStatusBar_SetText($StatusBar1, " Panel 1", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Panel 2", 1) GUISetState() ; Create the second child window that is implemented into the main GUI $child2 = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI) $listview2 = GUICtrlCreateListView("Col1|Col2",10,10,210,150,-1,$WS_EX_CLIENTEDGE) GUICtrlCreateListViewItem("ItemLong1|ItemLong12", $listview2) GUICtrlCreateListViewItem("ItemLong2|Item22", $listview2) ; Switch back the main GUI and create the tabs GUISwitch($main_GUI) $main_tab = GUICtrlCreateTab(10,10,240,200) $child1tab = GUICtrlCreateTabItem("Child1") $child2tab = GUICtrlCreateTabItem("Child2") GUICtrlCreateTabItem("") DIM $tabItemLast = 0 GUISetState() While 1 $msg = GUIGetMsg(1) Switch $msg[0] Case $GUI_EVENT_CLOSE, $cancel_button ExitLoop Case $main_tab $tabItem = GUICtrlRead($main_Tab) if $tabItem <> $tabItemLast then TabSwitch($tabItem) EndSwitch WEnd func TabSwitch($tabItem) GUISetState(@SW_HIDE,$child1) GUISetState(@SW_HIDE,$child2) if $tabItem = 0 then GUISetState(@SW_SHOW,$child1) if $tabItem = 1 then GUISetState(@SW_SHOW,$child2) $tabItemLast = $tabItem EndFunc Edited August 14, 2008 by ReFran
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