| **Navigation:**  [[templates.htm|Templates]] > [[tlrcontents.htm|Template Language Reference]] > Annotated Examples > Procedure Template: Window >====== Procedure Template: Window {{c6h0068.jpg|C6H0068.jpg}} ====== | [[tlr08open.htm|{{btn_prev_n.gif|Previous page}}]][[tlrcontents.htm|{{btn_home_n.gif|Return to chapter overview}}]][[ standardwindowcode group.htm|{{btn_next_n.gif|Next page}}]] | | || The //Window// Procedure template is the generic template that creates any window handling procedure. Since most (if not all) procedures in a Windows application have a window, the type of code this template generates forms the basis of the generated source code for most procedures. The Window template is also the fundamental template upon which all the other Procedure templates are built. For example, the Browse template is actually a Window template with BrowseBox and BrowseUpdateButtons Control templates pre-defined for the procedure. The following template language code is all the code for the Window Template: {{notebox.jpg|NoteBox.jpg}} For this and all other code examples in this book, the template line continuation character (%|) is used to split code lines that are too long to fit on the page. In the template files on disk these characters are not (and should not be) used to continue a template code line; they are used here only for readability. These templates are from the Clarion template chain, not ABC. **#PROCEDURE(Window,'Generic Window Handler'),WINDOW,HLP('~TPLProcWindow')** **#LOCALDATA** **LocalRequest         LONG,AUTO** **OriginalRequest      LONG,AUTO** **LocalResponse        LONG,AUTO** **WindowOpened         LONG** **WindowInitialized    LONG** **ForceRefresh         LONG,AUTO** **#ENDLOCALDATA** **#CLASS('Procedure Setup','Upon Entry into the Procedure')** **#CLASS('Before Lookups','Refresh Window ROUTINE, before lookups')** **#CLASS('After Lookups','Refresh Window ROUTINE, after lookups')** **#CLASS('Procedure Exit','Before Leaving the Procedure')** **#PROMPT('&Parameters:', @s255), %Parameters** **#ENABLE(%ProcedureType='FUNCTION')** **  #PROMPT('Return Value:',FIELD),%ReturnValue** **#ENDENABLE** **#PROMPT('Window Operation Mode:',DROP('Use WINDOW setting|Normal|MDI|Modal')) %|** **         ,%WindowOperationMode** **#ENABLE(%INIActive)** **  #BOXED('INI File Settings')** **    #PROMPT('Save and Restore Window Location',CHECK) %|** **             ,%INISaveWindow,DEFAULT(1),AT(10,,150)** **  #ENDBOXED** **#ENDENABLE** **#AT(%CustomGlobalDeclarations)** **  #INSERT(%StandardGlobalSetup)** **#ENDAT** **#INSERT(%StandardWindowCode)** This code starts with the #PROCEDURE statement, which names the Procedure template and indicates that it will have a WINDOW (or APPLICATION) structure, but no REPORT. The #LOCALDATA section defines six local variables that generate automatically as part of the procedure. These are common local variables for most generated procedures. The #CLASS statements define the formula classes for the Formula Editor. These identify the source code positions at which formulas generate. The #PROMPT statements create the prompts on the **Procedure Properties** window. The first allows the programmer to name the parameters passed into the procedure. The #ENABLE structure enables its #PROMPT only when the %ProcedureType symbol contains "FUNCTION." This occurs only when the **Prototype** prompt (standard on all procedures) contains a procedure prototype with a return data type. The next #PROMPT allows the programmer to override the window's operation mode as specified on the WINDOW structure. The next #ENABLE structure enables its #BOXED #PROMPT only when the %INIActive symbol contains a value. This symbol comes from a check box on the Global Settings window. The #AT structure calls the %StandardGlobalSetup #GROUP. This contains code to determine if the procedure is using any .VBX controls. It so, they are added to the list of files to ship with the application that generates into the //ProgramName//.SHP file. You will note that none of these statements generates any target language (Clarion) source code other than the six variable declarations. The last #INSERT statement places all the code the %StandardWindowCode #GROUP generates at the end of these statements. This is the #GROUP that handles all the source generation for the template. **See Also:     **[[ standardwindowcode group.htm|%StandardWindowCode #GROUP]] ,[[ standardwindowhandling group.htm|%StandardWindowHandling #GROUP]] ,[[ standardacceptedhandling group.htm|%StandardAcceptedHandling #GROUP]] ,[[ standardcontrolhandling group.htm|%StandardControlHandling #GROUP]]