Monday, 7 July 2008

How to close a form after a certain timespan

Sometimes it would be really nice if a form closes automatically after a certain timespan. I found it particulary useful in ShopFloorControl, where end-users might not have a mouse to point to close on a form.

On the forms run:

public void run()
{
str JmgJobId;
// Define variable for timeout
// Created with new int on JmgParameters
int TimeOut = JmgParameters::find().JmgRegistredOnJobPromptTime;

// Check if there is a parm
if(element.args().parm())
{
JmgJobId = element.args().parm();
jobIdTxt.text(JmgJobId);
}

super();

// Close form after TimeOut
this.setTimeOut(identifierstr(close),TimeOut);
}



No comments: