Board index » delphi » Form Create, Form Show events not firing

Form Create, Form Show events not firing

The form create and show events do not fire with the following code in D5.

If not assigned(frmClubs) then
    begin
        screen.cursor := crHourGlass;
        frmClubs := TrmClubs.create(self);
        frmClubs.show;
        screen.cursor := crDefault;
    end
else
 more stuff......

I do reach a breakpoint in the above code and can step through the above
code.  It never steps into the create event in the form created (use to in
D4), but in any circumstance the code in the create event of the new form
never executes.

Also regarding the show event of another form that is created and shown like
above, the show event never fires.  I moved the code to the activate event
and that occured, but not exactly what I wanted to do.

Is there an inherent difference between D4 and D5 or was I just getting away
with something in D4 ?

Any help would be appreciated.

Thanks,

Bob M.

 

Re:Form Create, Form Show events not firing


Quote
Bob M. wrote in message <7rcjlj$c...@forums.borland.com>...
>The form create and show events do not fire with the following code in D5.

>If not assigned(frmClubs) then
>    begin
>        screen.cursor := crHourGlass;
>        frmClubs := TrmClubs.create(self);
>        frmClubs.show;
>        screen.cursor := crDefault;
>    end
>else
> more stuff......

>I do reach a breakpoint in the above code and can step through the above
>code.  It never steps into the create event in the form created (use to in
>D4), but in any circumstance the code in the create event of the new form
>never executes.

Check the object inspector and make sure the events are properly assigned to
these methods. It sounds like these have become detached.

--
Wayne Niddery - WinWright Consulting
RADBooks - http://members.home.net/wniddery/
Bill of NO Rights; ARTICLE VIII:  You DON'T have the right to demand that
our children risk their lives in foreign wars to soothe your aching
conscience.

Re:Form Create, Form Show events not firing


Wayne,

I checked the object inspector in D5 and the events are not shown, for any
events, although the declaration and the definition are present.  The same
is also true in D4 which does fire the events.

If I double click the event in the object nspector the code is shown or if I
choose the event in D5's object inspector then everything is fine and the
events will fire.

Because of the number of forms and events in this project and other projects
, this will become burdensome and prone to error.

Do you think this is an D5 issue or an environment issue ?

D4 is still installed on the same computer.

Any help would be appreciated.

Bob M.

Wayne Niddery (TeamB) <winwri...@chaffhome.com> wrote in message
news:7rf3en$ruo11@forums.borland.com...

Quote
> Bob M. wrote in message <7rcjlj$c...@forums.borland.com>...
> >The form create and show events do not fire with the following code in
D5.

> >If not assigned(frmClubs) then
> >    begin
> >        screen.cursor := crHourGlass;
> >        frmClubs := TrmClubs.create(self);
> >        frmClubs.show;
> >        screen.cursor := crDefault;
> >    end
> >else
> > more stuff......

> >I do reach a breakpoint in the above code and can step through the above
> >code.  It never steps into the create event in the form created (use to
in
> >D4), but in any circumstance the code in the create event of the new form
> >never executes.

> Check the object inspector and make sure the events are properly assigned
to
> these methods. It sounds like these have become detached.

> --
> Wayne Niddery - WinWright Consulting
> RADBooks - http://members.home.net/wniddery/
> Bill of NO Rights; ARTICLE VIII:  You DON'T have the right to demand that
> our children risk their lives in foreign wars to soothe your aching
> conscience.

Re:Form Create, Form Show events not firing


Quote
Bob M. wrote in message <7rgnbb$e...@forums.borland.com>...

>I checked the object inspector in D5 and the events are not shown, for any
>events, although the declaration and the definition are present.  The same
>is also true in D4 which does fire the events.

If they aren't connected in D4, and you compile it again, it's a good bet
they will no longer fire there either.

Quote
>Do you think this is an D5 issue or an environment issue ?

You indicated they are no longer presently attached in the D4 source code
either, therefore it is not a D5 issue (at least not introduced there), D5
is showing exactly what was loaded. It may possibly be a D4 quirk, but I've
never seen it happen before, so I don't know. Have you checked many of the
other forms? Do they all seem to be disconnected?

Are you using inherited forms? If so, possibly one descendant got
disconnected and so all of *its* descendants are now also disconnected.

--
Wayne Niddery - WinWright Consulting
RADBooks - http://members.home.net/wniddery/
Bill of NO Rights; ARTICLE VIII:  You DON'T have the right to demand that
our children risk their lives in foreign wars to soothe your aching
conscience.

Re:Form Create, Form Show events not firing


I went back and double checked D4 and the events are not in the object
inspector, therefore, as you said, D5 loaded D4. I reckon D5 is more
particular about this attachment in the object inspector even though the
code is in the unit for the form events.

In D4, all forms were designed at design time, not auto-created at run-time,
and instantiated when the form was needed.  Even though the events were not
shown in the object inspector in D4, they still worked.

So I guess there is not a quick solution.  But a solution would be to go
through each form unit and attach the appropriate events in the object
inspector.

I'll go ahead and do that and let you know if there are any other problems
associated with this issue.

Thanks for the help,

Bob M.

Wayne Niddery (TeamB) <winwri...@chaffhome.com> wrote in message
news:7rh6km$j871@forums.borland.com...

Quote
> Bob M. wrote in message <7rgnbb$e...@forums.borland.com>...

> >I checked the object inspector in D5 and the events are not shown, for
any
> >events, although the declaration and the definition are present.  The
same
> >is also true in D4 which does fire the events.

> If they aren't connected in D4, and you compile it again, it's a good bet
> they will no longer fire there either.

> >Do you think this is an D5 issue or an environment issue ?

> You indicated they are no longer presently attached in the D4 source code
> either, therefore it is not a D5 issue (at least not introduced there), D5
> is showing exactly what was loaded. It may possibly be a D4 quirk, but
I've
> never seen it happen before, so I don't know. Have you checked many of the
> other forms? Do they all seem to be disconnected?

> Are you using inherited forms? If so, possibly one descendant got
> disconnected and so all of *its* descendants are now also disconnected.

> --
> Wayne Niddery - WinWright Consulting
> RADBooks - http://members.home.net/wniddery/
> Bill of NO Rights; ARTICLE VIII:  You DON'T have the right to demand that
> our children risk their lives in foreign wars to soothe your aching
> conscience.

Re:Form Create, Form Show events not firing


Quote
Bob M. wrote in message <7rjahm$5m...@forums.borland.com>...
>I went back and double checked D4 and the events are not in the object
>inspector, therefore, as you said, D5 loaded D4. I reckon D5 is more
>particular about this attachment in the object inspector even though the
>code is in the unit for the form events.

>In D4, all forms were designed at design time, not auto-created at
run-time,
>and instantiated when the form was needed.  Even though the events were not
>shown in the object inspector in D4, they still worked.

There is something not right here. If the events are not hooked up then they
*cannot* fire. That is why my comment that if you compile the D4 app again,
you'll probably find the events *no longer* fire.  The fact the current
executable works only means it was compiled before the events became
disconnected in the source code/dfms.

--
Wayne Niddery - WinWright Consulting
RADBooks - http://members.home.net/wniddery/
Bill of NO Rights; ARTICLE VIII:  You DON'T have the right to demand that
our children risk their lives in foreign wars to soothe your aching
conscience.

Re:Form Create, Form Show events not firing


When I look at the object inspector in D4, the events shown, i.e. OnCreate,
OnShow, etc., do not have any values associated with them, although code
exists for a number of these events.  I compiled and ran the program again
with this scenario in D4 with no adverse effects.  The events fired.  I
never paid much attention to this quirk because the events always worked as
advertised.  However, as mentioned in prior posts this is not the case in
D5.

Where would I look to find out when the object inspector discovers or
attaches events ?

I guess that D5 does not look at the event code in the units unless there is
an event associated with the event in the object inspector and D4 doesn't
care.

In any event.....(:..., should I punt ?

Thanks for you help

Bob M.

Wayne Niddery (TeamB) <winwri...@chaffhome.com> wrote in message
news:7rkab7$cag11@forums.borland.com...

Quote
> Bob M. wrote in message <7rjahm$5m...@forums.borland.com>...
> >I went back and double checked D4 and the events are not in the object
> >inspector, therefore, as you said, D5 loaded D4. I reckon D5 is more
> >particular about this attachment in the object inspector even though the
> >code is in the unit for the form events.

> >In D4, all forms were designed at design time, not auto-created at
> run-time,
> >and instantiated when the form was needed.  Even though the events were
not
> >shown in the object inspector in D4, they still worked.

> There is something not right here. If the events are not hooked up then
they
> *cannot* fire. That is why my comment that if you compile the D4 app
again,
> you'll probably find the events *no longer* fire.  The fact the current
> executable works only means it was compiled before the events became
> disconnected in the source code/dfms.

> --
> Wayne Niddery - WinWright Consulting
> RADBooks - http://members.home.net/wniddery/
> Bill of NO Rights; ARTICLE VIII:  You DON'T have the right to demand that
> our children risk their lives in foreign wars to soothe your aching
> conscience.

Re:Form Create, Form Show events not firing


Quote
Bob M. wrote in message <7rn8qe$7...@forums.borland.com>...
>When I look at the object inspector in D4, the events shown, i.e. OnCreate,
>OnShow, etc., do not have any values associated with them, although code
>exists for a number of these events.  I compiled and ran the program again
>with this scenario in D4 with no adverse effects.  The events fired.

I cannot reproduce this (this is actually a good thing <g>). Can you put a
break point inside one of these events and have it stop there when you run?
If so, does the call stack show you where the event was called from (perhaps
from another method in your form)?

Quote
>Where would I look to find out when the object inspector discovers or
>attaches events ?

It doesn't do either, it simply lets *you* attach events. Once attached,
that fact is stored in the form's associated DFM file. When you open your
form in Delphi, it reads the dfm and attaches the events to the objects.
Same thing when you run the application, the objects are created and the
events are attached according to the specs found in the DFM. Events can also
be assigned via code at runtime.

Event handler methods are still just normal methods, there is nothing
special about them that can make them automatically be associated with any
component or event, so unless one of these two ways of attaching the events
is done (in code or via object inspector) there is no way for Delphi to know
that certain methods in your code are to be used as event handlers for
certain events - there is no connection at all.

Quote
>I guess that D5 does not look at the event code in the units unless there
is
>an event associated with the event in the object inspector and D4 doesn't
>care.

As above, if they are not explicitly associated, there is no way for Delphi
(any version) to call those event handlers in response to any component
event.

--
Wayne Niddery - WinWright Consulting
RADBooks - http://members.home.net/wniddery/
Bill of NO Rights; ARTICLE VIII:  You DON'T have the right to demand that
our children risk their lives in foreign wars to soothe your aching
conscience.

Re:Form Create, Form Show events not firing


 The snippet below is from one of the forms dfm file.  The items with an
asterick, the form events, were not there.  Other objects events such as a
button onclick event were there.  I will let D4 add the events back to the
dfm file via the object inspector and then recompile in D5.  I should not
have any problem once this is done.

Don't know why D4 works but.... I am moving on to D5.

Although I don't know how it happened in D4, I feel good that we know why it
doesn't compile the events in D5.

Thanks for your help.  It was pretty lenghty and took much of your time.
Thanks for your patience and advice.

Bob M.

Form file (.dfm) after reattaching events via the object inspector

  Font.Name = 'MS Sans Serif'
  Font.Style = []
  KeyPreview = True
  OldCreateOrder = True
**  OnClose = FormClose
**  OnCloseQuery = FormCloseQuery
**  OnCreate = FormCreate
**  OnDestroy = FormDestroy
**  OnKeyDown = FormKeyDown
**  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 24
......rest of the form

Wayne Niddery (TeamB) <winwri...@chaffhome.com> wrote in message
news:7rpb4j$ofv9@forums.borland.com...

Quote
> Bob M. wrote in message <7rn8qe$7...@forums.borland.com>...
> >When I look at the object inspector in D4, the events shown, i.e.
OnCreate,
> >OnShow, etc., do not have any values associated with them, although code
> >exists for a number of these events.  I compiled and ran the program
again
> >with this scenario in D4 with no adverse effects.  The events fired.

> I cannot reproduce this (this is actually a good thing <g>). Can you put a
> break point inside one of these events and have it stop there when you
run?
> If so, does the call stack show you where the event was called from
(perhaps
> from another method in your form)?

> >Where would I look to find out when the object inspector discovers or
> >attaches events ?

> It doesn't do either, it simply lets *you* attach events. Once attached,
> that fact is stored in the form's associated DFM file. When you open your
> form in Delphi, it reads the dfm and attaches the events to the objects.
> Same thing when you run the application, the objects are created and the
> events are attached according to the specs found in the DFM. Events can
also
> be assigned via code at runtime.

> Event handler methods are still just normal methods, there is nothing
> special about them that can make them automatically be associated with any
> component or event, so unless one of these two ways of attaching the
events
> is done (in code or via object inspector) there is no way for Delphi to
know
> that certain methods in your code are to be used as event handlers for
> certain events - there is no connection at all.

> >I guess that D5 does not look at the event code in the units unless there
> is
> >an event associated with the event in the object inspector and D4 doesn't
> >care.

> As above, if they are not explicitly associated, there is no way for
Delphi
> (any version) to call those event handlers in response to any component
> event.

> --
> Wayne Niddery - WinWright Consulting
> RADBooks - http://members.home.net/wniddery/
> Bill of NO Rights; ARTICLE VIII:  You DON'T have the right to demand that
> our children risk their lives in foreign wars to soothe your aching
> conscience.

Re:Form Create, Form Show events not firing


I am embarrased to report that I know what happened.  Operator error.

I am using a form resizer add-in component that reassigns form events to its
own component.  That component is not available in D5, therefore I removed
it from the form when compiling in D5.  This left the form events
unassigned.

Thanks again for your help.

The End

Quote
Bob M. <mau...@erols.com> wrote in message

news:7rphn8$oet22@forums.borland.com...
Quote
> The snippet below is from one of the forms dfm file.  The items with an
> asterick, the form events, were not there.  Other objects events such as a
> button onclick event were there.  I will let D4 add the events back to the
> dfm file via the object inspector and then recompile in D5.  I should not
> have any problem once this is done.

> Don't know why D4 works but.... I am moving on to D5.

> Although I don't know how it happened in D4, I feel good that we know why
it
> doesn't compile the events in D5.

> Thanks for your help.  It was pretty lenghty and took much of your time.
> Thanks for your patience and advice.

> Bob M.

> Form file (.dfm) after reattaching events via the object inspector

>   Font.Name = 'MS Sans Serif'
>   Font.Style = []
>   KeyPreview = True
>   OldCreateOrder = True
> **  OnClose = FormClose
> **  OnCloseQuery = FormCloseQuery
> **  OnCreate = FormCreate
> **  OnDestroy = FormDestroy
> **  OnKeyDown = FormKeyDown
> **  OnShow = FormShow
>   PixelsPerInch = 96
>   TextHeight = 13
>   object Label1: TLabel
>     Left = 24
> ......rest of the form

> Wayne Niddery (TeamB) <winwri...@chaffhome.com> wrote in message
> news:7rpb4j$ofv9@forums.borland.com...
> > Bob M. wrote in message <7rn8qe$7...@forums.borland.com>...
> > >When I look at the object inspector in D4, the events shown, i.e.
> OnCreate,
> > >OnShow, etc., do not have any values associated with them, although
code
> > >exists for a number of these events.  I compiled and ran the program
> again
> > >with this scenario in D4 with no adverse effects.  The events fired.

> > I cannot reproduce this (this is actually a good thing <g>). Can you put
a
> > break point inside one of these events and have it stop there when you
> run?
> > If so, does the call stack show you where the event was called from
> (perhaps
> > from another method in your form)?

> > >Where would I look to find out when the object inspector discovers or
> > >attaches events ?

> > It doesn't do either, it simply lets *you* attach events. Once attached,
> > that fact is stored in the form's associated DFM file. When you open
your
> > form in Delphi, it reads the dfm and attaches the events to the objects.
> > Same thing when you run the application, the objects are created and the
> > events are attached according to the specs found in the DFM. Events can
> also
> > be assigned via code at runtime.

> > Event handler methods are still just normal methods, there is nothing
> > special about them that can make them automatically be associated with
any
> > component or event, so unless one of these two ways of attaching the
> events
> > is done (in code or via object inspector) there is no way for Delphi to
> know
> > that certain methods in your code are to be used as event handlers for
> > certain events - there is no connection at all.

> > >I guess that D5 does not look at the event code in the units unless
there
> > is
> > >an event associated with the event in the object inspector and D4
doesn't
> > >care.

> > As above, if they are not explicitly associated, there is no way for
> Delphi
> > (any version) to call those event handlers in response to any component
> > event.

> > --
> > Wayne Niddery - WinWright Consulting
> > RADBooks - http://members.home.net/wniddery/
> > Bill of NO Rights; ARTICLE VIII:  You DON'T have the right to demand
that
> > our children risk their lives in foreign wars to soothe your aching
> > conscience.

Re:Form Create, Form Show events not firing


Quote
Bob M. wrote in message <7rpjab$oe...@forums.borland.com>...

>I am using a form resizer add-in component that reassigns form events to
its
>own component.  That component is not available in D5, therefore I removed
>it from the form when compiling in D5.  This left the form events
>unassigned.

Thanks very much for reporting this, it's nice to remove the mystery.

I consider any component that expropriates user events for its own use to be
very bad form - it is *extremely* error prone as you've discovered. I hope
that vendor doesn't upgrade it for D5 (unless the behaviour is fixed).  When
D1 came out, my first serious attempt at a useful component did this very
same thing. I soon found I didn't like using my own component because, even
though I wrote it, I kept forgetting I couldn't use the form events without
breaking the component's operations.

--
Wayne Niddery - WinWright Consulting
RADBooks - http://members.home.net/wniddery/
Bill of NO Rights; ARTICLE VIII:  You DON'T have the right to demand that
our children risk their lives in foreign wars to soothe your aching
conscience.

Other Threads