Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

beginners tip on radio buttons

Status
Not open for further replies.

CADTenchy

Technical User
Dec 12, 2007
237
GB

For relative newbies like myself...

This gotcha has been bugging me (sorry!) for two days now.
I've been tearing the last few strands of hair out thinking my routines were doing something really weird.

If you are using radio buttons, be warned that the onClick event is called if you toggle the radio buttons from code!

This can cause unexpected calling of the procedure !

If you just want to capture a click by user with mouse I think it's better to go with onMouseUp.

Hope this saves someone some grief!


Steve (Delphi 2007 & XP)
 
If you are using radio buttons, be warned that the onClick event is called if you toggle the radio buttons from code!

This is normal behavior of Delphi these days, and we ran into that with the MediaPlayer demos of about a month ago...

If you do anything that changes the controls, you disable the event, then re-enable it afterwards.

Code:
OnClick := nil;
{ do stuff to controls here }
OnClick := RadioButtonClickEvent;

----------
Measurement is not management.
 

thanks for the onclick := nil tip.

I didn't read through that thread much, as I figured it wouldn't be applicable to me.

Another tip there....


Steve (Delphi 2007 & XP)
 
Also be aware when making calls to DisableControls.
(From Delphi help:)
Calls to DisableControls can be nested. Only when all calls to DisableControls is matched to a corresponding call to EnableControls does the dataset update data controls and detail datasets.
(See Delphi Help & related topics for details.)

This is particularly important where calls to DisableControls may occur in separate units, forms or datamodules. The only way to ensure the stack is enabled is by:
Code:
  while DataSet.ControlsDisabled do
    DataSet.EnableControls;
I pulled my hair out once trying to figure out why EnableControls didn't. Hopefully this will help someone avoid the same anguish.

Roo
Delphi Rules!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top