I have a problem with the TCheckbox. Whenever I set it's
Checked-Property to TRUE by code, it fires it's OnClick-event.
I need to display the single bits of a word-value of a database-field.
When opening the query, I need to set the Checked-property of the
checkboxes to display the values of the bits, but when setting them,
they fire OnClick, causing a call to my routine to calculate the new
word value again. How can I prevent that ?
TIA, Dets ...
Rick Rogers (TeamB) schrieb:
> On Wed, 24 Feb 1999 16:15:26 +0100, Dets <de...@caix.net> wrote:
>
> > Whenever I set it's Checked-Property to TRUE by code,
> > it fires it's OnClick-event.
>
> True, that is by design and as documented.
>
> > How can I prevent that ?
>
> Set the event property to nil, like this:
>
> var
> Saved: TNotifyEvent;
> begin
> Saved := CheckBox1.OnClick;
> CheckBox1.OnClick := nil;
> CheckBox1.Checked := { some value };
> CheckBox1.OnClick := Saved;
> end;
>
> Or use a semaphore boolean variable like this:
>
> procedure TForm1.CheckBox1Click(Sender: TObject);
> begin
> if Updating then Exit;
> { Do something useful here }
> end;
>
> begin
> Updating := True;
> CheckBox1.Checked := { some value };
> Updating := False;
> end;
>
> --
> Rick Rogers (TeamB) | Fenestra Technologies
> http://www.fenestra.com/
As Rick has indicated, this is the normal behaviour for the check box.
Question: Do you need to recalc the word value each time a checkbox is
changed, or only when the user posts the record back? If the latter, then
take the code out of the OnClick events and move it to the BeforePost event
of the TTable or TQuery.
--
Wayne Niddery - WinWright Consulting
Delphi, C++Builder, JBuilder, InterDev --
http://home.ican.net/~wniddery/RADBooks.html
...remove chaff when replying...
"You know you've landed gear-up when it takes full power to taxi"
This also costed me hours to fix, and it doesn't really seem
logical to me. Maybe this could be *fixed* in an upcoming
update pack.
Richey
On Wed, 24 Feb 1999 15:25:25 GMT, ri...@fenestra.com (Rick Rogers
(TeamB)) wrote:
>On Wed, 24 Feb 1999 16:15:26 +0100, Dets <de...@caix.net> wrote:
>
>> Whenever I set it's Checked-Property to TRUE by code,
>> it fires it's OnClick-event.
>
>True, that is by design and as documented.
>
>> How can I prevent that ?
>
>Set the event property to nil, like this:
>
>var
> Saved: TNotifyEvent;
>begin
> Saved := CheckBox1.OnClick;
> CheckBox1.OnClick := nil;
> CheckBox1.Checked := { some value };
> CheckBox1.OnClick := Saved;
>end;
>
>Or use a semaphore boolean variable like this:
>
>procedure TForm1.CheckBox1Click(Sender: TObject);
>begin
> if Updating then Exit;
> { Do something useful here }
>end;
>
>begin
> Updating := True;
> CheckBox1.Checked := { some value };
> Updating := False;
>end;
_______________________________________________________________
http://Inner-Smile.com, home of:
INF-Tool - create *smaller* setup packages for your programs!
Resource-Grabber - giving you 1000's of glyphs,images,icons,sounds..
Richey's Delphi-Box - 1000+ links and answers for Delphi developers
..one of the best starting points for Delphi developers worldwide..
> Maybe this could be *fixed* in an upcoming
> update pack.
>
It is not broken in the first place.
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitely requested!
>Hi there.
>
>I have a problem with the TCheckbox. Whenever I set it's
>Checked-Property to TRUE by code, it fires it's OnClick-event.
>
>I need to display the single bits of a word-value of a database-field.
>When opening the query, I need to set the Checked-property of the
>checkboxes to display the values of the bits, but when setting them,
>they fire OnClick, causing a call to my routine to calculate the new
>word value again. How can I prevent that ?
>
>TIA, Dets ...
>
Try this
procedure CheckNoClick( const aCB: TCheckBox; const aCheckIt:
Boolean);
begin
aCB.Perform(BM_SETCHECK, Ord(aCheckIt), 0);
end;
Regards,
David Gottschalk