System Delphi

Title: How to prevent OnClick when changing CheckBox programmatically
//To prevent it:
procedure SetCheckBox(chk: TCheckBox; B: Boolean);
var
N: TNotifyEvent;
begin
with Chk do
begin
N := OnClick;
OnClick := nil;
Checked := B;
OnClick := N;
end;
end;