Board index » delphi » OnClick Event (Don't Change that Checkbox!)

OnClick Event (Don't Change that Checkbox!)

The OnClick event is fired whenever a TCheckbox's Checked property gets
changed. How can I avoid this? I only want the Event to fire off if the user
actually clicked the checkbox, and not if I change it's value in code.

For example, I have a form that has some values on it. The user clicks the
checkbox and the procedure takes these values, does a few calculations and
reposts the new (calculated) values to the form. However, there are conditions
which may not be met at the time of the checkbox getting clicked. The procedure
checks for this, and if the checkbox is not applicable at this time, it tells
the user, and attempts to change the state of the checkbox back to what it was
before the user clicked on it (By stating 'ckCheckbox.Checked := False', Or
ckCheckbox.State := cbUnchecked) as soon as this line is executed, it goes back
up to the top of the procedure and runs it again with the checkbox in it's new
state. i just want to change it's value, not run the whole procedure again.

Any help with this would be most appreciated!!

 

Re:OnClick Event (Don't Change that Checkbox!)


You could try to check the keypress, Mousedown/up-event to see whether there
was a click or a change.
Another way is to set a flag to true at the beginning of the calculation,
change the state afterwards and set the flag the to false. In the
calculation you check wether the flag is true or false (if its true then
dont calculate).

Sorry for the bad english, but i hope you understand it anyway.

--
Andreas Klein
Remove XXX from my eMail

Ulryk schrieb in Nachricht
<1998060516321200.MAA19...@ladder01.news.aol.com>...

Quote
>The OnClick event is fired whenever a TCheckbox's Checked property gets
>changed. How can I avoid this? I only want the Event to fire off if the
user
>actually clicked the checkbox, and not if I change it's value in code.

>For example, I have a form that has some values on it. The user clicks the
>checkbox and the procedure takes these values, does a few calculations and
>reposts the new (calculated) values to the form. However, there are
conditions
>which may not be met at the time of the checkbox getting clicked. The
procedure
>checks for this, and if the checkbox is not applicable at this time, it
tells
>the user, and attempts to change the state of the checkbox back to what it
was
>before the user clicked on it (By stating 'ckCheckbox.Checked := False', Or
>ckCheckbox.State := cbUnchecked) as soon as this line is executed, it goes
back
>up to the top of the procedure and runs it again with the checkbox in it's
new
>state. i just want to change it's value, not run the whole procedure again.

>Any help with this would be most appreciated!!

Re:OnClick Event (Don't Change that Checkbox!)


Quote
Ulryk wrote:
> The OnClick event is fired whenever a TCheckbox's Checked property gets
> changed. How can I avoid this? I only want the Event to fire off if the user
> actually clicked the checkbox, and not if I change it's value in code.

Another approach might be during your calculations set the OnClick event
to NIL, change your check box or do whatever you have to do, then set
the OnClick value of the control back to the MyCheckBoxClick method.
Easy.

Other approaches include some kind of boolean checking in the beginning
of the OnClick event (I think these have been covered with some detail
already).

Re:OnClick Event (Don't Change that Checkbox!)


Put your checkbox specific code in the onmousedown/onmouseup events.
ash

On Fri, 05 Jun 1998 13:02:01 -0600, Mike Powell <mi...@rt66.com>
wrote:

Quote
>Ulryk wrote:

>> The OnClick event is fired whenever a TCheckbox's Checked property gets
>> changed. How can I avoid this? I only want the Event to fire off if the user
>> actually clicked the checkbox, and not if I change it's value in code.

>Another approach might be during your calculations set the OnClick event
>to NIL, change your check box or do whatever you have to do, then set
>the OnClick value of the control back to the MyCheckBoxClick method.
>Easy.

>Other approaches include some kind of boolean checking in the beginning
>of the OnClick event (I think these have been covered with some detail
>already).

Other Threads