Jump to content
Sign in to follow this  

about the "_GUICtrlTab_DeleteItem"

Recommended Posts

I want to make a muti-tab browser.

Now the problem is that when closing a tab using "_GUICtrlTab_DeleteItem",controls on the tabitems are not deleted.

I try to use GUICtrlDelete to destroy the control.

But it seems to always delete the last one.

Here is my code:

$oIE = _IECreateEmbedded()

$Sub = GUICreate("BootBars", 740, 700, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)

$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 750, 560)

If $msg = $Button4 Then

_GUICtrlTab_DeleteItem($BB_Tab, 0)


Share this post

Link to post
Share on other sites

#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]
Dim $label[5]
For $n = 0 To UBound($avTabItems) - 1
    $avTabItems[$n] = GUICtrlCreateTabItem("Tab No." & $n)

    $label[$n] = GUICtrlCreateLabel("This is tab number " & $n & ".", 20, 100, 300, 20)

    GUICtrlSetOnEvent(-1, "_ButtonHit")

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

While 1

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 = _GUICtrlTab_GetCurSel($hTab)

        _GUICtrlTab_DeleteItem($hTab, $i)
        _ArrayDelete($avTabItems, $i)
        If @error Then
            MsgBox(16, "Done", "You deleted the last tab!  Goodbye...")
EndFunc   ;==>_ButtonHit

Func _Quit()
EndFunc   ;==>_Quit

Share this post

Link to post
Share on other sites

Hmmm. Well the code you posted does not match your original post at all. That said, maybe part of the problem is the way you are creating the tabs. The help file shows that _GUICtrlTab_DeleteItem is called after _GUICtrlTab_InsertItem even though you may have created the tab with GUICtrlCreateTab.

Try this:

$avTabItems[$n] = _GUICtrlTab_InsertItem($hTab,$n,"Tab No." & $n)

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...