Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

IWForm - OnClose effect

Posted on 2010-11-20
4
Medium Priority
?
765 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

610 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