Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread TMemo
Mon, Dec 12 2011 4:58 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Tim,

1.
Enter key seems to have no effect inside a TMemo now, tough Ctrl-M does insert a line break.

2.
I can't figure out how to deal with modal forms, as the code continues to execute after the call to ShowModal. I'm not sure if its a bug or me misunderstanding how modal forms should behave in a web application.

--
Fernando Dias
[Team Elevate]
Mon, Dec 12 2011 8:50 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Fernando,

<< Enter key seems to have no effect inside a TMemo now, tough Ctrl-M does
insert a line break. >>

It's the embedded IE - if you run it in an external FF or IE instance, it
works fine.  For some reason that I can't figure out yet, the embedded
browser eats dialog keys like Enter.

<< 2.  I can't figure out how to deal with modal forms, as the code
continues to execute after the call to ShowModal. I'm not sure if its a bug
or me misunderstanding how modal forms should behave in a web application.
>>

Yeah, it's a little different with a browser application due to the fact
that there isn't any message loop that the form can use to intercept all
activity and direct it to the modal form, so modal forms have to work with a
callback event handler.  If you look at the declarations in WebForms.wbs,
you'll see how you call them:

        procedure MessageDlg(const Msg: String;
                             const DlgCaption: String;
                             DlgType: TMsgDlgType;
                             const Buttons: TMsgDlgBtns;
                             MsgDlgResult: TMsgDlgResultEvent=nil;
                             CloseButton: Boolean=False;
                             OverlayColor: TColor=clBlack;
                             OverlayOpacity: Double=20);

        procedure MessageDlg(const Msg: String;
                             const DlgCaption: String;
                             DlgType: TMsgDlgType;
                             const Buttons: TMsgDlgBtns;
                             DefaultButton: TMsgDlgBtn;
                             MsgDlgResult: TMsgDlgResultEvent=nil;
                             CloseButton: Boolean=False;
                             OverlayColor: TColor=clBlack;
                             OverlayOpacity: Double=20);

There's also a ShowMessage in the next build, and as you can see, overloads
in EWB's Object Pascal are automatic, and the compiler always figures out
which method to call based upon how it is called.

You call them like this:

  Application.Desktop.MessageDlg('Are you sure that you want to show this
message dialog here, '+
                                 'right now, without any other thing
showing ?','Please Confirm',
                                 mtError,[mbOk,mbCancel],mbNo,MsgDlgResult,False);

And so, you would need a method on the active form called MsgDlgResult that
looks something like this:

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

It's a little screwy when you're used to 1, 2, 3, 4... execution of modal
forms, but you basically have to chain the result processing on to the event
handler for the modal form.  The good thing, though, is that you don't have
to jump through hoops in order to throw up modal progress dialogs that allow
execution to continue while the modal dialog is showing.  So, lose a little,
gain a little. Smile

--
Tim Young
Elevate Software
www.elevatesoft.com
Mon, Dec 12 2011 10:05 PMPermanent Link

Ron Levy

"Tim Young [Elevate Software]" wrote:

Fernando,

<< Enter key seems to have no effect inside a TMemo now, tough Ctrl-M does
insert a line break. >>

<It's the embedded IE - if you run it in an external FF or IE instance, it
works fine.  For some reason that I can't figure out yet, the embedded
browser eats dialog keys like Enter.>

I think I have run into issues like this in the past, maybe in ActiveForms- and might be able to dig up some code. I believe it is Delphi's ActiveX container that is the issue, not embedded IE.

Looking at some of my code - I see references like the following:

procedure THTMLDTSEdForm.HTMLEditorKeyDown(Sender: TObject; var Key: Word;
 Shift: TShiftState);
begin
  if ((key in [vk_tab]) and (not (ssShift in Shift))) then begin
     if (ActiveControl = HTMLEditor) then
        HTMLEditor.SelText := chr(vk_tab);
  end;
end;

This might be what you need to do with the web browser as well.

Not sure how to get to the web browser memo editor from the web browser itself however.
Tue, Dec 13 2011 6:46 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ron,

<< I think I have run into issues like this in the past, maybe in
ActiveForms- and might be able to dig up some code. I believe it is Delphi's
ActiveX container that is the issue, not embedded IE. >>

I'm not sure if that's the case or not, but anything you can provide would
be great.  We've got a UI handler attached to the web browser to handle this
type of thing, but it doesn't seem to affect certain keystrokes.

<< Not sure how to get to the web browser memo editor from the web browser
itself however. >>

You can't, at least not easily.  You have to literally traverse the DOM like
you do in JavaScript, except with all of that OLE stuff.

--
Tim Young
Elevate Software
www.elevatesoft.com
Tue, Dec 13 2011 2:37 PMPermanent Link

Ron Levy

<I'm not sure if that's the case or not, but anything you can provide would
be great.  We've got a UI handler attached to the web browser to handle this
type of thing, but it doesn't seem to affect certain keystrokes.>

Tim,

I just ran a test of the same html in a Delphi app with TWebBrowser and bsalsa EmbeddedWB - the problem seems to be fixed in EmbeddedWB - so I suggest just using it instead of TWebBrowser.

http://www.bsalsa.com/product.html

Ron.
Tue, Dec 13 2011 3:23 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ron,

<< I just ran a test of the same html in a Delphi app with TWebBrowser and
bsalsa EmbeddedWB - the problem seems to be fixed in EmbeddedWB - so I
suggest just using it instead of TWebBrowser. >>

Thanks, I'll check it out.

--
Tim Young
Elevate Software
www.elevatesoft.com
Image