Hi Forum:
Please offer your insight. In below script, I expected the message modal box to appear only once when clicking on Checkbox1. However, the message modal box appears twice. It seems like the dialog handler is firing for Checkbox2 even though the box was not Clicked (per the OnClick event). Am I understanding the expected behavior correctly?
Dialog>Dialog1
object Dialog1: TForm
Left = 306
Top = 98
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 223
ClientWidth = 439
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 CheckBox1: TCheckBox
Left = 57
Top = 20
Width = 97
Height = 17
Caption = 'CheckBox1'
Checked = True
State = cbChecked
TabOrder = 8
end
object CheckBox2: TCheckBox
Left = 57
Top = 119
Width = 97
Height = 17
Caption = 'CheckBox2'
TabOrder = 9
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,CheckBox1,OnClick,DisEnableLogs
AddDialogHandler>Dialog1,CheckBox2,OnClick,DisEnableLogs
show>dialog1,r
SRT>DisEnableLogs
getDialogProperty>Dialog1,CheckBox1,Checked,varLog
If>%varLog%=False
setDialogProperty>Dialog1,CheckBox2,Checked,True
MessageModal>%varLog%
else
setDialogProperty>Dialog1,CheckBox2,Checked,False
MessageModal>%varLog%
endif
END>DisEnableLogs
Dialog Handler Anomaly
Moderators: JRL, Dorian (MJT support)
It appears the setDialogProperty>Dialog1,CheckBox2,Checked,XXX lines are causing the adddialoghandler event for checkbox2 to fire. You can verify this by remarking out that dialog handler line and you can see that picking on checkbox1 then only runs the subroutine once. I don't know if that is what I would expect to see but it appears to be what is happening.
Actually, if setdialogproperty checking the box sets off the dialoghandler, I would expect what you have written to go into an endless loop. Maybe Marcus can explain this.
Actually, if setdialogproperty checking the box sets off the dialoghandler, I would expect what you have written to go into an endless loop. Maybe Marcus can explain this.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
If you have created a handler for the checkbox, OnClick, that may be part of the problem.
It turns out that any change in the status of Checked property will trigger the OnClick routine. So, it you change the property by clicking with a mouse, pressing a space bar, or using SetProperty command, the OnClick will fire.
It has been suggested that the property "Checked" should properly be named something like "CheckStatusChanged". but Marcus is unable to change the name, the subcode Macro Scheduler uses is from another source.
Maybe using a Radio Button vs. a Checkbox might work here? They automatically toggle status of the other choice(s)
It turns out that any change in the status of Checked property will trigger the OnClick routine. So, it you change the property by clicking with a mouse, pressing a space bar, or using SetProperty command, the OnClick will fire.
It has been suggested that the property "Checked" should properly be named something like "CheckStatusChanged". but Marcus is unable to change the name, the subcode Macro Scheduler uses is from another source.
Maybe using a Radio Button vs. a Checkbox might work here? They automatically toggle status of the other choice(s)
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!