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 

Re: I can not Recognize Designe time & Run time mode in my C

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





PostPosted: Wed Aug 27, 2003 2:00 pm    Post subject: Re: I can not Recognize Designe time & Run time mode in my C Reply with quote




Thanks
You are ver smart!, but I am writing a Component and it
must be set automatically. I don't access to your Form Okay!!

"Rodolfo Frino" <rodolfofrino (AT) yahoo (DOT) com> wrote:
Quote:
At design time set the property to false
Timer1->Enabled = false;

or if appropriate, set it to false when the main form is created inside the
form's
constructor,

__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Timer1->Enabled = false;
}

Then, in your code set it to true when the event that is supposed to
trigger the timer occurs, for example:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Timer1->Enabled = true;
}

or when a particular part or youer code is
executed.


Rodolfo




Back to top
Ralph Kazemier
Guest





PostPosted: Wed Aug 27, 2003 10:28 pm    Post subject: Re: I can not Recognize Designe time & Run time mode in my C Reply with quote




"Jialing" <Jialing (AT) yaho (DOT) com> wrote

Quote:

I write a Component an put into it a Timer.
I want set Enabled Property of Time to true it at
Run time not Design time.
The value of ComponentState is constant at Design time and
Run time and is dependent to Creation time.
How can I do this?

The ComponentState property of the TTimer instance is constant as it should.
It's not the component being designed. You have to check the ComponentState
of your component instead. Furthermore, since the TTimer instance is
encapsulated in your component, its properties will not be streamed to dfm.
You will need to take care of that yourself. Simply introduce a property on
your component which reflects the Enabled property of the TTimer instance.
Use the virtual function Loaded() to set the Enabled property of the TTimer
instance when the component is not in design mode.

Here is an example;

class TComponentWithTimer: public TComponent {
protected:
bool FTimerEnabled;
TTimer* FTimer;

void __fastcall SetTimerEnabled(bool Value) {
if(!ComponentState.Contains(csDesigning)) {
FTimer->Enabled=Value;
}
FTimerEnabled=Value;
}

public:
__fastcall TComponentWithTimer(TComponent* Owner):
FTimerEnabled(false),
FTimer(new TTimer(this))
{
FTimer->Enabled=false;
}

virtual void __fastcall Loaded() {
TComponent::Loaded();
if(!ComponentState.Contains(csDesigning)) {
FTimer->Enabled=FTimerEnabled;
}
}

__published:
__property bool
TimerEnabled={read=FTimerEnabled,write=SetTimerEnabled,default=false};

};


Ralph




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) 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.