Board index » delphi » How to trap RadioGroupClick event?

How to trap RadioGroupClick event?

Can anyone help me on this?

I am using a procedure TForm1.RadioGroup1Click which to detect click
events. However when I change the index from another procedure I would
like to disable that RadioGroup1Click event.

After I change the ItemIndex How should I trap a message that causes
RadioGroupClick event to fire?

I trying to get up to speed on event handling in Delphi. Is this covered
anywhere? Any input would be greatly appreciated.

 

Re:How to trap RadioGroupClick event?


Quote
Brad Koehler wrote:

> Can anyone help me on this?

> I am using a procedure TForm1.RadioGroup1Click which to detect click
> events. However when I change the index from another procedure I would
> like to disable that RadioGroup1Click event.

> After I change the ItemIndex How should I trap a message that causes
> RadioGroupClick event to fire?

You need to declare a flag variable at form level.  Set it before you
set the item index, and clear it after its set.  In the event handler
for the click, check this flags status, if true then the click has been
generated by code and you can exit.

Quote
> I trying to get up to speed on event handling in Delphi. Is this covered
> anywhere? Any input would be greatly appreciated.

All event handling in documented heavily in the OLH.  Any questions
could be directed to this newsgroup, as you have discovered ;-)

--
Mark.

Re:How to trap RadioGroupClick event?


Re: How to trap RadioGroupClick event?

An Event Handler is nothing more than a property wich type is a
procedure pointer.
The solution is to dynamically change that property:

To activate the handler :

  form1.radiogroup1.onclick := @form1.radiogroup1click;

to de-activate it :

  form1.radiogroup1.onclick := nil;

Re:How to trap RadioGroupClick event?


Quote
Damien Thouvenin wrote:

> Re: How to trap RadioGroupClick event?

> An Event Handler is nothing more than a property wich type is a
> procedure pointer.
> The solution is to dynamically change that property:

> To activate the handler :

>   form1.radiogroup1.onclick := @form1.radiogroup1click;

> to de-activate it :

>   form1.radiogroup1.onclick := nil;

Another option, but I prefer the flag option as it allows a little more
flexibility since the event handler is called every time.

--
Mark.

Re:How to trap RadioGroupClick event?


Quote
Brad Koehler wrote:

> Can anyone help me on this?

> I am using a procedure TForm1.RadioGroup1Click which to detect click
> events. However when I change the index from another procedure I would
> like to disable that RadioGroup1Click event.

> After I change the ItemIndex How should I trap a message that causes
> RadioGroupClick event to fire?

> I trying to get up to speed on event handling in Delphi. Is this covered
> anywhere? Any input would be greatly appreciated.

=============================
   I am not quite understand your question, but the following code
may help you.
  Regards
   Boonlert

procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
  Label1.Caption := IntToStr(RadioGroup1.ItemIndex);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  RadioGroup1.OnClick := nil;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  RadioGroup1.OnClick := RadioGroup1Click;
  RadioGroup1.ItemIndex := 4;
end;

Re:How to trap RadioGroupClick event?


Quote
Brad Koehler wrote:

> Can anyone help me on this?

> I am using a procedure TForm1.RadioGroup1Click which to detect click
> events. However when I change the index from another procedure I would
> like to disable that RadioGroup1Click event.

> After I change the ItemIndex How should I trap a message that causes
> RadioGroupClick event to fire?

> I trying to get up to speed on event handling in Delphi. Is this covered
> anywhere? Any input would be greatly appreciated.

======================
   I am not quite understand your question, but the following code
may help you.
  Regards
   Boonlert

procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
  Label1.Caption := IntToStr(RadioGroup1.ItemIndex);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  RadioGroup1.OnClick := nil;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  RadioGroup1.OnClick := RadioGroup1Click;
  RadioGroup1.ItemIndex := 4;
end;

Other Threads