Mr. Cluey
: How To ...? : Start() a DialogBoxNot every application begins with a MainWin. The MainWin class has a lot of nice functionality in it, which would be really handy for all applications, except that it isn't there.
There is one answer to this, which can be applied in two different ways, depending on
your mood. Both boil down to a single key idea, telling QAP that your dialog box is a
MainWin with a DialogBox WNDTAG. MainWin("MyApp") tells QAP
that you are expecting a MainWin with the caption "MyApp". But WNDTAGs can carry
class information as well. This tag, "[DialogBox]MyApp" matches a DialogBox
anywhere that it appears, even if we wrap it inside a different class of window, as in MainWin("[DialogBox]MyApp").
This first implementation is that which is hinted at by the 4Test Language Reference in the description of the tag statement.
window MainWin MyApp
{
tag "[DialogBox]MyApp" ;
}
If you choose this implementation, then everywhere in your scripts, the variable MyApp will have MainWin methods, properties, and so on. In theory this is a bad idea (you are exposing an implementation choice that should remain hidden), in practice you can get away with it.
My prefered method of dealing with these issues is to hide the details of the implementation within the class itself. In this particular case, we don't want a MainWin, what we want is a DialogBox which use Start(). To do this, I would create a temporary MainWin with the same tag as the DialogBox, and use that Start method. The implementation would look like:
window DialogBox MyApp
{
tag "MyApp" ;
Start ( string sCmdLine )
{
MainWin( this.WndTag ).Start( sCmdLine ) ;
}
}
window MainWin M { tag "[DialogBox]D" ; }
window DialogBox D { tag "D" ; }
main ()
{
print ( ClassOf(M)) ; //prints MainWin
print ( ClassOf(D)) ; //prints DialogBox
}
That's it in a nutshell - M really is a MainWin, as far as 4Test is concerned, and D is a DialogBox. D.Accept() is valid, but M.Accept() is undefined. Similarly, D.CloseWindows() is not defined. Both M and D point to the same window on the screen, but the class declarations define how your scripts can interact with those windows.
| Mr. Cluey : How To ...? : Start() a DialogBox |