Hi all,
I once had an "strange" problem with checkboxes.
In a routine I needed a button that i could click, if I wanted to refresh variables i a program.
And this action should be visible until the refresh was done (about 3 seconds)
So if this was a Button, I would change Color to Red to indicate that the process was running.
And after running the Button returns normal color.
But a Button can not change color, so i used a checkbox instead.
And now the circus started.....
Code: Select all
//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
//Checkbox test
Dialog>Dialog1
object Dialog1: TForm
Left = 438
Top = 165
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 223
ClientWidth = 484
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object CheckBox3: TCheckBox
Left = 74
Top = 86
Width = 97
Height = 17
Caption = 'CheckBox3'
TabOrder = 0
end
end
EndDialog>Dialog1
AddDialogHandler>dialog1,checkbox3,OnClick,DoRefresh
AddDialogHandler>Dialog1,,OnClose,DoClose
Show>Dialog1
let>VarRefresh=0
let>Terminated=False
label>WaitForAction
if>VarRefresh=1
let>VarRefresh=0
SetDialogProperty>Dialog1,Checkbox3,Checked,True
Message>-
Message>now refreshing variables routine !!
wait>1
Message>-
SetDialogProperty>Dialog1,Checkbox3,Checked,False
endif
if>Terminated=True
CloseDialog>Dialog1
goto>closeprogramm
endif
wait>2
goto>WaitForAction
SRT>DoClose
Let>Terminated=True
End>DoClose
SRT>DoRefresh
Let>VarRefresh=1
END>DoRefresh
Label>closeprogramm
The Dialog starts,
shows a checkbox
if you click on the checkbox, a SRT set variable VarRefresh to 1
In the main loop, I see that the VarRefresh is 1 (active) .
The first thing I do, is setting the VarRefresh to 0
Than I refresh my variables
And then I return to the main loop....
See what happens !
The loop keeps on going refreshing !!
SPOILER ALERT do not read below this line if you want to find the cause yourself !!
---------------------------------------------------------------------------------
The dialoghandler got activated each time you run
SetDialogProperty>Dialog1,Checkbox3,Checked,True
This fires SRT>DoRefresh (so the "Checked" activates a "OnClick" event)
well this all is not shocking, but it kept me busy for while because I was debugging it, and while debugging the variable VarRefresh was (stepping with F8) always the right value, but running it "live" it kept in a loop.
Hope this helps you with your problem with the Checkboxes
Kind regards,
Djek