Board index » cppbuilder » Property is empty when it isn't

Property is empty when it isn't


2004-07-03 05:16:46 AM
cppbuilder48
I have an AnsiString property that is set in the IDE and I want
to use in the components constructor but when I do, the
property is empty. For example, the following displays an empty
string:
if( !ComponentState.Contains(csDesigning) )
{
ShowMessage( PropertyName );
}
However, if I check it in the form's constructor it displays
correctly.
~ JD
 
 

Re:Property is empty when it isn't

"JD" < XXXX@XXXXX.COM >wrote in message
Quote
I have an AnsiString property that is set in the IDE
and I want to use in the components constructor
but when I do, the property is empty.
You cannot do what you are asking for. Property values have not been
streamed from the DFM yet when the constructor is executing. You have to
wait until the property is actually assigned before you can use its value.
Quote
However, if I check it in the form's constructor
it displays correctly.
The DFM is streamed during TCustomForm's construction.
Gambit
 

Re:Property is empty when it isn't

"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote
You cannot do what you are asking for. Property values have
not been streamed from the DFM yet when the constructor is
executing. [...]
Not what I wanted to hear. I was hoping to make it 'automatic'
but I guess calling an Activate method in the form's ctor isn't
the end of the world.
~ JD
 

{smallsort}

Re:Property is empty when it isn't

"JD" < XXXX@XXXXX.COM >wrote in message
Quote
Not what I wanted to hear.
Then you need to explain exactly what you are trying to accomplish in the
first place.
Gambit
 

Re:Property is empty when it isn't

"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote
Then you need to explain exactly what you are trying to
accomplish in the first place.
The ultimate objective to have a component that can be dropped
on the main form, set a couple of properties and the component
will handle 'authorizing' the application to run.
The desired visual effect is to have zero screen output if the
program is not authorized to run so using the properties in
the ctor seemed like the solution.
If I hard code the properties, it works as expected but that
defeats the point of having something that's reusable. I just
want to be able to drop it, set it and forget it.
I just thought of this but I'm not sure how to impliment. I
could move the code in the ctor to an Activate method, set the
application's ShowMainForm to false in the ctor, start a
thread that waits for streaming to finish and terminates in
such a way as to cause the Activate method to execute. The
Activate method then either sets ShowMainForm to true or calls
Application->Terminate.
How 'bout that?
~ JD
 

Re:Property is empty when it isn't

"JD" < XXXX@XXXXX.COM >wrote in message
Quote
The ultimate objective to have a component that can
be dropped on the main form, set a couple of properties
and the component will handle 'authorizing' the application
to run.
Then you should override the component's Loaded() method so that you can
wait until after the DFM has finished streaming all of the property values
before you then act on them.
Quote
The desired visual effect is to have zero screen output
if the program is not authorized to run so using the
properties in the ctor seemed like the solution.
Why use a component for that? Just check the credentials inside of
WinMain() directly before any forms are created at all.
Quote
If I hard code the properties, it works as expected
but that defeats the point of having something that's
reusable. I just want to be able to drop it, set it and forget it.
What about using premade components/libraries that already do that?
Quote
I could move the code in the ctor to an Activate method,
set the application's ShowMainForm to false in the ctor,
start a thread that waits for streaming to finish and terminates
in such a way as to cause the Activate method to execute.
That is not a good design choice.
Gambit
 

Re:Property is empty when it isn't

"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote
Then you should override the component's Loaded() method so
that you can wait until after the DFM has finished streaming
all of the property values before you then act on them.
That sounds like the solution.
Quote
Why use a component for that? Just check the credentials
inside of WinMain()
That's what we're doing now. It's basically the same code for
nearly everything we do. Granted we don't turn out that many
executables but there are enough and you wouldn't believe some
of the stuff - well YOU would - that these guys put in there.
Quote
What about using premade components/libraries that already do that?
There's really only one 'rule' that we have and that's that no
3rd party stuff unless it comes with source code (and it's free
because that's what we get paid for). It's hard to argue with
that.
Quote
That is not a good design choice.
LOL. I was VERY TIRED!!
~ JD