| View previous topic :: View next topic |
| Author |
Message |
rw Guest
|
Posted: Wed Apr 12, 2006 10:03 am Post subject: Event Handler |
|
|
Hi
Can anybody help me how to write an OnActivate and OnClose EventHandler for
a TForm which is created during runtime.
Robert |
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Wed Apr 12, 2006 11:03 am Post subject: Re: Event Handler |
|
|
rw wrote:
| Quote: | Can anybody help me how to write an OnActivate and OnClose EventHandler for
a TForm which is created during runtime.
|
You can write that eventhandler at designtime. Take the form from where you will
create the form at runtime and let the IDE create an OnActivate and an OnClose
handler.
Now you now how the eventhandlers have to look like. If you want you can change the
name or first make a copy of them.
For the rest you only have to assign that eventhandler to your newly created
instance of a TForm.
TForm *Form = new TForm (this);
Form->OnClose = FormClose2;
Form->OnActivate = FormActivate2;
Form->Show();
Hans. |
|
| Back to top |
|
 |
rw Guest
|
Posted: Wed Apr 12, 2006 12:03 pm Post subject: Re: Event Handler |
|
|
I just forgot to set the parent.
"rw" <rw (AT) denconfoods (DOT) dk> skrev i en meddelelse
news:443ce2ac (AT) newsgroups (DOT) borland.com...
| Quote: | Hi Hans
That worked so far.
The MessageBox pops up just fine,
but the CheckListBox doesn't show up.
Where am I going wrong.
void __fastcall TForm1::Viskolonne1Click(TObject *Sender)
{
//FColumnSelection->ShowModal();
TForm *Form=new TForm(this);
Form->Position=poMainFormCenter;
Form->Height=300;
Form->Width=300;
Form->OnActivate=FormActivate2;
TCheckListBox *CLB=new TCheckListBox(Form);
CLB->Align=alCLient;
Form->ShowModal();
delete CLB;
CLB=NULL;
delete Form;
Form=NULL;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormActivate2(TObject *Sender)
{
Application->MessageBox("test","test",MB_OK);
}
Rober
|
|
|
| Back to top |
|
 |
rw Guest
|
Posted: Wed Apr 12, 2006 12:03 pm Post subject: Re: Event Handler |
|
|
Hi Hans
That worked so far.
The MessageBox pops up just fine,
but the CheckListBox doesn't show up.
Where am I going wrong.
void __fastcall TForm1::Viskolonne1Click(TObject *Sender)
{
//FColumnSelection->ShowModal();
TForm *Form=new TForm(this);
Form->Position=poMainFormCenter;
Form->Height=300;
Form->Width=300;
Form->OnActivate=FormActivate2;
TCheckListBox *CLB=new TCheckListBox(Form);
CLB->Align=alCLient;
Form->ShowModal();
delete CLB;
CLB=NULL;
delete Form;
Form=NULL;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormActivate2(TObject *Sender)
{
Application->MessageBox("test","test",MB_OK);
}
Rober |
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Wed Apr 12, 2006 1:03 pm Post subject: Re: Event Handler |
|
|
rw wrote:
| Quote: | I just forgot to set the parent.
|
Indeed.
| Quote: | TCheckListBox *CLB=new TCheckListBox(Form);
delete CLB;
|
That was not needed. You will delete Form and while CLB is owned by Form
it will be deleted too.
For a local variable that is never needed. And what do you do with the
warning that the value is never used ?
| Quote: | delete Form;
Form=NULL;
|
ditto.
Please do not repost a whole message.
Hans. |
|
| Back to top |
|
 |
|