Sign in to follow this  
Followers 0
JohnRichard

how to reset the GUIForm

10 posts in this topic

i was wondering how will i reset my main gui window. my GUI window has an Inputbox, Checkboxes and Edit control. It also has a browse button, reset button, backup button and Exit button. When i clicked on Backup button it will display a message on the Edit control with corresponding checkbox option. What i want to happen is that when i click on the Reset button, the checkboxes will be deselected and the text on the Edit control will disappear as if i will start the program. what script will do that?

this is the GUIForm Code:

$Form1 = GUICreate("Backup", 491, 377, -1, -1)

GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")

$Group1 = GUICtrlCreateGroup("Select Folder to Backup", 48, 75, 393, 126)

$Documents_Checkbox = GUICtrlCreateCheckbox("My Documents", 72, 115, 97, 25)

GUICtrlSetOnEvent($Documents_Checkbox, "Documents_CheckboxClick")

$Favorites_Checkbox = GUICtrlCreateCheckbox("Favorites", 72, 157, 97, 25)

GUICtrlSetOnEvent($Favorites_Checkbox, "Favorites_CheckboxClick")

$Desktop_CheckBox = GUICtrlCreateCheckbox("Desktop", 310, 115, 97, 25)

GUICtrlSetOnEvent($Desktop_CheckBox, "Desktop_CheckBoxClick")

$Outlook_CheckBox = GUICtrlCreateCheckbox("MS Outlook", 310, 157, 97, 25)

GUICtrlSetOnEvent($Outlook_CheckBox, "Outlook_CheckBoxClick")

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

$Edit = GUICtrlCreateEdit("", 48, 240, 393, 65, $ES_READONLY)

$Backup_Button = GUICtrlCreateButton("Backup", 49, 328, 113, 33, 0)

GUICtrlSetFont($Backup_Button, 8, 800, 0, "MS Sans Serif")

GUICtrlSetOnEvent($Backup_Button, "Backup_Buttonclick")

$Reset_Button = GUICtrlCreateButton("Reset", 190, 328, 113, 33, 0)

GUICtrlSetFont($Reset_Button, 8, 800, 0, "MS Sans Serif")

$Exit_Button = GUICtrlCreateButton("Exit", 330, 328, 113, 33, 0)

GUICtrlSetOnEvent($Reset_Button, "Reset_Buttonclick")

GUICtrlSetFont($Exit_Button, 8, 800, 0, "MS Sans Serif")

GUICtrlSetOnEvent($Exit_Button, "Exit_Buttonclick")

$Backup_Label = GUICtrlCreateLabel("Backup Location:", 50, 26, 104, 17)

GUICtrlSetFont($Backup_Label, 8, 800, 0, "MS Sans Serif")

$Browse_Button = GUICtrlCreateButton("Browse", 351, 12, 89, 33, 0)

GUICtrlSetFont($Browse_Button, 8, 800, 0, "MS Sans Serif")

GUICtrlSetOnEvent($Browse_Button, "Browse_Buttonclick")

$Input = GUICtrlCreateInput("", 160, 23, 185, 21)

GUISetState(@SW_SHOW)

Share this post


Link to post
Share on other sites



You must call guictrlsetData() on every control you want to erase.

Share this post


Link to post
Share on other sites

You must call guictrlsetData() on every control you want to erase.

i dont want to erase instead i wanted to set the form to the original state. Say i want all checkboxes to be unchecked wheni click on reset.

can you give sample code...

i tried but its not working

Share this post


Link to post
Share on other sites

this is my code for the reset button..i can't make it working

Func Reset_Buttonclick()

Local $Favorites = GUICtrlRead($Favorites_Checkbox)

GUICtrlSetData($Favorites_Checkbox, $GUI_UNCHECKED)

EndFunc

how will i clear the form?

Share this post


Link to post
Share on other sites

i dont want to erase instead i wanted to set the form to the original state.

Save data of the controls to global variables. When you want to set to the original state, retrieve the values from the variables.

Share this post


Link to post
Share on other sites

this is my code for the reset button..i can't make it working

Func Reset_Buttonclick()

Local $Favorites = GUICtrlRead($Favorites_Checkbox)

GUICtrlSetData($Favorites_Checkbox, $GUI_UNCHECKED)

EndFunc

how will i clear the form?

I guess it's GuictrlsetState on checkboxes

Share this post


Link to post
Share on other sites

I guess it's GuictrlsetState on checkboxes

i checked the helpfile for guictrlsetstate. i think it is.

but when i modified the code it is even not working

check this

GUICtrlSetState($Favorites_Checkbox, $GUI_UNCHECKED)

when i run the script and click reset, checkbox could not be unchecked.

Share this post


Link to post
Share on other sites

Use some debuggin if the guictrlsetstate is even called.

If so, check it's return value.

Share this post


Link to post
Share on other sites

i was wondering how will i reset my main gui window. my GUI window has an Inputbox, Checkboxes and Edit control. It also has a browse button, reset button, backup button and Exit button. When i clicked on Backup button it will display a message on the Edit control with corresponding checkbox option. What i want to happen is that when i click on the Reset button, the checkboxes will be deselected and the text on the Edit control will disappear as if i will start the program. what script will do that?

this is the GUIForm Code:

$Form1 = GUICreate("Backup", 491, 377, -1, -1)

GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")

$Group1 = GUICtrlCreateGroup("Select Folder to Backup", 48, 75, 393, 126)

$Documents_Checkbox = GUICtrlCreateCheckbox("My Documents", 72, 115, 97, 25)

GUICtrlSetOnEvent($Documents_Checkbox, "Documents_CheckboxClick")

$Favorites_Checkbox = GUICtrlCreateCheckbox("Favorites", 72, 157, 97, 25)

GUICtrlSetOnEvent($Favorites_Checkbox, "Favorites_CheckboxClick")

$Desktop_CheckBox = GUICtrlCreateCheckbox("Desktop", 310, 115, 97, 25)

GUICtrlSetOnEvent($Desktop_CheckBox, "Desktop_CheckBoxClick")

$Outlook_CheckBox = GUICtrlCreateCheckbox("MS Outlook", 310, 157, 97, 25)

GUICtrlSetOnEvent($Outlook_CheckBox, "Outlook_CheckBoxClick")

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

$Edit = GUICtrlCreateEdit("", 48, 240, 393, 65, $ES_READONLY)

$Backup_Button = GUICtrlCreateButton("Backup", 49, 328, 113, 33, 0)

GUICtrlSetFont($Backup_Button, 8, 800, 0, "MS Sans Serif")

GUICtrlSetOnEvent($Backup_Button, "Backup_Buttonclick")

$Reset_Button = GUICtrlCreateButton("Reset", 190, 328, 113, 33, 0)

GUICtrlSetFont($Reset_Button, 8, 800, 0, "MS Sans Serif")

$Exit_Button = GUICtrlCreateButton("Exit", 330, 328, 113, 33, 0)

GUICtrlSetOnEvent($Reset_Button, "Reset_Buttonclick")

GUICtrlSetFont($Exit_Button, 8, 800, 0, "MS Sans Serif")

GUICtrlSetOnEvent($Exit_Button, "Exit_Buttonclick")

$Backup_Label = GUICtrlCreateLabel("Backup Location:", 50, 26, 104, 17)

GUICtrlSetFont($Backup_Label, 8, 800, 0, "MS Sans Serif")

$Browse_Button = GUICtrlCreateButton("Browse", 351, 12, 89, 33, 0)

GUICtrlSetFont($Browse_Button, 8, 800, 0, "MS Sans Serif")

GUICtrlSetOnEvent($Browse_Button, "Browse_Buttonclick")

$Input = GUICtrlCreateInput("", 160, 23, 185, 21)

GUISetState(@SW_SHOW)

See if this helps you with a strategy for your code:

CODE
Func _sSMonitorMenu()

While 1

;Put an INIRead statement here to read the last processed settings

;//Exit Menu After nn Minutes Nil Activity

$MenuCycle = _TimeToTicks(@HOUR, @MIN, @SEC)

$MenuEndCycle = $MenuCycle + $EndMenuTimer * 60 * 1000

;//User Interface

GUICreate($Title, 240, 320, -1, -1)

GUISetBkColor(0xE0FFFF)

GUISetState()

;//Report in hh Format

GUICtrlCreateLabel("Schedule Daily Report [hh]:", 200, 290, 150, 20)

$ispReport = GUICtrlCreateInput($s_ReportTime, 350, 288, 25, 20, $es_right)

If $mprocess = 26 Then GUICtrlSetState(-1, $GUI_FOCUS)

GUICtrlSetLimit(-1, 2)

GUICtrlSetTip(-1, " Compile and Send Daily Report at [00-24] Hours", "Help", 1)

;//Save

$sSsave = GUICtrlCreateButton("Save", 408, 402, 117, 30)

;//Close

$sSExit = GUICtrlCreateButton("Close", 116, 290, 100, 25)

While 1

;//Menu Processor:

If _TimeToTicks(@HOUR, @MIN, @SEC) >= $MenuEndCycle Then

GUIDelete()

ExitLoop (2)

EndIf

$mprocess = 0

$cISPReport = GUICtrlRead($ispReport)

$msg = GUIGetMsg()

Select

;//Exit the Application

Case $msg = $GUI_EVENT_CLOSE Or $msg = $sSExit

GUIDelete()

ExitLoop (2)

Case $msg = $sSsave

ExitLoop

EndSelect

WEnd

While 1

GUIDelete()

;//Reporting 24 Hour Clock [00-23] 00 = Midnight:

If $cISPReport = "" Or $cISPReport > 23 Or StringLen("'" & $cISPReport & "'") <> 4 Then

$mprocess = 26

$TextMsg = "Daily Reporting Hour is in [00-23] FORMAT"

ExitLoop

Else

;iniwrite (to save the information)

EndIf

;Check the next input and so on.

WEnd

WEnd

EndFunc

Share this post


Link to post
Share on other sites

thanks to all who replied, i got it working now with the GUICTRLSETSTATE

GUICtrlSetState($Desktop_CheckBox, $GUI_UNCHECKED)

GUICtrlSetState($Outlook_CheckBox, $GUI_UNCHECKED)

GUICtrlSetData($Edit, "")

GUICtrlSetData($Input, "")

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