Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread Problem with a modal form and IE
Wed, Sep 14 2016 7:23 AMPermanent Link

Michael Dreher

Last week I had to recompile a Webbuilder projekt in version 2.05, that was compiled before with version 2.04.
After recompiling there is a problem with a modal form call and the internet explorer (and so observable in der Webbuilder IDE), while in the firefox is works fine as before.


The code (see also the attachment, compiled with 2.05B4 and 2.04B1):

// handle button click to call a modal form
procedure TfmMain.btnEnterDMCClick(Sender: TObject);
begin
 EnableSearchButtons(false);
 fmEnterDMC            := TfmEnterDMC.Create(NIL); // create the form
 fmEnterDMC.OnClose    := OnDmcClose; // the OnClose handler for later freeing the closed modal form
 fmEnterDMC.Enter; // call a member procedure that calls ShowModal
end;

// free the closed modal form when it returns
procedure TfmMain.OnDmcClose(Sender: TObject);
begin
 ShowMessage('OnDmcClose');
 fmEnterDMC.Free;
 EnableSearchButtons(true);
end;
-----------------------------------
// in the called form call ShowModal
procedure TfmEnterDMC.Enter;
begin
 ShowModal;
end;

Thert is a button in the modal form, when clicked calls "Close".
procedure TfmEnterDMC.btnSearchClick(Sender: TObject);
begin
 Close;
end;
---------------------------------

The effect in the IE:
After the close command in the modal form, for about one second nothing happens. Than the modal form
becomes invisible and the caller form remains grayed. The ShowMessage message in the OnClose handler is
never shown. Effectively the modal state remains.

The IE about box says version: 11.0.9600.18427.
Is there something wrong with the code?

Michael Dreher



Attachments: CodeExamples.zip
Wed, Sep 14 2016 8:23 AMPermanent Link

Raul

Globestar Systems

Team Elevate Team Elevate

On 9/14/2016 7:23 AM, Michael Dreher wrote:
> Last week I had to recompile a Webbuilder projekt in version 2.05, that was compiled before with version 2.04.
> After recompiling there is a problem with a modal form call and the internet explorer (and so observable in der Webbuilder IDE), while in the firefox is works fine as before.
> ...
> The effect in the IE:
> After the close command in the modal form, for about one second nothing happens. Than the modal form
> becomes invisible and the caller form remains grayed. The ShowMessage message in the OnClose handler is
> never shown. Effectively the modal state remains.
>
> The IE about box says version: 11.0.9600.18427.
> Is there something wrong with the code?

Michael,

Code looks fine to me.

Since you are using showmodal you could try using modalResult setting
instead of close to see if it makes any difference (i.e.   modalResult
:= mrOKWink.

I just tried a somple example of this here with your code as shown and
works just fine with IE (both in EWB embedded browser and standalone) -
however my IE is 11.545.10586.0.

This might need some in-depth in-browser debugging.

Raul
Wed, Sep 14 2016 9:02 AMPermanent Link

Michael Dreher

Raul wrote:

// Since you are using showmodal you could try using modalResult setting
// instead of close to see if it makes any difference (i.e.   modalResult
// := mrOKWink.
// ...
// Raul

Raul,
I already tried this and it makes no difference. I've also noticed that disabling the button on the main form with the first statement

 -  EnableSearchButtons(false);

could be related to this. The effect disappears when commenting out this.

Michael Dreher
Wed, Sep 14 2016 12:29 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

Can you send me a cut-down version of the project that reproduces what you're seeing ?

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Sep 26 2016 1:55 AMPermanent Link

Michael Dreher

Raul wrote:

  // This might need some in-depth in-browser debugging.

I debugged the JavaScript in the IE and observed a "not enough stack memory" error during the attempt of the library to set the focus to the last active control (of the main form I think). On a deeper level there are two functions in the TFormControl calling each other

 - webforms_tformcontrol.$p.focuslastactivecontrol   and
 - webforms_tformcontrol.$p.setfocus

and it seems this never terminates and causes the stack error. In my (pascal) code I disabled the button before calling the modal form. I guess this is the key. The are no stackerrors using firefox or crome, and I did not know at this time what's the reason behind all this.

Michael Dreher
Mon, Sep 26 2016 1:25 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< and it seems this never terminates and causes the stack error. In my (pascal) code I disabled the button before calling the modal form. I guess this is the key. The are no stackerrors using firefox or crome, and I did not know at this time what's the reason behind all this. >>

Do you have a grid on the form ?  There is an issue with grids in 2.05, whereby they can get into an infinite loop when the grid's AlwaysShowControls property is True, due to a bug approximating what you're describing.

The hot fix is this:

WebGrids unit:

procedure TGridControl.SetFocus;
begin
  inherited SetFocus;
  { Need this check, otherwise we will cause an infinite loop !!! }
  if FColumnControlActive then  <<<<<<<<<<<<<<<<< Add this !!!!
     UpdateColumnFocus;
end;

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Sep 27 2016 8:30 AMPermanent Link

Michael Dreher

Tim,

 // Do you have a grid on the form ?  There is an issue with grids in 2.05.....

No. Only label, edit and button controls. Once more I add the code example, and the stack trace also (see CallStack.txt, read it from the bottom up).

Michael Dreher



Attachments: CodeExample.zip
Mon, Oct 3 2016 1:07 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< No. Only label, edit and button controls. Once more I add the code example, and the stack trace also (see CallStack.txt, read it from the bottom up). >>

Thanks, I'll check it out.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Oct 3 2016 2:07 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

Yeah, it has to do with the disabling of the button after the click, which is messing with the ability of EWB to focus the last active control (the button).

I'll see what else I can find out.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Oct 3 2016 2:58 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

Okay, here's the hot fix:

WebForms unit:

procedure TFormControl.SetLastActiveFormControl(AControl: TControl);
begin
  if (Parent=Application.Surface) then
     begin
     if (not (AControl is TFormControl)) then   <<<< Fix !!!
        FLastActiveControl:=AControl;
     end
  else
     inherited SetLastActiveFormControl(AControl);
end;

The problem was that IE was firing focus events for forms, and the last active control would get set to the form.  This completely botched up EWB's logic for handling the focus of actual controls, as opposed to forms.

Tim Young
Elevate Software
www.elevatesoft.com
Page 1 of 2Next Page
Jump to Page:  1 2
Image