?
Solved

IWForm - OnClose effect

Posted on 2010-11-20
4
Medium Priority
?
762 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 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