Jump to content

GUICtrlDelete() - Deletes more than one ctrl


Recommended Posts

When I use GUICtrlDelete(), more than one ctrl is deleted. WHY?

I know the below script is long. It was pieced together from a huge script. I tried really hard to get it down to the bare minimums. I seem to only get the issue when it's setup like this with all the controls listed.

To get the same problem I do:

  • Run the code below
  • Move the child gui to the side (there are two guis if you can't tell by the script)
  • Click Retrieve
  • Click Rest
  • There's the problem: All the tabs are removed and so is $MenuItem4 and the ListView Item (both are in the parent GUI)
BytheWay, I know a work around to this using _GUICtrlTabDeleteItem (), but my question remains. I don't want to just move on because I found a work around.

Opt("GUIOnEventMode", 1)
#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <Array.au3>
#Include <IE.au3>
#Include <GuiEdit.au3>

Global $oIE_Capture
Global $tabCount=1;1=core
Global $htmlCaptureTabArray[1]

$ParentWin = GUICreate("IE Object Info", 885, 593, -1, -1)
$LV_Main = GUICtrlCreateListView("URL|Title|Visible", 20, 42, 839, 286)
GUICtrlSendMsg($LV_Main, 0x101E, 0, 250)
GUICtrlSendMsg($LV_Main, 0x101E, 1, 200)
GUICtrlSendMsg($LV_Main, 0x101E, 2, 50)
$LaunchNewIE = GUICtrlCreateButton("Launch New", 389, 487, 114, 25, 0)
$CloseBTN = GUICtrlCreateButton("Close", 783, 332, 75, 25, 0)
$Radio1 = GUICtrlCreateRadio("Show", 715, 337, 55, 17)
$Radio2 = GUICtrlCreateRadio("Hide", 655, 337, 52, 17)
$StatusBarLB = GUICtrlCreateLabel("", 0, 555, 883, 17, BitOR($SS_CENTERIMAGE,$SS_SUNKEN))
GUICtrlSetColor($StatusBarLB, 0x808080)
$GotoAccount_INP = GUICtrlCreateInput("", 114, 340, 121, 21)
$GotoAccount_BTN = GUICtrlCreateButton("GoTo Account", 21, 338, 85, 25, 0)
$ChangeDateTemp_BTN = GUICtrlCreateButton("Change Date", 22, 377, 92, 25, 0)
$GroupDateRange = GUICtrlCreateGroup("Date Range", 120, 373, 281, 57)
$DateStart_CAL = GUICtrlCreateDate("2007/09/27 09:03:43", 136, 397, 98, 21, $WS_TABSTOP)
$DateEnd_CAL = GUICtrlCreateDate("2007/09/27 09:03:43", 271, 397, 98, 21, $WS_TABSTOP)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 728, 460, 131, 49)
$Radio3 = GUICtrlCreateRadio("Show", 803, 479, 55, 17)
$Radio4 = GUICtrlCreateRadio("Hide", 743, 479, 52, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label2 = GUICtrlCreateLabel("All Current Open", 729, 446, 130, 17)
$DownloadCSV_BTN = GUICtrlCreateButton("Download CSV", 23, 455, 90, 25, 0)
$MenuItem1 = GUICtrlCreateMenu("IE Obj")
$MenuItem3 = GUICtrlCreateMenuItem("IE Show", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenuItem("IE Unbind", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenu("Tools")
$MenuItem5 = GUICtrlCreateMenuItem("HTML Capture", $MenuItem4)
GUISetState(@SW_SHOW)

$Win_1 = GUICreate("HTML Capture", 1080, 877, -1, -1,-1,-1,$ParentWin)
$Tab1 = GUICtrlCreateTab(17, 9, 1046, 803)
GUICtrlSetResizing($Tab1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Core")
$InnerTextED = GUICtrlCreateEdit("", 39, 89, 435, 318)
$InnerHTMLED = GUICtrlCreateEdit("", 488, 88, 542, 320)
$OuterTextED = GUICtrlCreateEdit("", 37, 444, 436, 304)
$OuterHTMLED = GUICtrlCreateEdit("", 484, 445, 548, 303)
$URLlocationIN = GUICtrlCreateInput("", 86, 39, 944, 21)
$Label1 = GUICtrlCreateLabel("InnerText", 39, 69, 49, 17)
$Label2 = GUICtrlCreateLabel("OuterText", 38, 424, 49, 17)
$Label3 = GUICtrlCreateLabel("OuterHTML", 483, 423, 73, 17)
$Label4 = GUICtrlCreateLabel("InnerHTML", 488, 67, 78, 17)
$InnerTextCountLB = GUICtrlCreateLabel("", 387, 67, 84, 17, BitOR($SS_RIGHT,$SS_SUNKEN))
$OuterTextCountLB = GUICtrlCreateLabel("", 387, 422, 84, 17, BitOR($SS_RIGHT,$SS_SUNKEN))
$OuterHTMLCountLB = GUICtrlCreateLabel("", 945, 422, 84, 17, BitOR($SS_RIGHT,$SS_SUNKEN))
$InnerHTMLCountLB = GUICtrlCreateLabel("", 945, 67, 84, 17, BitOR($SS_RIGHT,$SS_SUNKEN))
$TitleIN = GUICtrlCreateInput("", 122, 769, 219, 21)
$Label5 = GUICtrlCreateLabel("Title", 39, 771, 78, 17)
GUICtrlCreateTabItem("")
$RetrieveDataBTN = GUICtrlCreateButton("Retrieve Data", 0, 850, 101, 25, 0)
$StatusBarLB = GUICtrlCreateLabel("", 98, 851, 979, 24, BitOR($SS_CENTER,$SS_CENTERIMAGE,$SS_SUNKEN))
$Rest_BTN = GUICtrlCreateButton("Rest", 986, 814, 75, 25, 0)
GUISetState(@SW_SHOW)

GUICtrlSetState($RetrieveDataBTN,$GUI_DISABLE)
GUICtrlSetState($Rest_BTN,$GUI_DISABLE)

GUISetOnEvent($GUI_EVENT_CLOSE, "Win_1Close",$ParentWin)
GUISetOnEvent($GUI_EVENT_CLOSE, "Win_1Close",$Win_1)
GUICtrlSetOnEvent($RetrieveDataBTN, "RetrieveDataBTNClick")
GUICtrlSetOnEvent($Rest_BTN, "Rest_BTNClick")

ProgressOn('FFTAM Element', "Loading page...")
$oIE_Capture = _IECreateWithListener('http://www.ncdesign.org/html/frame/rows.html',0,1)
Local $stringURL = _IEPropertyGet ($oIE_Capture, "locationurl")
Local $stringTitle = _IEPropertyGet ($oIE_Capture, "title")
Local $numVisible = _IEPropertyGet ($oIE_Capture, "visible")
GUICtrlCreateListViewItem($stringURL&'|'& _ 
                                $stringTitle &'|'& _ 
                                $numVisible, _ 
                                $LV_Main _
                                )

GUICtrlSetState($RetrieveDataBTN,$GUI_ENABLE)
GUICtrlSetState($Rest_BTN,$GUI_ENABLE)


While 1
    Sleep(50)
WEnd


Func Win_1Close()
    _IEQuit($oIE_Capture)
    Exit
EndFunc

Func Rest_BTNClick()
    GUICtrlSetData($URLlocationIN,'')
    GUICtrlSetData($TitleIN,'')
    GUICtrlSetData($InnerTextED,'')
    GUICtrlSetData($InnerTextCountLB,'')
    GUICtrlSetData($InnerHTMLED,'')
    GUICtrlSetData($InnerHTMLCountLB,'')
    GUICtrlSetData($OuterTextED,'')
    GUICtrlSetData($OuterTextCountLB,'')
    GUICtrlSetData($OuterHTMLED,'')
    GUICtrlSetData($OuterHTMLCountLB,'')
    If $tabCount > 1 Then 
        For $_x = $tabCount-1 to 1 Step -1 
            GUICtrlDelete($htmlCaptureTabArray[$_x])
            _ArrayDelete($htmlCaptureTabArray,$_x)
        Next
    EndIf
    $tabCount=1
EndFunc
Func RetrieveDataBTNClick()
    $stringURL = _IEPropertyGet ($oIE_Capture, "locationurl")
    $stringInnerText = _IEPropertyGet ($oIE_Capture, "innertext")
    $stringInnerHTML = _IEPropertyGet ($oIE_Capture, "innerhtml")
    $stringOuterText = _IEPropertyGet ($oIE_Capture, "outertext")
    $stringOuterHTML = _IEPropertyGet ($oIE_Capture, "outerhtml")
    $stringTitle = _IEPropertyGet ($oIE_Capture, "title")

    GUICtrlSetData($URLlocationIN,$stringURL)
    GUICtrlSetData($TitleIN,$stringTitle)
    GUICtrlSetData($InnerTextED,$stringInnerText)
    GUICtrlSetData($InnerTextCountLB,_GUICtrlEditGetLineCount($InnerTextED))
    GUICtrlSetData($InnerHTMLED,$stringInnerHTML)
    GUICtrlSetData($InnerHTMLCountLB,_GUICtrlEditGetLineCount($InnerHTMLED))
    GUICtrlSetData($OuterTextED,$stringOuterText)
    GUICtrlSetData($OuterTextCountLB,_GUICtrlEditGetLineCount($OuterTextED))
    GUICtrlSetData($OuterHTMLED,$stringOuterHTML)
    GUICtrlSetData($OuterHTMLCountLB,_GUICtrlEditGetLineCount($OuterHTMLED))
    $oFrames = _IEFrameGetCollection ($oIE_Capture)
    $iNumFrames = @extended
    $htmlCaptureTabArray[0] = $iNumFrames
    For $i = 0 to ($iNumFrames - 1)
        $tabCount+=1
        $oFrame = _IEFrameGetCollection ($oIE_Capture, $i)
        $tabName = _IEPropertyGet ($oFrame, "title")
        Local $TabSheetNew=GUICtrlCreateTabitem ($tabName)
        ReDim $htmlCaptureTabArray[UBound($htmlCaptureTabArray)+1]
        $htmlCaptureTabArray[UBound($htmlCaptureTabArray)-1] = $TabSheetNew
        
        $InnerTextEDTemp = GUICtrlCreateEdit("", 39, 89, 435, 318)
        $InnerHTMLEDTemp = GUICtrlCreateEdit("", 488, 88, 542, 320)
        $OuterTextEDTemp = GUICtrlCreateEdit("", 37, 444, 436, 304)
        $OuterHTMLEDTemp = GUICtrlCreateEdit("", 484, 445, 548, 303)
        $URLlocationINTemp = GUICtrlCreateInput("", 86, 39, 944, 21)
        $Label1Temp = GUICtrlCreateLabel("InnerText", 39, 69, 49, 17)
        $Label2Temp = GUICtrlCreateLabel("OuterText", 38, 424, 49, 17)
        $Label3Temp = GUICtrlCreateLabel("OuterHTML", 483, 423, 73, 17)
        $Label4Temp = GUICtrlCreateLabel("InnerHTML", 488, 67, 78, 17)
        $InnerTextCountLBTemp = GUICtrlCreateLabel("", 387, 67, 84, 17, BitOR($SS_RIGHT,$SS_SUNKEN))
        $OuterTextCountLBTemp = GUICtrlCreateLabel("", 387, 422, 84, 17, BitOR($SS_RIGHT,$SS_SUNKEN))
        $OuterHTMLCountLBTemp = GUICtrlCreateLabel("", 945, 422, 84, 17, BitOR($SS_RIGHT,$SS_SUNKEN))
        $InnerHTMLCountLBTemp = GUICtrlCreateLabel("", 945, 67, 84, 17, BitOR($SS_RIGHT,$SS_SUNKEN))
        $TitleINTemp = GUICtrlCreateInput("", 1160, 40, 219, 21)
        $Label5Temp = GUICtrlCreateLabel("Title", 1077, 42, 78, 17)
        
        $stringURL = _IEPropertyGet ($oFrame, "locationurl")
        $stringInnerText = _IEPropertyGet ($oFrame, "innertext")
        $stringInnerHTML = _IEPropertyGet ($oFrame, "innerhtml")
        $stringOuterText = _IEPropertyGet ($oFrame, "outertext")
        $stringOuterHTML = _IEPropertyGet ($oFrame, "outerhtml")
        $stringTitle = _IEPropertyGet ($oFrame, "title")
        
        GUICtrlSetData($URLlocationINTemp,$stringURL)
        GUICtrlSetData($TitleINTemp,$stringTitle)
        GUICtrlSetData($InnerTextEDTemp,$stringInnerText)
        GUICtrlSetData($InnerTextCountLBTemp,_GUICtrlEditGetLineCount($InnerTextEDTemp))
        GUICtrlSetData($InnerHTMLEDTemp,$stringInnerHTML)
        GUICtrlSetData($InnerHTMLCountLBTemp,_GUICtrlEditGetLineCount($InnerHTMLEDTemp))
        GUICtrlSetData($OuterTextEDTemp,$stringOuterText)
        GUICtrlSetData($OuterTextCountLBTemp,_GUICtrlEditGetLineCount($OuterTextEDTemp))
        GUICtrlSetData($OuterHTMLEDTemp,$stringOuterHTML)
        GUICtrlSetData($OuterHTMLCountLBTemp,_GUICtrlEditGetLineCount($OuterHTMLEDTemp))
    Next
EndFunc



;=============================================
;  A Variant of Dale's with an added Listener
;=============================================
Func _IECreateWithListener($s_Url = "about:blank", $f_tryAttach = 0, $f_visible = 1, $f_wait = 1, $f_takeFocus = 1)
    
    Local $result, $f_mustUnlock = 0
    
; Temporary campatability mode for pre V2.0 code
    If $__IEAU3V1Compatibility Then
        Switch String($s_Url)
            Case "0"
                $s_Url = "about:blank"
                $f_visible = 0
                __IEErrorNotify("Warning", "_IECreate", "", _
                        "Using deprecated behavior - $f_visible is now parameter 3 instead of parameter 1")
            Case "1"
                $s_Url = "about:blank"
                $f_visible = 1
                __IEErrorNotify("Warning", "_IECreate", "", _
                        "Using deprecated behavior - $f_visible is now parameter 3 instead of parameter 1")
        EndSwitch
    EndIf
    
    If Not $f_visible Then $f_takeFocus = 0; Force takeFocus to 0 for hidden window
    
    If $f_tryAttach Then
        Local $oResult = _IEAttach($s_Url, "url")
        If IsObj($oResult) Then
            If $f_takeFocus Then WinActivate(HWnd($oResult.HWND))
            SetError($_IEStatus_Success)
            SetExtended(1)
            Return $oResult
        EndIf
    EndIf
    
    If Not $f_visible Then
        $result = __IELockSetForegroundWindow($LSFW_LOCK)
        If $result Then $f_mustUnlock = 1
    EndIf
    
    Local $o_object = ObjCreate("InternetExplorer.Application")
    If Not IsObj($o_object) Then
        __IEErrorNotify("Error", "_IECreate", "", "Browser Object Creation Failed")
        SetError($_IEStatus_GeneralError)
        Return 0
    EndIf
    
    ObjEvent($o_object,"IEEvent_","DWebBrowserEvents2"); IE Object Listener <<< THE ADDED LINE
    
    $o_object.visible = $f_visible
    
    If $f_mustUnlock Then
        $result = __IELockSetForegroundWindow($LSFW_UNLOCK)
        If Not $result Then __IEErrorNotify("Warning", "_IECreate", "", "Foreground Window Unlock Failed!")
; If the unlock doesn't work we will have created an unwanted modal window
    EndIf
    _IENavigate($o_object, $s_Url, $f_wait)
    SetError(@error)
    Return $o_object
EndFunc



;=============================================
;             IE EVENTS
;=============================================
Func IEEvent_ProgressChange($Progress,$ProgressMax)
    $percent = Int( ($Progress * 100) / $ProgressMax )
    If $percent >= 0 And $percent <= 100 Then
        ProgressSet ( $percent , $percent & " percent to go." , "loading web page" )
    Else
        ProgressOff()
    EndIf
EndFunc


Func IEEvent_OnQuit()
    ConsoleWrite('IE Quit Occured: '&@LF)
    MsgBox(0,'ByeBye','You closed the IE Window that is used by this script')
    Exit        
EndFunc
Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

Given this part of the code, why wouldn't it do more than one?

If $tabCount > 1 Then
        For $_x = $tabCount - 1 To 1 Step - 1
            GUICtrlDelete($htmlCaptureTabArray[$_x])
            _ArrayDelete($htmlCaptureTabArray, $_x)
        Next
    EndIf

What is the value of $tabCount supposed to be that would NOT do the For/Next loop more than once?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Given this part of the code, why wouldn't it do more than one?

If $tabCount > 1 Then
        For $_x = $tabCount - 1 To 1 Step - 1
            GUICtrlDelete($htmlCaptureTabArray[$_x])
            _ArrayDelete($htmlCaptureTabArray, $_x)
        Next
    EndIf

What is the value of $tabCount supposed to be that would NOT do the For/Next loop more than once?

:)

OK, I officially suck at explaining things :"> . It's only supposed to delete the added tabs. The tabs are added in RetrieveDataBTNClick(). Does that clarify at all? I mean that during the loop runs GUICtrlDelete removes more than one ctrl at a time.

A decision is a powerful thing
Link to comment
Share on other sites

OK, I officially suck at explaining things blush.gif . It's only supposed to delete the added tabs. The tabs are added in RetrieveDataBTNClick(). Does that clarify at all? I mean that during the loop runs GUICtrlDelete removes more than one ctrl at a time.

Just think about what you are asking.....

1

GUICtrlCreateTab() ... notice that this is a "control" then you add GUICtrlCreateTabitem() on that control.

Then you want to use GUICtrlDelete() to delete just the "additions" to a control. It does not say

GUICtrlDeleteItem()

2

You say you found a work-around with _GUICtrlTab_DeleteItem(). That is exactly what you are trying to do in #1 above

Additionally, why do you think Autoit Developers would create a command of _GUICtrlTab_DeleteItem()

... just for a "work-around"???????????

Think twice, use what works, and ... Enjoy!!!

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Just think about what you are asking.....

1

GUICtrlCreateTab() ... notice that this is a "control" then you add GUICtrlCreateTabitem() on that control.

Then you want to use GUICtrlDelete() to delete just the "additions" to a control. It does not say GUICtrlDeleteItem()

I did not know that GUICtrlCreateTabitem() didn't create a control. :)

I totally learned something new!

So, controls can have "items" ?

Addiyionally, why do you think Autoit Developers would create a command of _GUICtrlTab_DeleteItem()

... just for a "work-around"???????????

Think twice, use what works, and move on

8)

I did not understand that controls could have items that aren't controls theselves (if that's the correct wording). Therefore, I was uncertain as to why _GUICtrlTab_DeleteItem() existed.

One thing though, why does what I did still remove the tabs?

A decision is a powerful thing
Link to comment
Share on other sites

I did not know that GUICtrlCreateTabitem() didn't create a control. ;)

I totally learned something new!

So, controls can have "items" ?

I did not understand that controls could have items that aren't controls theselves (if that's the correct wording). Therefore, I was uncertain as to why _GUICtrlTab_DeleteItem() existed.

One thing though, why does what I did still remove the tabs?

This works, just for fun (_GuiCtrlTabDeleteItem() requires Beta):

#include <GUIConstants.au3>
#Include <GuiTab.au3>
#include <array.au3>

Opt("GuiOnEventMode", 1)
GUICreate("My GUI Tab", 640, 480)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")

$Tab = GUICtrlCreateTab(10, 10, 580, 400)
$hTab = GUICtrlGetHandle($Tab)
Dim $avTabItems[5]
For $n = 0 To UBound($avTabItems) - 1
    $avTabItems[$n] = GUICtrlCreateTabItem("Tab No." & $n)
    GUICtrlCreateLabel("This is tab number " & $n & ".", 20, 100, 300, 20)
    GUICtrlCreateButton("Button " & $n, 120, 160, 100, 30)
    GUICtrlSetOnEvent(-1, "_ButtonHit")
    GUICtrlCreateTabItem("")
Next

GUICtrlCreateLabel("Click button to delete a random tab:", 10, 420, 300, 20)
GUICtrlCreateButton("Delete-A-Tab", 110, 440, 100, 30)
GUICtrlSetOnEvent(-1, "_ButtonHit")
GUISetState()

While 1
    Sleep(20)
WEnd

Func _ButtonHit()
    Local $sText = GUICtrlRead(@GUI_CtrlId)
    If StringLeft($sText, 7) = "Button "  Then
        MsgBox(64, "Click!", "You clicked: " & $sText)
    ElseIf $sText = "Delete-A-Tab"  Then
        Local $i = Random(0, UBound($avTabItems) - 1, 1)
        _GUICtrlTab_DeleteItem ($hTab, $i)
        _ArrayDelete($avTabItems, $i)
        If @error Then
            MsgBox(16, "Done", "You deleted the last tab!  Goodbye...")
            Exit
        EndIf
    EndIf
EndFunc   ;==>_ButtonHit

Func _Quit()
    Exit
EndFunc   ;==>_Quit

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

This works, just for fun (_GuiCtrlTabDeleteItem() requires Beta):

:)

Thank you VERY much PsaltyDS!! That gave me a bunch of insight. (I seriously appreciate the help!)

One thing, do I need to remove the controls "on" the tabitems (using the array for their vars)?

Remark in help file:

"This does not delete the controls on the tabitems"

A decision is a powerful thing
Link to comment
Share on other sites

For All Those Listening In,

Evidentially, I'm not the only bloke asking questions along these lines ( http://www.autoitscript.com/forum/index.php?showtopic=46370 )

More information for those who would like to help

GaryFrost posted an example that shows basically what I was doing before (ie using GUICtrlDelete)

Here's what's interesting: If you use _GUICtrlTab_DeleteItem() or _GUICtrlTabDeleteItem(), then the button control on the next tab (the one left behind) is invisible until you move over it or switch tabs. However, if you use GUICtrlDelete(), the issue seems to be nonexistant. Odd eh?!

_GUICtrlTabSetCurFocus () fixes the issue with the Tab DeleteItem functions. I guess it focuses on nothing. I wonder why the GUICtrlDelete focuses on an available tab and the UDF functions don't.

#include <GUIConstants.au3>
#include <array.au3>
#include <guitab.au3>

$GUI = GUICreate("Tab bug?", 200, 200)
$hTab = GUICtrlCreateTab(10, 10, 180, 150)
$hDelTab2 = GUICtrlCreateButton("Delete the second tab", 10, 165, 120, 25)
Local $ahTabs[4]
$ahTabs[0] = GUICtrlCreateTabItem("t0")
GUICtrlCreateButton(Random(0,50,1), 32, 45, 75, 25, 0)
$ahTabs[1] = GUICtrlCreateTabItem("t1")
GUICtrlCreateButton(Random(0,50,1), 32, 45, 75, 25, 0)
$ahTabs[2] = GUICtrlCreateTabItem("t2")
GUICtrlCreateButton(Random(0,50,1), 32, 45, 75, 25, 0)
$ahTabs[3] = GUICtrlCreateTabItem("t3")
GUICtrlCreateButton(Random(0,50,1), 32, 45, 75, 25, 0)
GUICtrlCreateTabItem("")
GUISetState()

$bTab2Deleted = False
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hDelTab2
            If Not $bTab2Deleted Then
              ;GUICtrlDelete($ahTabs[1]);Built-In
                _GUICtrlTabDeleteItem($hTab,1);Production
        ;_GUICtrlTab_DeleteItem($hTab,1);Beta
                        _GUICtrlTabSetCurFocus ($hTab, 0); only use with the UDF functions
                _ArrayDelete($ahTabs, 1)
            EndIf
        Case $hTab
            $iTab = GUICtrlRead($hTab)
            GUICtrlSetData($ahTabs[$iTab], Random(0, 999, 1))
    EndSwitch
WEnd
Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

Interesting... ;)

Confirmed on the demo I posted above. When you click the button that deletes a tabitem, the tabitem names remain as expected, but the labels and buttons remain with the their old tabitem index-numbers, so the button on the tabitem index 2 remains Button 2, even though tabitem 2 got deleted.

Making just this change fixes it:

; _GUICtrlTab_DeleteItem ($hTab, $i)
        GUICtrlDelete($avTabItems[$i])

So the controls you put on a tabitem are associated with that tabitem's index number, not the ControlID or HWnd of the tabitem... hmmm...

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Interesting... ;)

Confirmed on the demo I posted above. When you click the button that deletes a tab, the tab names remain as expected, but the labels and buttons remain with the their old index-numbered tab, so the button on the tab index 2 remains Button 2, even though tab 2 got deleted.

Making just this change fixes it:

; _GUICtrlTab_DeleteItem ($hTab, $i)
        GUICtrlDelete($avTabItems[$i])

So the controls you put on a tab are associated with that tab's index number, not the ControlID or HWnd of the tab... hmmm...

:)

WOW that explanation explained a lot! THANK YOU! You taught me a lot about wording just then! That's what I meant by not wanting to just move on. I want to know why and that's getting to the whys.

What's weird is I don't understand why it's setup like you described. Plus, this goes back to my original problem because if I use GUICtrlDelete(), as I did in my original code in this thread, then it removes other controls as well. ODD! I know that _GUICtrlTabSetCurFocus () or _GUICtrlTab_SetCurFocus () will fix the glitch as far as visually, but that method ("Work-around") does nothing for helping the whys :P haha

Should we report this?

Edit: wording and addition

Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

WOW that explanation explained a lot! THANK YOU! You taught me a lot about wording just then! That's what I meant by not wanting to just move on. I want to know why and that's getting to the whys.

What's weird is I don't understand why it's setup like you described. Plus, this goes back to my original problem because if I use GUICtrlDelete(), as I did in my original code in this thread, then it removes other controls as well. ODD! I know that _GUICtrlTabSetCurFocus () or _GUICtrlTab_SetCurFocus () will fix the glitch as far as visually, but that method ("Work-around") does nothing for helping the whys ;) haha

Should we report this?

Edit: wording and addition

Note I corrected my post to say "tabitem" vice "tab". In AutoIt-speak, the "Tab" is the entire rectangular area. What most people would call the "Tabs" are actually indexed "tabitems" on the tab control (to AutoIt).

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...