Board index » cppbuilder » TCheckBox, TComboBox events

TCheckBox, TComboBox events

Hello,
 Is there a property in TCheckBox and TComboBox which
prevents events such as OnClick occurring when properties
are modified in code e.g. CheckBox1->Checked=true;

 Roger

 

Re:TCheckBox, TComboBox events


This is one way of doing it:

void __fastcall TForm1::CheckBox1Click(TObject *Sender)
{
      ShowMessage("1");

Quote
}

//--------------------------------------------------------------------------
-
void __fastcall TForm1::CheckBox2Click(TObject *Sender)
{
   ShowMessage("2");
Quote
}

//--------------------------------------------------------------------------
-
void __fastcall TForm1::Button1Click(TObject *Sender)
{
   CheckBox1->OnClick = NULL;
   CheckBox2->OnClick = NULL;
   //--
   CheckBox1->Checked = true;
   CheckBox2->Checked = true;
   //--
   CheckBox1->OnClick = CheckBox1Click;
   CheckBox2->OnClick = CheckBox2Click;
Quote
}

//--------------------------------------------------------------------------
-

void __fastcall TForm1::Button2Click(TObject *Sender)
{
   CheckBox1->OnClick = NULL;
   CheckBox2->OnClick = NULL;
   //--
   CheckBox1->Checked = false;
   CheckBox2->Checked = false;
   //--
   CheckBox1->OnClick = CheckBox1Click;
   CheckBox2->OnClick = CheckBox2Click;

Quote
}

Rodolfo

Quote
"Digby Millikan" <dig...@internode.on.net> wrote in message

news:3e8295b0@newsgroups.borland.com...
Quote
> Hello,
>  Is there a property in TCheckBox and TComboBox which
> prevents events such as OnClick occurring when properties
> are modified in code e.g. CheckBox1->Checked=true;

>  Roger

Re:TCheckBox, TComboBox events


There is no such property, no.  You'll just have to set the event handler to
NULL temporary while setting the desired property, then restore the handler
back afterwards, ie:

    TNotifyEvent OldHandler = CheckBox1->OnClick;
    CheckBox1->OnClick = NULL;
    CheckBox1->Checked = true;
    CheckBox1->OnClick = OldHandler;

The other alternative is to use the Tag property (if you're not using it for
anything else, that is) and have the OnClick handler simply return
immediately if the Tag is set, ie:

    CheckBox1->Tag = 1;
    CheckBox1->Checked = true;
    CheckBox1->Tag = 0;

    void __fastcall TForm1::CheckBox1Click(TObject *Sender)
    {
        if( CheckBox1->Tag == 1 )
            return;
        // ...
    }

Gambit

Quote
"Digby Millikan" <dig...@internode.on.net> wrote in message

news:3e8295b0@newsgroups.borland.com...
Quote
>  Is there a property in TCheckBox and TComboBox which
> prevents events such as OnClick occurring when properties
> are modified in code e.g. CheckBox1->Checked=true;

Re:TCheckBox, TComboBox events


Is there likelyness they would consider creating a property
for suppressing events in a BCB future release?

 Roger

Re:TCheckBox, TComboBox events


Very doubtful.  There's no way to suppress such behavior externally.  Events
are just function pointers to user-defined functions.  The components are
calling those functions directly when appropriate, so there's no real way to
prevent it.

Gambit

Quote
"Digby Millikan" <dig...@internode.on.net> wrote in message

news:3e83dcd0$1@newsgroups.borland.com...
Quote
> Is there likelyness they would consider creating a
> property for suppressing events in a BCB future release?

Other Threads