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 

Link to a Form from a component

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





PostPosted: Thu Feb 05, 2004 8:12 pm    Post subject: Link to a Form from a component Reply with quote



Hi,

I can't find a good solution to following problem:

- Given a TCustomMaskEdit derived component which handles data input and
extends the validity checking already included in the component, thus it
does not require additional programming in the target application. For
instance, a numeric input with range check, or a string input present (or
not present) in a given container etc.

- As it is required to be self-sufficient, it can not use exceptions for the
validity errors it handles. So it overrides ValidateError and handles the
displaying of the appropriate error message. Additional properties supply
detailed information to the user.

- Finding the standard Window Dialogs not ideal to display such extended
error informations, I prepared a message-display-form to be shown modal. It
works fine and does what required. The form is called TMsgForm.

- But now the problem: The Editing component must 'link' to the TMsgForm in
order to get the error displayed, but it can/should not include its header
as it is part of a project only and not of a precompiled package. On the
contarry, to include from other components compiled into the same package
would be acceptable.

- Further the editing component should be capable to identify in runtime the
presence of this form (e.g. scanning the TScreen-> Forms list) but again
needs the TMsgForm type to dynamic cast.

- An event to display can't be used as the process flow should stop until
the error is acknowledged.

- Adding to the editor component a function pointer for the error display
handling, this should be initialized by the component's contructor to
achieve the self-sufficiency, so with the same include problem.

Any suggestion ?

Have also considered some alternatives, but can't do without help:

- The TMsgForm could be made a component and compiled to the same package.
I've read on this newsgroup that a TCustomForm derivate can't be made to a
new component. Is that true? Eventually, it could be made only available to
runtime installation. Could that be then compiled to a component?

- Any other display solution not involving a Form or Frame? My TMsgForm
containes a TImage to display an Icon, a TMemo for the message display, a
TTimer for an automatic timeout closure with an associated TProgressBar,
intercepts both keys and mouse to turn off the time count (CLICK or SPACE)
as well as to close thereafter (second CLICK or SPACE) or anytime (ESC or
RETURN). Will probably have to add some Hint and Help later.


Thanks, Martin





Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Feb 05, 2004 10:30 pm    Post subject: Re: Link to a Form from a component Reply with quote




"Martin Moeller" <martin.moeller (AT) moema (DOT) it> wrote


Quote:
- But now the problem: The Editing component must 'link' to
the TMsgForm in order to get the error displayed, but it
can/should not include its header

Why not? You need to in order to instantiate the form.

Quote:
as it is part of a project only and not of a precompiled package.

Why can't you simply add the TMsgForm's unit to the edit component's
package?

Quote:
- Further the editing component should be capable to identify
in runtime the presence of this form (e.g. scanning the
TScreen-> Forms list) but again needs the TMsgForm type to
dynamic cast.

Why can't you simply instantiate a new instance when you actually need it
and then free it when you are done? Then you don't have any dependancies on
the application creating the form ahead of time. Or are you trying to set
it up so that there can only be a single instance of the form present at any
given time and all errors from all instances of the edit component go to a
single form for display?

Quote:
- The TMsgForm could be made a component and compiled to
the same package. I've read on this newsgroup that a TCustomForm
derivate can't be made to a new component. Is that true? Eventually,
it could be made only available to runtime installation. Could that be
then compiled to a component?

It doesn't need to be an actual component. Just add the form's .cpp and
..dfm files to the package and then dynamically instantiate the form at
runtime via the 'new' operator when needed.


Gambit



Back to top
Martin Moeller
Guest





PostPosted: Fri Feb 06, 2004 10:35 am    Post subject: Re: Link to a Form from a component Reply with quote




"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote

Quote:

as it is part of a project only and not of a precompiled package.

Why can't you simply add the TMsgForm's unit to the edit component's
package?


So simple...

Quote:

It doesn't need to be an actual component. Just add the form's .cpp and
.dfm files to the package and then dynamically instantiate the form at
runtime via the 'new' operator when needed.


Almost for sure the MsgForm will be needed by the program, so it should well
stay in memory when instantiated or even created at start-up.
In both cases, rather then new, should I not prefer TApplication->CreateForm
for its proper registration?


Rgds, Martin




Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Feb 06, 2004 7:59 pm    Post subject: Re: Link to a Form from a component Reply with quote


"Martin Moeller" <martin.moeller (AT) moema (DOT) it> wrote


Quote:
Almost for sure the MsgForm will be needed by the program, so
it should well stay in memory when instantiated or even created
at start-up.

If you put the form inside the component, then the application should not be
creating the form directly. The component should remain in full control of
the form internally. If the application needs to manipulate the form, then
the component should expose access to the parts that need manipulating
(preferring wrapped in properties and methods so that the application does
not have *direct* access to the form).


Gambit



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.