BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Event Handler

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
rw
Guest





PostPosted: Wed Apr 12, 2006 10:03 am    Post subject: Event Handler Reply with quote



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





PostPosted: Wed Apr 12, 2006 11:03 am    Post subject: Re: Event Handler Reply with quote



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





PostPosted: Wed Apr 12, 2006 12:03 pm    Post subject: Re: Event Handler Reply with quote



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





PostPosted: Wed Apr 12, 2006 12:03 pm    Post subject: Re: Event Handler Reply with 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
Hans Galema
Guest





PostPosted: Wed Apr 12, 2006 1:03 pm    Post subject: Re: Event Handler Reply with quote

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.

Quote:
CLB=NULL;

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.