Floppy Posted December 15, 2012 Share Posted December 15, 2012 Hi,is it possible to create TabItems with close button? (like firefox/chrome tabs)I need them because I'm creating a web browser Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 15, 2012 Moderators Share Posted December 15, 2012 Floppy, Yes - you can create and delete tabs in the same way as any other control. 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...
Floppy Posted December 16, 2012 Author Share Posted December 16, 2012 Melba, how do I put the close button in every tab? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 16, 2012 Moderators Share Posted December 16, 2012 Floppy,You put a "Close" button in each tab - then the script knows which tab to close. Or you have a "Close button outside the tab structure and then close the active tab when it is pressed. Either will work - I tested before replying yesterday. 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...
Floppy Posted December 16, 2012 Author Share Posted December 16, 2012 Maybe I don't made myself clear. I want a Close button inside each tabitem header (like that red X in Firefox or Chrome tabs). Is possible to do that thing? Link to comment Share on other sites More sharing options...
Floppy Posted December 19, 2012 Author Share Posted December 19, 2012 Is possible? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2012 Moderators Share Posted December 19, 2012 Floppy, How about this: expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiTab.au3> #include <StaticConstants.au3> #include <Array.au3> Global $aTab[5] = [4] $hGUI = GUICreate("Test", 500, 500) $cCloseX = GUICtrlCreateLabel("X", 0, 0, 1, 1, BitOR($SS_NOTIFY, $SS_CENTER, $SS_SUNKEN)) GUICtrlSetBkColor($cCloseX, 0xFF8080) $cTab = GUICtrlCreateTab(5, 5, 390, 260) $hTab = GUICtrlGetHandle($cTab) For $i = 1 To $aTab[0] $aTab[$i] = GUICtrlCreateTabItem("Tab item - " & $i & " - X") Next GUICtrlCreateTabItem("") TabEvent() GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cTab TabEvent() Case $cCloseX $iIndex = GUICtrlRead($cTab) + 1 GUICtrlDelete($aTab[$iIndex]) _ArrayDelete($aTab, $iIndex) $aTab[0] -= 1 If $aTab[0] Then GUICtrlSetState($cCloseX, $GUI_SHOW) Else GUICtrlSetState($cCloseX, $GUI_HIDE) EndIf EndSwitch WEnd Func TabEvent() Local $iMargin_X = 6, $iMargin_Y = 6 $iTab_Index = _GUICtrlTab_GetCurSel($hTab) $aTab_Coord = _GUICtrlTab_GetItemRect($hTab, $iTab_Index) $iOffset = $aTab_Coord[2] - $aTab_Coord[0] - 20 GUICtrlSetPos($cCloseX, $iMargin_X + $aTab_Coord[0] + $iOffset, $iMargin_Y + $aTab_Coord[1], 20, $aTab_Coord[3] - $aTab_Coord[1] - 2) _GUICtrlTab_SetCurFocus(GUICtrlGetHandle($cTab), $iTab_Index) EndFunc ;==>TabEvent Any use? M23 Floppy 1 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...
Floppy Posted December 19, 2012 Author Share Posted December 19, 2012 Melba you're amazing!! This concept is very very smart!! However I discovered a bug. If I close the last tab, the last red X doesn't hide itself. Another thing: It's possible to put the red X in every tabitem (not just only in the active tabitem), detect the clicked X, and simply close the matching tabitem? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2012 Moderators Share Posted December 19, 2012 Floppy, If I close the last tab, the last red X doesn't hide itselfIt should - I added this section of code to do just that: If $aTab[0] Then GUICtrlSetState($cCloseX, $GUI_SHOW) Else GUICtrlSetState($cCloseX, $GUI_HIDE) EndIf and it does hide it when I test. As to adding a red "X" to each tab - I imagine you could rework the code I posted to do something like that. Perhaps you could try first and see how you get on. 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...
Andreik Posted December 19, 2012 Share Posted December 19, 2012 I added just a call of TabEvent() to prevent the bug reported by Floppy. expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiTab.au3> #include <StaticConstants.au3> #include <Array.au3> Global $aTab[5] = [4] $hGUI = GUICreate("Test", 500, 500) $cCloseX = GUICtrlCreateLabel("X", 0, 0, 1, 1, BitOR($SS_NOTIFY, $SS_CENTER, $SS_SUNKEN)) GUICtrlSetBkColor($cCloseX, 0xFF8080) $cTab = GUICtrlCreateTab(5, 5, 390, 260) $hTab = GUICtrlGetHandle($cTab) For $i = 1 To $aTab[0] $aTab[$i] = GUICtrlCreateTabItem("Tab item - " & $i & " - X") Next GUICtrlCreateTabItem("") TabEvent() GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cTab TabEvent() Case $cCloseX $iIndex = GUICtrlRead($cTab) + 1 GUICtrlDelete($aTab[$iIndex]) _ArrayDelete($aTab, $iIndex) $aTab[0] -= 1 If $aTab[0] Then GUICtrlSetState($cCloseX, $GUI_SHOW) Else GUICtrlSetState($cCloseX, $GUI_HIDE) EndIf TabEvent() EndSwitch WEnd Func TabEvent() Local $iMargin_X = 6, $iMargin_Y = 6 $iTab_Index = _GUICtrlTab_GetCurSel($hTab) $aTab_Coord = _GUICtrlTab_GetItemRect($hTab, $iTab_Index) $iOffset = $aTab_Coord[2] - $aTab_Coord[0] - 20 GUICtrlSetPos($cCloseX, $iMargin_X + $aTab_Coord[0] + $iOffset, $iMargin_Y + $aTab_Coord[1], 20, $aTab_Coord[3] - $aTab_Coord[1] - 2) _GUICtrlTab_SetCurFocus(GUICtrlGetHandle($cTab), $iTab_Index) EndFunc ;==>TabEvent When the words fail... music speaks. 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