Sign in to follow this  
Followers 0
4got

How could I delete the content of a control tab

37 posts in this topic

I need to delete the content of a control tab without specify every times all the elements that are inside it...

any ideas??

Share this post


Link to post
Share on other sites



Clearing and deleting all the Labels,Buttons,Controls in a Tab?

Share this post


Link to post
Share on other sites

yes.I have to remove all the elements inside a control tab

Share this post


Link to post
Share on other sites

yes.I have to remove all the elements inside a control tab

If you create all the controls on one tab in sequence then you can simplify deleting them all like this

;create controls on tab2
$label = guiCtrlCreate....
.
.
..
$Combo = GuiCtrlCreate....

$Tab2First= $label
$Tab2Last = $Combo
;end of control creation on tab2

.
.
;delete all controls on Tab2
for $n = $Tab2First to $Tab2Last
 GuiControlDelete($n)
next

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

If you create all the controls on one tab in sequence then you can simplify deleting them all like this

;create controls on tab2
$label = guiCtrlCreate....
.
.
..
$Combo = GuiCtrlCreate....

$Tab2First= $label
$Tab2Last = $Combo
;end of control creation on tab2

.
.
;delete all controls on Tab2
for $n = $Tab2First to $Tab2Last
 GuiControlDelete($n)
next
it's ok but the problem is that I have a window composed of a menu and a control tab;when I click on a menu item, the old control tab will be deleted and the new one will be loaded,but I couldn't know the elements that were in the old tab; I hope you understand, and forgive me if there are grammatical errors :P

Share this post


Link to post
Share on other sites

I'm pretty sure the only way to do that is to keep track of what items are in the tab from the start. I don't believe there's any way to figure out what items are associated to a tab after the fact.

Share this post


Link to post
Share on other sites

ok thx to all.. :P

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

ok thx to all.. :P

$iStart = GUICtrlCreateDummy()
   Create the controls here
$iEnd = GUICtrlCreateDummy()

For $i = $iStart to $iEnd
   GUICtrlDelete($i)
Next
Edited by GEOSoft

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

I never figure out what is a dummy control

Share this post


Link to post
Share on other sites

I never figure out what is a dummy control

Me too :P ...By the way I've solved the problem :

CODE

Func clear($inside)

If $inside=0 Then

$tab1=$tab

$tab2=$Icon1

For $n=$tab1 To $tab2

GUICtrlDelete($n)

next

If $inside="another value" Then

$tab1=$tab

$tab2=$Icon2

For $n=$tab1 To $tab2

GUICtrlDelete($n)

next

....

....

EndIf

EndFunc

This function clear the tab every time I click on the menu bar in order to load another tab. $inside is a control variable that is setted every time a new tab is loaded; every tab has a different value setted in this variable so the function recognise the elements to delete.. I hope to be clear in the explanations...

thx again to all

Share this post


Link to post
Share on other sites

oMBra

I never figure out what is a dummy control

4got

Me too

It's no hard :P

Example:

#include <GuiConstantsEx.au3>

$hGUI = GUICreate("Dummy control demo", 300, 200)

$Tab = GUICtrlCreateTab(10, 10, 280, 150)

$TabItem = GUICtrlCreateTabItem("Tab 1")

$DummyStart = GUICtrlCreateDummy()

GUICtrlCreateCombo("", 20, 40, 100, 20)

GUICtrlCreateInput("", 180, 40, 100, 20)

GUICtrlCreateEdit("", 20, 80, 260, 60)

$DummyEnd = GUICtrlCreateDummy()

GUICtrlCreateTabItem("")

$ClearButton = GUICtrlCreateButton("Clear", 11, 169, 75, 23)

$CloseButton = GUICtrlCreateButton("Close", 215, 169, 75, 23)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE, $CloseButton
            Exit
        Case $ClearButton
            _Clear()
    EndSwitch
WEnd

Func _Clear()
    Local $iCtl
    
    For $iCtl = $DummyStart To $DummyEnd
        GUICtrlDelete($iCtl)
    Next
EndFunc   ;==>_Clear

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

It's no hard :P

Example:

#include <GuiConstantsEx.au3>

$hGUI = GUICreate("Dummy control demo", 300, 200)

$Tab = GUICtrlCreateTab(10, 10, 280, 150)

$TabItem = GUICtrlCreateTabItem("Tab 1")

$DummyStart = GUICtrlCreateDummy()

GUICtrlCreateCombo("", 20, 40, 100, 20)

GUICtrlCreateInput("", 180, 40, 100, 20)

GUICtrlCreateEdit("", 20, 80, 260, 60)

$DummyEnd = GUICtrlCreateDummy()

GUICtrlCreateTabItem("")

$ClearButton = GUICtrlCreateButton("Clear", 11, 169, 75, 23)

$CloseButton = GUICtrlCreateButton("Close", 215, 169, 75, 23)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE, $CloseButton
            Exit
        Case $ClearButton
            _Clear()
    EndSwitch
WEnd

Func _Clear()
    Local $iCtl
    
    For $iCtl = $DummyStart To $DummyEnd
        GUICtrlDelete($iCtl)
    Next
EndFunc   ;==>_Clear
now I got it.... Edited by 4got

Share this post


Link to post
Share on other sites

basically it hold some control ?

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

basically it hold some control ?

It's a sort of delimiter.In this case is used to delete easily a list of elements with a for cycle.

Guys I'm sorry but solved a problem there are another hundred: Now I have a problem with a double while cycle:

CODE

While 1

$Msg = GUIGetMsg()

Select

Case $Msg=$ping_normal

$tab=GUICtrlCreateTab(8, 40, 529, 345)

$Label1=GUICtrlCreateLabel("Label1 :",30,55)

$Label2=GUICtrlCreateLabel("Label2 :",160,55)

...

...

$start=GUICtrlCreateButton("Start",300,50,60,25)

$start=GUICtrlCreateButton("Exit",300,200,60,25)

while 1

$msg=GUIGetMsg()

Select

Case $msg=$start

MsgBox(0,"ping","ping")

Case $msg=$exit

ExitLoop

EndSelect

wend

Case $Msg=$GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

Now when I click on the EXIT button the program should exit this while loop:

CODE

while 1

$msg=GUIGetMsg()

Select

Case $msg=$start

MsgBox(0,"ping","ping")

Case $msg=$exit

ExitLoop

EndSelect

wend

Or am I wrong?

Because when I click on the button the program exit the first while loop...

Edited by 4got

Share this post


Link to post
Share on other sites

It's a sort of delimiter.In this case is used to delete easily a list of elements with a for cycle.

Guys I'm sorry but solved a problem there are another hundred: Now I have a problem with a double while cycle:

CODE

While 1

$Msg = GUIGetMsg()

Select

Case $Msg=$ping_normal

$tab=GUICtrlCreateTab(8, 40, 529, 345)

$Label1=GUICtrlCreateLabel("Label1 :",30,55)

$Label2=GUICtrlCreateLabel("Label2 :",160,55)

...

...

$start=GUICtrlCreateButton("Start",300,50,60,25)

$start=GUICtrlCreateButton("Exit",300,200,60,25)

while 1

$msg=GUIGetMsg()

Select

Case $msg=$start

MsgBox(0,"ping","ping")

Case $msg=$exit

ExitLoop

EndSelect

wend

Case $Msg=$GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

Now when I click on the EXIT button the program should exit this while loop:

CODE

while 1

$msg=GUIGetMsg()

Select

Case $msg=$start

MsgBox(0,"ping","ping")

Case $msg=$exit

ExitLoop

EndSelect

wend

Or am I wrong?

Because when I click on the button the program exit the first while loop...

You need to have a different variable name for the return from GuiGetMsg() in each loop or the check which exits theinner loop will also be true to exit the outer loop.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

in the first loop the name is $Msg ,in the second is $msg..I try to change the name but it doesn't work...

Share this post


Link to post
Share on other sites

in the first loop the name is $Msg ,in the second is $msg..I try to change the name but it doesn't work...

AutoIt is not case sensitive so $Msg and $msg are the same. Use something like $Msg and $nMsg

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

AutoIt is not case sensitive so $Msg and $msg are the same. Use something like $Msg and $nMsg

I tryied with $Msg and $message but it's the same thing...

Share this post


Link to post
Share on other sites

Post the whole thing again and I'll take a look at it. I just don't feel like getting bits and pieces from different posts. Just post what you actually have so far.


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

CODE

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <GuiIPAddress.au3>

#include <StaticConstants.au3>

#include <TabConstants.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ###

;---------------------------------windows and icon used--------------------------------

$gui = GUICreate("REMOTE CONTROLLER V3.0 BY 4got", 548, 407, 341, 177)

;GUISetIcon("")

;----------------------------------disclaimer's page-----------------------------------

$tab = GUICtrlCreateTab(8, 40, 529, 345)

GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)

$Group1 = GUICtrlCreateGroup("Disclaimer:", 16, 56, 497, 161)

GUICtrlCreateEdit("xxx", 88, 96, 393, 89,$ES_READONLY)

$Icon1 = GUICtrlCreateIcon("xxx", 0, 24, 80, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))

GUICtrlCreateGroup("", -99, -99, 1, 1)

$Pic1 = GUICtrlCreatePic("xxx", 16, 224, 497, 153) ;Image

;-----------------------------------IP box---------------------------------------------

$ip_label = GUICtrlCreateLabel("IP Server", 8, 8, 63, 20)

GUICtrlSetFont(-1, 10, 800, 0, "Arial")

$ip_remote=GUICtrlCreateInput("0.0.0.0",72, 4, 89, 25)

;$IPAddress1 = _GUICtrlIpAddressCreate($gui, 72, 4, 137, 25)

;$ip_remote=_GUICtrlIpAddressSet($IPAddress1, "0.0.0.0")

;-----------------------------------menu----------------------------------------------

;-----ping menu-----

$ping = GUICtrlCreateMenu("Ping")

$ping_normal=GUICtrlCreateMenuItem("Normal Ping",$ping)

$ping_scan_ip=GUICtrlCreateMenuItem("IP scan",$ping)

$ping_scan_port=GUICtrlCreateMenuItem("Port scan",$ping)

;-------------------------------------------------------------------------------------

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

;-----------------------------function to clear the tab space--------------------------

Func clear($inside)

If $inside=0 Then

$tab1=$tab

$tab2=$Icon1

For $n=$tab1 To $tab2

GUICtrlDelete($n)

next

EndIf

EndFunc

;-------------------------------------------------------------------------------------

$tab_inside=0

While 1

$Msg = GUIGetMsg()

Select

Case $Msg=$ping_normal

clear($tab_inside)

$tab_inside="ping_normal"

$tab=GUICtrlCreateTab(8, 40, 529, 345)

$Label_port=GUICtrlCreateLabel("Port :",30,55)

$Label_delay=GUICtrlCreateLabel("Delay :",160,55)

$delay=GUICtrlCreateInput("10",200,50,60,25,$ES_READONLY)

$updown=GUICtrlCreateUpdown($delay)

GUICtrlSetLimit($updown,"100","1")

$port=GUICtrlCreateInput("80",60,50,60,25)

$listaip=GUICtrlCreateEdit("",15,100,515,100,$ES_READONLY)

$start_normal_ping=GUICtrlCreateButton("Ping",300,50,60,25)

$exit=GUICtrlCreateButton("EXIT",380,50,60,25)

while 1

$message=GUIGetMsg()

Select

Case $message=$start_normal_ping

MsgBox(0,"ping","ping")

$ip=GUICtrlRead($ip_remote) ;trova problema con loop

$del=GUICtrlRead($delay)

$por=GUICtrlRead($port)

$result=Ping($ip,$del)

If $result=0 Then ;if the ping hasn't a good result

;--------------------LIST OF VARIOUS ERROR -----------------------

$err=@error

Select

case $err=1

GUICtrlSetData($listaip,"Host is offline")

case $err=2

GUICtrlSetData($listaip,"Host is unreachable")

case $err=3

GUICtrlSetData($listaip,"Bad destination")

case $err=4

GUICtrlSetData($listaip,"Unknown error")

EndSelect

;-----------------------------------------------------------------

Else

GUICtrlSetData($listaip,"Host is online") ;if the ping has a good result

EndIf

Case $message=$exit

ExitLoop(1)

EndSelect

wend

;$result = RunWait(@ComSpec & " /c ping www.google.com", "", @SW_HIDE)

;MsgBox(0, "Trial 1", "Result of google ping: " & $result)

;$result = RunWait(@ComSpec & " /c ping www.goble-de-gook.com", "", @SW_HIDE)

;MsgBox(0, "Trial 2", "Result of garbage ping: " & $result)

Case $Msg=$GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

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