Sign in to follow this  
Followers 0
Jayson

Deleting stuff from tab

20 posts in this topic

#1 ·  Posted (edited)

Hi, I'm trying to create a program which use tabs and i'm kinda stuck.

I'm creating tabs with edit/input in it. When it comes to delete the tab everything works great but i can't figure out how to delete the edit/input associated with that tab.

Here's my code :

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>

GUICreate("Tabbing", 528, 351, 193, 125)

$NewTabButton = GUICtrlCreateButton("+", 475, 10, 50, 20)
$DelTabButton = Guictrlcreatebutton("-",420,10,50,20)

$Tab = GUICtrlCreateTab(16, 116, 497, 200)
GUICtrlCreateTabItem("1")

$Input = GUICtrlCreateInput("1", 32, 150, 121, 21)

GUISetState()

$TabID = 1

While 1

    Switch GUIGetMsg()

    Case $DelTabButton
        MsgBox(4160, "Information", "Deleting tab focus: " & _GUICtrlTab_GetCurFocus($Tab))
        $DelTab = _GUICtrlTab_GetCurFocus($Tab)
        _GUICtrlTab_DeleteItem($Tab, $DelTab)

    Case $NewTabButton
    GUICtrlCreateTabItem($TabID + 1)
    $Input1 = GUICtrlCreateInput($TabID + 1, 32, 150, 121, 21)
        GUICtrlCreateTabItem("")
    $TabID = $TabID + 1

    Case $GUI_EVENT_CLOSE
 Exit

    EndSwitch

WEnd

Sorry for the double post, my browser crashed and messed up everything ;)

Edited by Jayson

Share this post


Link to post
Share on other sites



Look in the help file.

Functions >> GUI Management >> GUI Control Creation >> GUICtrlDelete()

Actually that's a ridiculous place for it but that's where it is.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

That solution don't work because there's many $Input1 created when adding tab and i can't find a way to get the right one to delete with the tab with this.

Share this post


Link to post
Share on other sites

Jayson,

i can't find a way to get the right one to delete with the tab

Just use arrays to hold the ControlIDs: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

Global $aTab[2] = [0]
Global $aInput[2]

GUICreate("Tabbing", 528, 351, 193, 125)

$NewTabButton = GUICtrlCreateButton("+", 475, 10, 50, 20)
$DelTabButton = GUICtrlCreateButton("-", 420, 10, 50, 20)

$Tab = GUICtrlCreateTab(16, 116, 497, 200)

_AddTab()

GUISetState()

$TabID = 1

While 1

    Switch GUIGetMsg()

        Case $DelTabButton
            _DelTab()

        Case $NewTabButton
            _AddTab()

        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch

WEnd

Func _AddTab()

    $aTab[0] += 1
    ReDim $aTab[$aTab[0] + 1]
    $aTab[$aTab[0]] = GUICtrlCreateTabItem($aTab[0])
    ReDim $aInput[$aTab[0] + 1]
    $aInput[$aTab[0]] = GUICtrlCreateInput($aTab[0], 32, 150, 121, 21)
    GUICtrlCreateTabItem("")

EndFunc

Func _DelTab()

    $DelTab = GUICtrlRead($Tab) + 1
    GUICtrlDelete($aInput[$DelTab])
    _ArrayDelete($aInput, $DelTab)
    GUICtrlDelete($aTab[$DelTab])
    _ArrayDelete($aTab, $DelTab)

EndFunc

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

Oh ! TY very much Melba ! I tried with arrays but i wasn't sure how to make it work correctly. Btw what does do the [0] in $aTab[2] = [0] ?

Share this post


Link to post
Share on other sites

Jayson,

It sets the [0] element of the array to 0 on declaration to act as a counter so that we get the next tab and input in the next element of their respective arrays. ;)

Are you adding and/or deleting many tabs? Because if so we might need to look at a bit more complex code to keep the arrays to a reasonable size. :)

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

#7 ·  Posted (edited)

Ok, thank for the explanation ;)

Yes, the user might adding/deleting up to 30 tabs.

Edited by Jayson

Share this post


Link to post
Share on other sites

My first question would be more along the lines of "Why are you re-using the same variable name for each control?".


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I'm using the same variable to keep track of the ID when i tried with the arrays because i'm not sure how to do this with many variable.

Edited by Jayson

Share this post


Link to post
Share on other sites

I ran into another problem. I added an editbox($aEditDisable) that show which line we are on another edit($aEdit). Everything work up there. The problem is when i switch back to another tab. The number won't increase anymore but the last tab will work and when i'm deleting any tab it crash my app.

This is the error that i got :

C:\Users\Jason\Desktop\Engine\Mergin Both.au3 (117) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
If $iLParam = GUICtrlGetHandle($aEdit[$aTab[0]]) Then
If $iLParam = GUICtrlGetHandle(^ ERROR

And the code :

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <GUIToolbar.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GUIEdit.au3>

Global Enum $idNew = 1000, $idOpen, $idSave, $idHelp
Global $aTaskBar_Pos = WinGetPos("[CLASS:Shell_TrayWnd]")
Global $aTab[2] = [0], $aEdit[2], $aEditDisable[2]
Global $sLineCount = ''
For $i = 1 to 2000
    $sLineCount &= $i & @CRLF
Next

If $aTaskBar_Pos[1] > 0 Then
    If $aTaskBar_Pos[1] > @DesktopHeight - $aTaskBar_Pos[3] Then
        $Editor = GUICreate("Editor", @DesktopWidth - 15, @DesktopHeight - 15, 0, 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Bottom hidden
    Else
        $Editor = GUICreate("Editor", $aTaskBar_Pos[2] - 15, $aTaskBar_Pos[1] - 15, 0, 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Bottom
    EndIf
ElseIf $aTaskBar_Pos[0] > 0 Then
    If $aTaskBar_Pos[0] > @DesktopWidth - $aTaskBar_Pos[2] Then
        $Editor = GUICreate("Editor", @DesktopWidth - 15, @DesktopHeight - 15, 0, 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Right hidden
    Else
        $Editor = GUICreate("Editor", $aTaskBar_Pos[0] - 15, @DesktopHeight - 15, 0, 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Right
    EndIf
ElseIf $aTaskBar_Pos[2] = @DesktopWidth Then
    If $aTaskBar_Pos[1] < 0 Then
        $Editor = GUICreate("Editor", @DesktopWidth - 15, @DesktopHeight - 15, 0, 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Top hidden
    Else
        $Editor = GUICreate("Editor", @DesktopWidth - 15, @DesktopHeight - $aTaskBar_Pos[3] - 15, 0, $aTaskBar_Pos[3], BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Top
    EndIf
ElseIf $aTaskBar_Pos[3] = @DesktopHeight Then
    If $aTaskBar_Pos[0] < 0 Then
        $Editor = GUICreate("Editor", @DesktopWidth - 15, @DesktopHeight - 15, 0, 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Left hidden
    Else
        $Editor = GUICreate("Editor", @DesktopWidth - $aTaskBar_Pos[2] - 15, @DesktopHeight - 15, $aTaskBar_Pos[2], 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Left
    EndIf
EndIf

$NewTabButton = GUICtrlCreateButton("+", 475, 10, 50, 20)
$DelTabButton = GUICtrlCreateButton("-", 420, 10, 50, 20)

$Tab = GUICtrlCreateTab(200, 116, 1300, 750)

_AddTab()

;;;;;;;;;;;;;;;;;;;;;; FOR LATER
$filemenu = GUICtrlCreateMenu("&File")
$fileitem = GUICtrlCreateMenuItem("Open", $filemenu)
$saveitem = GUICtrlCreateMenuItem("Save", $filemenu)
$separator1 = GUICtrlCreateMenuItem("", $filemenu)
$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu)
$recentfilesmenu = GUICtrlCreateMenuItem("C:\Program Files(x86)...", $recentfilesmenu)
$viewmenu = GUICtrlCreateMenu("&View")
$sourceitem = GUICtrlCreateMenuItem("Source", $viewmenu)

$hToolbar = _GUICtrlToolbar_Create ($Editor)
_GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
; Add buttons
_GUICtrlToolbar_AddButton ($hToolbar, $idNew, $STD_FILENEW)
_GUICtrlToolbar_AddButton ($hToolbar, $idOpen, $STD_FILEOPEN)
_GUICtrlToolbar_AddButton ($hToolbar, $idSave, $STD_FILESAVE)
_GUICtrlToolbar_AddButtonSep ($hToolbar)
_GUICtrlToolbar_AddButton ($hToolbar, $idHelp, $STD_HELP)
;;;;;;;;;;;;;;;;;;;; END FOR LATER

GUIRegisterMsg($WM_CTLCOLOREDIT, 'WM_CTLCOLOREDIT')

While 1
    Switch GUIGetMsg()

    Case $DelTabButton
    _DelTab()

    Case $NewTabButton
    _AddTab()

    Case $GUI_EVENT_CLOSE
    Exit

    EndSwitch
WEnd

Func _AddTab()
    $aTab[0] += 1
    ReDim $aTab[$aTab[0] + 1]
    $aTab[$aTab[0]] = GUICtrlCreateTabItem($aTab[0])
    ReDim $aEdit[$aTab[0] + 1]
    $aEdit[$aTab[0]] = GUICtrlCreateEdit($aTab[0], 256, 150, 1200, 600)
    ReDim $aEditDisable[$aTab[0] + 2]
    $aEditDisable[$aTab[0]] = GUICtrlCreateEdit('1', 208, 150, 40, 600, BitOR($ES_READONLY, $ES_RIGHT))
    GUICtrlCreateTabItem("")
EndFunc

Func _DelTab()
    $DelTab = GUICtrlRead($Tab) + 1
    GUICtrlDelete($aEdit[$DelTab])
    _ArrayDelete($aEdit, $DelTab)
    GUICtrlDelete($aTab[$DelTab])
    _ArrayDelete($aTab, $DelTab)
    GUICtrlDelete($aEditDisable[$DelTab])
    _ArrayDelete($aEditDisable, $DelTab)
EndFunc

Func WM_CTLCOLOREDIT($hWnd, $iMsg, $iWParam, $iLParam)

    If $iLParam = GUICtrlGetHandle($aEdit[$aTab[0]]) Then
    _GUICtrlEdit_BeginUpdate($aEditDisable[$aTab[0]])
    Local $iLineCount = _GUICtrlEdit_GetLineCount($aEdit[$aTab[0]])
    Local $iCutOff = StringInStr($sLineCount, @CRLF, 0, $iLineCount)

    If $iCutOff = 0 Then
    Global $sLineCount = ''
    For $i = 1 to $iLineCount + 100
    $sLineCount &= $i & @CRLF
    Next
 $iCutOff = StringInStr($sLineCount, @CRLF, 0, $iLineCount)
    EndIf

    GUICtrlSetData($aEditDisable[$aTab[0]], StringLeft($sLineCount, $iCutOff+1))
    $STATIC___iLineCountMem = $iLineCount

    Local $iLineVis = _GUICtrlEdit_GetFirstVisibleLine($aEdit[$aTab[0]])
    _GUICtrlEdit_Linescroll($aEditDisable[$aTab[0]], 0, -$iLineCount)
    _GUICtrlEdit_Linescroll($aEditDisable[$aTab[0]], 0, $iLineVis)
    _GUICtrlEdit_EndUpdate($aEditDisable[$aTab[0]])

    EndIf

    Return $GUI_RUNDEFMSG

EndFunc

Share this post


Link to post
Share on other sites

Jayson,

This should work. You were looking for the last created tab and not the active tab in the WM_CTLCOLOREDIT message handler. ;)

Look between the <<<<<<<<<<<<<< lines: ;)

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <GUIToolbar.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GUIEdit.au3>

Global Enum $idNew = 1000, $idOpen, $idSave, $idHelp
Global $aTaskBar_Pos = WinGetPos("[CLASS:Shell_TrayWnd]")
Global $aTab[2] = [0], $aEdit[2], $aEditDisable[2]
Global $sLineCount = ''
For $i = 1 To 2000
    $sLineCount &= $i & @CRLF
Next

If $aTaskBar_Pos[1] > 0 Then
    If $aTaskBar_Pos[1] > @DesktopHeight - $aTaskBar_Pos[3] Then
        $Editor = GUICreate("Editor", @DesktopWidth - 15, @DesktopHeight - 15, 0, 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Bottom hidden
    Else
        $Editor = GUICreate("Editor", $aTaskBar_Pos[2] - 15, $aTaskBar_Pos[1] - 15, 0, 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Bottom
    EndIf
ElseIf $aTaskBar_Pos[0] > 0 Then
    If $aTaskBar_Pos[0] > @DesktopWidth - $aTaskBar_Pos[2] Then
        $Editor = GUICreate("Editor", @DesktopWidth - 15, @DesktopHeight - 15, 0, 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Right hidden
    Else
        $Editor = GUICreate("Editor", $aTaskBar_Pos[0] - 15, @DesktopHeight - 15, 0, 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Right
    EndIf
ElseIf $aTaskBar_Pos[2] = @DesktopWidth Then
    If $aTaskBar_Pos[1] < 0 Then
        $Editor = GUICreate("Editor", @DesktopWidth - 15, @DesktopHeight - 15, 0, 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Top hidden
    Else
        $Editor = GUICreate("Editor", @DesktopWidth - 15, @DesktopHeight - $aTaskBar_Pos[3] - 15, 0, $aTaskBar_Pos[3], BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Top
    EndIf
ElseIf $aTaskBar_Pos[3] = @DesktopHeight Then
    If $aTaskBar_Pos[0] < 0 Then
        $Editor = GUICreate("Editor", @DesktopWidth - 15, @DesktopHeight - 15, 0, 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Left hidden
    Else
        $Editor = GUICreate("Editor", @DesktopWidth - $aTaskBar_Pos[2] - 15, @DesktopHeight - 15, $aTaskBar_Pos[2], 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
        GUISetState() ; Left
    EndIf
EndIf

$NewTabButton = GUICtrlCreateButton("+", 475, 10, 50, 20)
$DelTabButton = GUICtrlCreateButton("-", 420, 10, 50, 20)

$Tab = GUICtrlCreateTab(200, 116, 1300, 750)

_AddTab()

;;;;;;;;;;;;;;;;;;;;;; FOR LATER
$filemenu = GUICtrlCreateMenu("&File")
$fileitem = GUICtrlCreateMenuItem("Open", $filemenu)
$saveitem = GUICtrlCreateMenuItem("Save", $filemenu)
$separator1 = GUICtrlCreateMenuItem("", $filemenu)
$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu)
$recentfilesmenu = GUICtrlCreateMenuItem("C:\Program Files(x86)...", $recentfilesmenu)
$viewmenu = GUICtrlCreateMenu("&View")
$sourceitem = GUICtrlCreateMenuItem("Source", $viewmenu)

$hToolbar = _GUICtrlToolbar_Create($Editor)
_GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
; Add buttons
_GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW)
_GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN)
_GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE)
_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)
;;;;;;;;;;;;;;;;;;;; END FOR LATER

GUIRegisterMsg($WM_CTLCOLOREDIT, 'WM_CTLCOLOREDIT')

While 1
    Switch GUIGetMsg()

        Case $DelTabButton
            _DelTab()

        Case $NewTabButton
            _AddTab()

        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _AddTab()
    $aTab[0] += 1
    ReDim $aTab[$aTab[0] + 1]
    $aTab[$aTab[0]] = GUICtrlCreateTabItem($aTab[0])
    ReDim $aEdit[$aTab[0] + 1]
    $aEdit[$aTab[0]] = GUICtrlCreateEdit($aTab[0], 256, 150, 1200, 600)
    ReDim $aEditDisable[$aTab[0] + 1] ; Why add 2 here - 1 is quite suffcient <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    $aEditDisable[$aTab[0]] = GUICtrlCreateEdit('1', 208, 150, 40, 600, BitOR($ES_READONLY, $ES_RIGHT))
    GUICtrlCreateTabItem("")
EndFunc   ;==>_AddTab

Func _DelTab()
    $DelTab = GUICtrlRead($Tab) + 1
    GUICtrlDelete($aEdit[$DelTab])
    _ArrayDelete($aEdit, $DelTab)
    GUICtrlDelete($aTab[$DelTab])
    _ArrayDelete($aTab, $DelTab)
    GUICtrlDelete($aEditDisable[$DelTab])
    _ArrayDelete($aEditDisable, $DelTab)
EndFunc   ;==>_DelTab

Func WM_CTLCOLOREDIT($hWnd, $iMsg, $iWParam, $iLParam)

    ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $ActiveTab, not $aTab[0] in this section
    Local $ActiveTab = GUICtrlRead($Tab) + 1
    If $iLParam = GUICtrlGetHandle($aEdit[$ActiveTab]) Then
        _GUICtrlEdit_BeginUpdate($aEditDisable[$ActiveTab])
        Local $iLineCount = _GUICtrlEdit_GetLineCount($aEdit[$ActiveTab])
        Local $iCutOff = StringInStr($sLineCount, @CRLF, 0, $iLineCount)

        If $iCutOff = 0 Then
            Global $sLineCount = ''
            For $i = 1 To $iLineCount + 100
                $sLineCount &= $i & @CRLF
            Next
            $iCutOff = StringInStr($sLineCount, @CRLF, 0, $iLineCount)
        EndIf

        GUICtrlSetData($aEditDisable[$ActiveTab], StringLeft($sLineCount, $iCutOff + 1))
        $STATIC___iLineCountMem = $iLineCount

        Local $iLineVis = _GUICtrlEdit_GetFirstVisibleLine($aEdit[$ActiveTab])
        _GUICtrlEdit_LineScroll($aEditDisable[$ActiveTab], 0, -$iLineCount)
        _GUICtrlEdit_LineScroll($aEditDisable[$ActiveTab], 0, $iLineVis)
        _GUICtrlEdit_EndUpdate($aEditDisable[$ActiveTab])

    EndIf
    ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_CTLCOLOREDIT

Please ask if there are 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

Oh, i was close ! I tried $TabFocus = GUICtrlRead($aTab[0]) + 1 which was only updating Tab 1 ;)

Thank you for your great help again Melba !

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Now i got a problem by loading my treeview with array from a file ;)

It makes two times the A ... instead of merging into the same section.

....
$ini = "db.txt"
$section = IniReadSectionNames($ini)
$Editor = GUICreate("Editor", @DesktopWidth - 15, @DesktopHeight - 15, 0, 0, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
$Tags = _GUICtrlTreeView_Create($Editor, 20, 95, 160, 795)
;_GUICtrlTreeView_BeginUpdate($Tags)

For $i = 1 To $section[0]
    $data = IniReadSection($ini,$section[$i])
    For $j = 1 To $data[0][0]
        ;_ArrayDisplay($data)
        $lol = _GUICtrlTreeView_Add($Tags, 0,$section[$i])
        _GUICtrlTreeView_AddChild($Tags, $lol, $data[$j][0])
    Next
Next

db.txt :

[A ...]
HREF=""LOLZ
lolZ=ZZZZ
[B ...]
LOL1Z=LOL2
Edited by Jayson

Share this post


Link to post
Share on other sites

Jayson,

This has nothing to do with the tabs we were discussing above. Next time you have a new problem, start a new topic, OK? ;)

As you have your _GUICtrlTreeView_Add line within your loop, you get a new parent on each pass through it. Just move that line outside the loop: :)

For $i = 1 To $section[0]
    $lol = _GUICtrlTreeView_Add($Tags, 0,$section[$i]) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<< now it it outside and you get just the one parent
    $data = IniReadSection($ini,$section[$i])
    For $j = 1 To $data[0][0]
        _GUICtrlTreeView_AddChild($Tags, $lol, $data[$j][0])
    Next
Next

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

#15 ·  Posted (edited)

Melba,

I just found something weird with the tabs.. I never noticed this until i made some test today.. Add 5 tabs then delete them. Do this 2 times. You'll notice that you need to click more than once do see a tab disappear. I'm not sure why it does that.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

Global $aTab[2] = [0]
Global $aInput[2]

GUICreate("Tabbing", 528, 351, 193, 125)

$NewTabButton = GUICtrlCreateButton("+", 475, 10, 50, 20)
$DelTabButton = GUICtrlCreateButton("-", 420, 10, 50, 20)

$Tab = GUICtrlCreateTab(16, 116, 497, 200)

_AddTab()

GUISetState()

While 1

    Switch GUIGetMsg()

    Case $DelTabButton
    _DelTab()

    Case $NewTabButton
    _AddTab()

    Case $GUI_EVENT_CLOSE
    Exit

    EndSwitch

WEnd

Func _AddTab()

    $aTab[0] += 1
    ReDim $aTab[$aTab[0] + 1]
    $aTab[$aTab[0]] = GUICtrlCreateTabItem($aTab[0])
    ReDim $aInput[$aTab[0] + 1]
    $aInput[$aTab[0]] = GUICtrlCreateInput($aTab[0], 32, 150, 121, 21)
    GUICtrlCreateTabItem("")

EndFunc

Func _DelTab()

    $DelTab = GUICtrlRead($Tab) + 1
    GUICtrlDelete($aInput[$DelTab])
    _ArrayDelete($aInput, $DelTab)
    GUICtrlDelete($aTab[$DelTab])
    _ArrayDelete($aTab, $DelTab)

EndFunc
Edited by Jayson

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Jayson,

I'm not sure why it does that

I am! :shocked:

The array holding the ControlIDs was becoming corrupted when you added a second set of tabs. Try this version - it also fixes the possible array size problem I mentioned earlier by resizing the array to only hold the current tabs: ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

Global $aTab[2] = [0]
Global $aInput[2]
Global $iCounter = 0

GUICreate("Tabbing", 528, 351, 193, 125)

$NewTabButton = GUICtrlCreateButton("+", 475, 10, 50, 20)
$DelTabButton = GUICtrlCreateButton("-", 420, 10, 50, 20)

$Tab = GUICtrlCreateTab(16, 116, 497, 200)

_AddTab()

GUISetState()

While 1

    Switch GUIGetMsg()

    Case $DelTabButton
    _DelTab()

    Case $NewTabButton
    _AddTab()

    Case $GUI_EVENT_CLOSE
    Exit

    EndSwitch

WEnd

Func _AddTab()

    $iCounter += 1
    $aTab[0] += 1
    ReDim $aTab[$aTab[0] + 1]
    $aTab[$aTab[0]] = GUICtrlCreateTabItem($iCounter)
    ReDim $aInput[$aTab[0] + 1]
    $aInput[$aTab[0]] = GUICtrlCreateInput($iCounter, 32, 150, 121, 21)
    GUICtrlCreateTabItem("")

EndFunc

Func _DelTab()

    $DelTab = GUICtrlRead($Tab, 1)
    If $DelTab <> 0 Then
        Local $iIndex = _ArraySearch($aTab, $DelTab)
        If $iIndex <> -1 Then
            GUICtrlDelete($aInput[$iIndex])
            _ArrayDelete($aInput, $iIndex)
            GUICtrlDelete($aTab[$iIndex])
            _ArrayDelete($aTab, $iIndex)
            $aTab[0] -= 1
        EndIf
    EndIf

EndFunc

I hope this works more as you wish. :)

M23

Edit: Change to _DelTab function - I forgot to errorcheck. ;)

Edited by Melba23

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

Melba,

it works like a charm. HURRAY ! ;)

Share this post


Link to post
Share on other sites

Jayson,

it works like a charm.

Not unless you use the edited code I just posted! ;)

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

#19 ·  Posted (edited)

Melba,

Your edited code was for fixing the crash that occured when there was no tab to delete ? If yes, well i found the same answer as you :) (i am getting better everyday! lol)

Thank you ;)

Edited by Jayson

Share this post


Link to post
Share on other sites

Jayson,

Your edited code was for fixing the crash that occured when there was no tab to delete ?

Exactly! ;)

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