Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread ShowModal doesn't stop execution
Sun, Apr 29 2012 3:54 AMPermanent Link

Rick

Hi Tim.

I have the following code:

Form2.ShowModal;
Application.Desktop.ShowMessage('here');

I expected that this would show Form2 in a modal fashion and stop further
execution of the application until Form2 was closed. Once Form2 was closed
then the ShowMessage should execute. Instead, Form2 is shown and the
ShowMessage executes immediately.

After the ShowMessage dialog is dismissed then Form2 is interactive in a
modal fasion.

Shouldn't ShowModal stop further execution of the application until the form
is closed?

--
Rick

Sun, Apr 29 2012 12:57 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Rick,

<< I expected that this would show Form2 in a modal fashion and stop further
execution of the application until Form2 was closed. Once Form2 was closed
then the ShowMessage should execute. Instead, Form2 is shown and the
ShowMessage executes immediately. >>

Web browsers do not have a message loop, therefore the event model is
completely asynchronous, even for modal dialogs/forms.  What you do instead
is assign an event handler to handle the close of the message dialog, like
this:

prototype:

  TMsgDlgResultEvent = procedure (DlgResult: TModalResult) of object;

implementation

procedure TForm2.MsgDlgResult(DlgResult: TModalResult);
begin
  with ResultLabel do
     begin
     case DlgResult of
        mrNone:
           Caption:='None';
        mrOk:
           Caption:='Ok';
        mrCancel:
           Caption:='Cancel';
        mrAbort:
           Caption:='Abort';
        mrRetry:
           Caption:='Retry';
        mrIgnore:
           Caption:='Ignore';
        mrYes:
           Caption:='Yes';
        mrNo:
           Caption:='No';
        mrAll:
           Caption:='All';
        mrNoToAll:
           Caption:='NoToAll';
        mrYesToAll:
           Caption:='YesToAll';
        mrClose:
           Caption:='Close';
        else
           Caption:='';
        end;
     end;
end;

procedure TForm2.Button1Click(Sender: TObject);
begin
  Application.Desktop.MessageDlg('Are you sure that you want to show this
message dialog here, '+
                                 'right now, without any other thing
showing ?','Please Confirm',
                                 mtConfirmation,[mbOk,mbCancel],mbNo,MsgDlgResult,False);
end;

Notice that you pass the MsgDlgResult event handler directly to the
MessageDlg call.

--
Tim Young
Elevate Software
www.elevatesoft.com
Thu, May 3 2012 8:58 PMPermanent Link

Rick

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message
news:3FB9D2B6-6E36-4265-9621-F5C90BC090B9@news.elevatesoft.com...
>
> Web browsers do not have a message loop, therefore the event model is
> completely asynchronous, even for modal dialogs/forms.  What you do
> instead is assign an event handler to handle the close of the message
> dialog, like this:
>
>

Thanks for the clarification Tim.

As well as ShowMessage would it be worth including something like
Application.Desktop.Alert(text) which compiles directly to the standard
Javascript Alert() function? This way processing would halt until the user
actioned the alert window.

Sometimes it's useful to have processing stop completely until a message
popup is read.

--
Rick

Fri, May 4 2012 3:50 AMPermanent Link

Manfredt

Rick,

I really enjoy your extremely valuable and constructive
commends, please do not tire making your contributions,
they are positively shaping the development and evolution
of EWB.

Manfredt Kavetu
Sat, May 5 2012 6:26 PMPermanent Link

Rick

<Manfredt> wrote in message
news:B0E99C19-5EE9-4355-9C50-97E382774412@news.elevatesoft.com...
> Rick,
>
> I really enjoy your extremely valuable and constructive
> commends, please do not tire making your contributions,
> they are positively shaping the development and evolution
> of EWB.
>
> Manfredt Kavetu
>

>
Thanks for the encouragement Manfredt.

I guess most of what I've said Tim has already thought of anyway seeing as a
lot of it comes from a Delphi perspective. But I'll keep on suggesting Smile

I think EWB has a lot of potential and I intend on using it a lot so I'm
keen to see it have plenty of features and a very long life.

--
Rick

Mon, May 7 2012 12:13 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Rick,

<< As well as ShowMessage would it be worth including something like
Application.Desktop.Alert(text) which compiles directly to the standard
Javascript Alert() function? This way processing would halt until the user
actioned the alert window. >>

You can just use something like this:

uses WebDOM;

procedure TTestForm.Button1Click(Sender: TObject);
begin
  window.alert('Hello ????');
end;

I haven't wrapped much of the direct browser functionality like this because
a) it's easy to get to and b) I'm trying to keep the code size down.

Tim Young
Elevate Software
www.elevatesoft.com

Mon, May 7 2012 5:22 PMPermanent Link

Rick

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message
news:1AE24D5F-63C8-475C-9DFD-6829E0845F35@news.elevatesoft.com...
>
> << As well as ShowMessage would it be worth including something like
> Application.Desktop.Alert(text) which compiles directly to the standard
> Javascript Alert() function? This way processing would halt until the user
> actioned the alert window. >>
>
> You can just use something like this:
>
> uses WebDOM;
>
> procedure TTestForm.Button1Click(Sender: TObject);
> begin
>   window.alert('Hello ????');
> end;
>
> I haven't wrapped much of the direct browser functionality like this
> because a) it's easy to get to and b) I'm trying to keep the code size
> down.
>
>

That does what I want and is easy to use, thanks Tim.

I agree that keeping the code size small is the way to go.

--
Rick

Image