Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread Form OnCreate and OnSow Events
Fri, May 22 2015 2:24 AMPermanent Link

Eivind

All

Got a couple of things I wonder about regarding the OnCreate and OnShow event. Here is two scenarios:

1. If a ShowMessage() is called from inside any of those events, the "modal layer" does not go away and cover the message box as well. It's impossible to click the OK button with the mouse to close the dialog. If I hit the Enter key, that will close the dialog.

2. "Unprotected" code (not in a try..except block) does not raise an error. Let say I purposely set a wrong ItemIndex for a ComboBox and we all know that will trigger the "List Index out of bounds" error. However, if this error is triggered form inside the OnCreate or OnShow events, an exception is not raised. Aslo, if you have ticked the Show Progress check box in the projects options, the Loading dialog never closes.

  try
     ButtonComboBox1.ItemIndex := 7; // (Using an empty ButtonComboBox)
  except
     On E: Exception  do
        ShowMessage(E.Message);
  end;

However, if I put the above code in the OnCreate or OnShow, the error text is shown in the ShowMessage dialog, but the again, the "modal layer" stay darkened and the ShowMessage dialog does not allow me to click OK with the mouse.

I also saw another strange thing happen in Build 8. Not sure if I should have posted that in a separate thread or not. From time to time, events seams to be lost for some controls. I mean, the code I wrote for the event is still there, but the control does not show anything in the Event tab of the Object Inspector. If I double click it again, the event will be "hooked up" again all is good. At this point of time, I can not really say how it happens, but I see it after closing some tab's or re-opening the project that some events are lost.

Anyone else experience any of this?

Cheers

Eivind
Fri, May 22 2015 2:46 AMPermanent Link

Uli Becker

Eivind,

> 1. If a ShowMessage() is called from inside any of those events, the
"modal layer" does not go away and cover the message box as well. It's
impossible to click the OK button with the mouse to close the dialog. If
I hit the Enter key, that will close the dialog.

I just tried that with a simple project, but don't see what you are
describing.

> I also saw another strange thing happen in Build 8. Not sure if I should have posted that in a separate thread or not. From time to time, events seams to be lost for some controls. I mean, the code I wrote for the event is still there, but the control does not show anything in the Event tab of the Object Inspector. If I double click it again, the event will be "hooked up" again all is good. At this point of time, I can not really say how it happens, but I see it after closing some tab's or re-opening the project that some events are lost.

I reported that some time ago and it should be fixed with the next build.

Uli
Fri, May 22 2015 3:26 AMPermanent Link

Eivind

Uli.. Had to go back digging a bit deeper. Did you check the "Show Loading Progress" in the project option? If not, the ShowMessage works ok. Also try this:

- drop a ButtonComboBox on any form type
- In the OnCreate, try this code: ButtonComboBox1.ItemIndex := 9;
- Run the app. If the "Show Loading Progress" is ticked, the Loading Progress never goes away in my app
- If the "Show Loading Progress" is not ticked, the app starts normal, but no error is raised
- If you execute the same cocde from a Button, an exception is raised

My way of getting around this temporary was to use a TTimer that is started from the OnCreate. The same code executes fine inside the TTimer.

Br

Eivind




Uli Becker wrote:

Eivind,

> 1. If a ShowMessage() is called from inside any of those events, the
"modal layer" does not go away and cover the message box as well. It's
impossible to click the OK button with the mouse to close the dialog. If
I hit the Enter key, that will close the dialog.

I just tried that with a simple project, but don't see what you are
describing.

> I also saw another strange thing happen in Build 8. Not sure if I should have posted that in a separate thread or not. From time to time, events seams to be lost for some controls. I mean, the code I wrote for the event is still there, but the control does not show anything in the Event tab of the Object Inspector. If I double click it again, the event will be "hooked up" again all is good. At this point of time, I can not really say how it happens, but I see it after closing some tab's or re-opening the project that some events are lost.

I reported that some time ago and it should be fixed with the next build.

Uli
Fri, May 22 2015 3:39 AMPermanent Link

Uli Becker

Eivind,

> Had to go back digging a bit deeper. Did you check the "Show Loading Progress" in the project option?

OK, that was not clear in you first post.
To solve that, just use  Application.Surface.HideProgress before
displaying the messagebox.

> - drop a ButtonComboBox on any form type

I haven't tried that.

> Uli

Fri, May 22 2015 8:36 AMPermanent Link

Raul

Team Elevate Team Elevate

On 5/22/2015 3:26 AM, Eivind wrote:
> Uli.. Had to go back digging a bit deeper. Did you check the "Show Loading Progress" in the project option? If not, the ShowMessage works ok. Also try this:

If you enable this then internally Application creates the progress
dialog and then schedules a task to create the form (in order to update
progress).

> - drop a ButtonComboBox on any form type
> - In the OnCreate, try this code: ButtonComboBox1.ItemIndex := 9;
> - Run the app. If the "Show Loading Progress" is ticked, the Loading Progress never goes away in my app

If you don't handle the exception it propagates up and trips up the
application logic.

This one is interesting - Tim needs to decide whether it's by design or
not.

In my view if app generates an exception in the OnCreate then it should
crash and burn (i.e. framework should not protect us) - this way any
issues get found out right away and not during app running later.


> - If the "Show Loading Progress" is not ticked, the app starts normal, but no error is raised

Seems to work for me for both OnShow and OnCreate- i'm definitely
getting an exception raised and dialog shown (message is "List index 9
out of bounds")!?

procedure TForm1.Form1Create(Sender: TObject);
begin
   try
      ButtonComboBox1.ItemIndex := 9;
   except
   on E:Exception do
      ShowMEssage(e.message);
   end;
end;


Raul
Fri, May 22 2015 9:06 AMPermanent Link

Matthew Jones

Raul wrote:

> In my view if app generates an exception in the OnCreate then it
> should crash and burn (i.e. framework should not protect us) - this
> way any issues get found out right away and not during app running
> later.

I agree - makes it a lot easier to find in the browser debugger too.
Indeed, it was exactly this that allowed me to quickly find a bug in my
code with IE.
Fri, May 22 2015 9:34 AMPermanent Link

Eivind

Raul

Yes, with the code below I also get the exception if I use try..except. However, if I only have ButtomComboBox1.ItemIndex := 9;, and no try..except block. No exception is raised. If I have "Show Loading Progress" checked, the Loading does not disappear.

This might be designed to be like this... Just qurious.

Eivind


> - If the "Show Loading Progress" is not ticked, the app starts normal, but no error is raised

Seems to work for me for both OnShow and OnCreate- i'm definitely
getting an exception raised and dialog shown (message is "List index 9
out of bounds")!?

procedure TForm1.Form1Create(Sender: TObject);
begin
   try
      ButtonComboBox1.ItemIndex := 9;
   except
   on E:Exception do
      ShowMEssage(e.message);
   end;
end;


Raul
Fri, May 22 2015 9:50 AMPermanent Link

Raul

Team Elevate Team Elevate

On 5/22/2015 9:34 AM, Eivind wrote:
> Yes, with the code below I also get the exception if I use try..except. However, if I only have ButtomComboBox1.ItemIndex := 9;, and no try..except block. No exception is raised. If I have "Show Loading Progress" checked, the Loading does not disappear.

Basically without progress it probably gets propagated up to main
application where the forms are created and app started and there is no
handler there so app simply crashes.

With progress it's similar but propagation is likely up to scheduler
task first creating the form and then application.


> This might be designed to be like this... Just qurious.

Would be nice to get a runtime error still if it's not handled.

One problem with any of those default prompt dialogs is that it would be
for anything not handled so so there might sceanrios where its also
undesirable.


Let's see what Tim say and what he can do.


Raul
Fri, May 22 2015 1:08 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Eivind,

<< 2. "Unprotected" code (not in a try..except block) does not raise an
error. Let say I purposely set a wrong ItemIndex for a ComboBox and we all
know that will trigger the "List Index out of bounds" error. However, if
this error is triggered form inside the OnCreate or OnShow events, an
exception is not raised. >>

If you're raising/causing exceptions during the loading of an application,
then yes, the browser will do this.  There are certain times during
loads/unloads where the browser will eat exceptions (once they bubble up)
and not pass them on to the global error handling that normally would
display the error.

<< Also, if you have ticked the Show Progress check box in the projects
options, the Loading dialog never closes. >>

That's because the loading progress is never turned off if there's an
exception during the initial application load.   This is just the nature of
how the forms need to be created/loaded in a browser application, and still
allow for things like animated progress indicators.  What EWB has to do is
schedule the progress dialog showing and form creation as UI tasks, and so
typical try..except handling won't/can't work, and once there's an
exception, EWB has no way of handling it.  Again, this is *only* during
application load, and is just the nature of how the browsers do loads,
combined with the issues involved in working within the confines of a single
UI thread.

If an application exception happens during form creation, and isn't handled,
then the only form of recovery is to reset the application using Ctrl-F5 or
F5.  The application is in an inconsistent state, and is probably not
usable.

<< I also saw another strange thing happen in Build 8. Not sure if I should
have posted that in a separate thread or not. From time to time, events
seams to be lost for some controls. I mean, the code I wrote for the event
is still there, but the control does not show anything in the Event tab of
the Object Inspector. If I double click it again, the event will be "hooked
up" again all is good. At this point of time, I can not really say how it
happens, but I see it after closing some tab's or re-opening the project
that some events are lost. >>

This is fixed.  I'm uploading a new build 9 shortly - I was going to do so
yesterday, but needed to add something else.

Tim Young
Elevate Software
www.elevatesoft.com
Image