Solved

IWForm - OnClose effect

Posted on 2010-11-20
4
744 Views
Last Modified: 2013-11-23
I have something I need to do when a uses leaves the page.. (maybe the site too)
I tried the OnDestroy but it does not get triggered.
Any idea on how to implement this ?

Something like:
procedure TmainForm.OnClose( sender: TObject);
begin
  callSomeSillyLittleProc(param);
end;

TIWUserSession can NOT USED! since it requires hugh overhead (too many users)

TIA
0
Comment
Question by:controlr
  • 2
  • 2
4 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 34181363
The OnDestroy gets triggered when you call release:

 
procedure TformMain.IWButtoncloseClick(Sender: TObject);
begin
  Release;
end;

procedure TformMain.IWAppFormDestroy(Sender: TObject);
begin
  callSomeSillyLittleProc(param);
end;

Open in new window



But if you close with WebApplication.Terminate then you can think of something like this (smart but not the best):
Make "callSomeSillyLittleProc(param)" a function that returns a string rather than a procedure;
pass it as a parameter to WebApplication.Terminate(callSomeSillyLittleProc(param));
Make sure the function is returning blank (Result := '');

uses SysUtils; //for inttostr

function TformMain.callSomeSillyLittleProc(i,j:integer; str:string):string;
begin
  WebApplication.showmessage(IntToStr(i+j) +' '+ str);
  Result := '';
end;

procedure TformMain.IWButtonCloseClick(Sender: TObject);
begin
  WebApplication.Terminate(callSomeSillyLittleProc(3,1,'closed, Goodbye!'));
end;

Open in new window

0
 

Author Comment

by:controlr
ID: 34182297
JImmy...
The user does not hit any button.. .. he simply closed the browser.. (CTRL+F4) and does not have any interaction with the page.

THerefore.. there is never a call made to release.. and thus (like i said) the destroy does not get triggered.

There should be a onTerminate events that gets triggered when browser is closed or the user goes to another URL.... but   I think its handles in teh Session timeout and there is no way to intercept it..  maybe eBob has a trick :)
0
 
LVL 24

Accepted Solution

by:
jimyX earned 500 total points
ID: 34182682
I do not think IW can get that done without Javascript code with it.

Have a look on this site (scroll down to the part "Implementing the Browser Close Detection"):

http://robertcram.blogspot.com/
0
 

Author Closing Comment

by:controlr
ID: 34184717
i can use that :)
Thanks!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now