Paul E. Schoen
2010-05-21 05:30:17 UTC
I have a form with a RadioGroup component with two choices, but sometimes it
needs to be set programmatically, so I just set the ItemIndex property to 0
or 1 accordingly. However, this seems to trigger the OnClick event which
sets the wrong choice, and it also seems to cause a subsequent click on the
form to trigger the OnClick event. I figure that I might be able to set the
OnClick Event to nil when I set the ItemIndex property, but this does not
seem right.
It also does not seem to work. If I do not set the ItemIndex, everything
seems to work, but the RadioGroup is incorrect.
Well, I got something that seemed to work, but it seems very wrong, and I'm
too tired to think clearly. Here's what I came up with:
//****************************** SetTestType
*********************************
procedure TfmOrt.SetTestType(Mode: TTestMode);
begin
if Mode = NORMAL then
TestTypeSel.ItemIndex := 0
else
TestTypeSel.ItemIndex := 1;
// TestTypeSelClick(self);
// This was superfluous, as cahnging the ItemIndex fired the event
end;
//**************************** TestTypeSelClick
*****************************
procedure TfmOrt.TestTypeSelClick(Sender: TObject);
begin
fmDebug.AddDebugItem( 'SetTestType ' );
if fmSetup.TestMode = NORMAL then begin
fmWaveform.WaveFileName := NORMWAVEFILE;
MaxOps := NormalMaxOps;
OrtUpdate1.OnThreshold := fmCal.Cal.OnThresh;
cbMaxOps.Enabled := True;
MinPickUpCurrent.Visible := FALSE;
MinPUlabel.Visible := FALSE;
fmOrtMeter.Visible := False;
end
else begin
fmWaveform.WaveFileName := MPUWAVEFILE;
MaxOps := 1;
OrtUpdate1.OnThreshold := fmCal.Cal.MPUThresh;
cbMaxOps.Enabled := False;
MinPickUpCurrent.Text := '';
MinPickUpCurrent.Visible := TRUE;
MinPUlabel.Visible := TRUE;
fmOrtMeter.Visible := True;
if fmSetup.MaxOnTime < 10 then
fmSetup.MaxOnTime := 10;
end;
SetMaxOps( MaxOps );
ResetData;
fmDebug.AddDebugItem( 'End SetTestType ' );
end;
Originally I had the SetTestType procedure do what is now done in the
TestTypeSelClick handler, as well as setting the ItemIndex. Now it only sets
the ItemIndex. But it still doesn't work right. I've tried all sorts of
things to no avail. This seems like a simple thing. I'll try a little more,
but I'm about beat. I'll follow up if I find a solution. Any ideas?
Thanks,
Paul
needs to be set programmatically, so I just set the ItemIndex property to 0
or 1 accordingly. However, this seems to trigger the OnClick event which
sets the wrong choice, and it also seems to cause a subsequent click on the
form to trigger the OnClick event. I figure that I might be able to set the
OnClick Event to nil when I set the ItemIndex property, but this does not
seem right.
It also does not seem to work. If I do not set the ItemIndex, everything
seems to work, but the RadioGroup is incorrect.
Well, I got something that seemed to work, but it seems very wrong, and I'm
too tired to think clearly. Here's what I came up with:
//****************************** SetTestType
*********************************
procedure TfmOrt.SetTestType(Mode: TTestMode);
begin
if Mode = NORMAL then
TestTypeSel.ItemIndex := 0
else
TestTypeSel.ItemIndex := 1;
// TestTypeSelClick(self);
// This was superfluous, as cahnging the ItemIndex fired the event
end;
//**************************** TestTypeSelClick
*****************************
procedure TfmOrt.TestTypeSelClick(Sender: TObject);
begin
fmDebug.AddDebugItem( 'SetTestType ' );
if fmSetup.TestMode = NORMAL then begin
fmWaveform.WaveFileName := NORMWAVEFILE;
MaxOps := NormalMaxOps;
OrtUpdate1.OnThreshold := fmCal.Cal.OnThresh;
cbMaxOps.Enabled := True;
MinPickUpCurrent.Visible := FALSE;
MinPUlabel.Visible := FALSE;
fmOrtMeter.Visible := False;
end
else begin
fmWaveform.WaveFileName := MPUWAVEFILE;
MaxOps := 1;
OrtUpdate1.OnThreshold := fmCal.Cal.MPUThresh;
cbMaxOps.Enabled := False;
MinPickUpCurrent.Text := '';
MinPickUpCurrent.Visible := TRUE;
MinPUlabel.Visible := TRUE;
fmOrtMeter.Visible := True;
if fmSetup.MaxOnTime < 10 then
fmSetup.MaxOnTime := 10;
end;
SetMaxOps( MaxOps );
ResetData;
fmDebug.AddDebugItem( 'End SetTestType ' );
end;
Originally I had the SetTestType procedure do what is now done in the
TestTypeSelClick handler, as well as setting the ItemIndex. Now it only sets
the ItemIndex. But it still doesn't work right. I've tried all sorts of
things to no avail. This seems like a simple thing. I'll try a little more,
but I'm about beat. I'll follow up if I find a solution. Any ideas?
Thanks,
Paul