Solved

IWForm - OnClose effect

Posted on 2010-11-20
4
749 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

808 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