827.TXT ===================================================================== Using MDI Forms ===================================================================== PRODUCT: R:BASE VERSION: 5.5 or Higher ===================================================================== CATALOG: General Information ARea : General Information ===================================================================== R:BASE 5.5 includes new options on the EDIT USING and ENTER USING commands as well as new commands that enable you to display forms in a sizeable window instead of full screen. Forms displayed in a sizeable window are called MDI forms. The new options of the EDIT USING command are: ENTER MDI_the MDI keyword replaces the USING keyword. The MDI keyword tells R:BASE to display the form in a sizeable window. EDIT MDI_the MDI keyword replaces the USING keyword. The MDI keyword tells R:BASE to display the form in a sizeable window. AT location_only used with the MDI keyword. Specifies the initial size of the form window. AS aliasname_only used with the MDI keyword. Specifies an alias name that is used with the SETFOCUS command. CAPTION_specifies the window title when the form displays. Can be used with MDI forms and with full screen forms. The new commands used when working with MDI forms are: SETFOCUS_used to programmatically make the form window the active window. The form is identified by the alias name specified in the EDIT/ENTER command. CLOSEWINDOW_programmatically closes an MDI form. The form is identified by the alias name specified in the EDIT/ENTER command. MINIMIZE_minimizes the "R:BASE R> Prompt" window to an icon within the "R:BASE 5.5" window. NORMALIZE_normalizes the "R:BASE R> Prompt" window. MAXIMIZE_maximizes the "R:BASE R> Prompt" window. MDI forms can only be displayed from the "R:BASE R> Prompt" window or within a command file or application. Typically you reduce the size of the "R:BASE R> Prompt" window, call the form, and then make the form the active window using the SETFOCUS command. For example: -- set the size of the R> prompt window MINIMIZE -- run the form EDIT MDI formname AS alias1 -- make the form the active window SETFOCUS alias1 WAIT How to use each of these commands and options is discussed in more detail below. Sizing the R> prompt Whenever R:BASE executes a RUN command, R:BASE automatically maximizes the "R:BASE R> Prompt" window. Since MDI forms are typically called from a command file or application, the "R:BASE R> Prompt" window is maximized and has focus (i.e. is the active window). The form is displayed, but behind the maximized "R:BASE R> Prompt" window. In order to set focus to a form window, the "R:BASE R> Prompt" window must be minimized or normalized. Three new commands have been added in R:BASE 5.5 to control the size of the "R:BASE R> Prompt" window: MINIMIZE, MAXIMIZE, and NORMALIZE. In addition, you can use the commands TILE and CASCADE to arrange multiple windows on the screen. When using MDI forms, The "R:BASE R> Prompt" window is typically minimized using the MINIMIZE command. When the form is closed, the "R:BASE R> Prompt" window is then maximized using the MAXIMIZE command. When the "R:BASE R> Prompt" window is minimized, any commands that display output to the screen do so, but to the minimized R> prompt_the output is not visible until the "R:BASE R> Prompt" window is maximized or normalized. Sizing the Form The size and location of the window an MDI form displays in are specified by the four numbers following the keyword AT. The numbers are in pixels. The first two numbers are the location of the upper left corner of the form window, measuring from the upper left corner of the "R:BASE 5.5" window. The next two numbers locate the lower right corner of the form window. If the window size is smaller than the defined form size, scroll bars are displayed. Instead of guessing at the size of the form, define a screen area for the form in the Form Designer. Choose Layout: Resolution Guidelines... to define an area on the form. Define a custom area and specify a size, for example, 400 x 350. The first number is the width and the second number is the height. R:BASE displays a red line on the form indicating the size of the screen area. Layout your form objects within the screen area. Using a screen area, you can easily design your form to a specific size and have the coordinates for displaying the form at runtime. Use the screen area size to specify the window size when running the MDI form. For example, a form is defined with a screen area of 400 x 350. The lower right coordinates are the screen area size plus plus 20 pixels to remove scroll bars. If the upper left corner is specified at 10,50, the lower right is (400+20), (350+20) or 420,370. The command used to display the form in a specific size window instead of the default window size might look like this: EDIT MDI formname AT 10,50,420,370 The form window is sizeable and the size can be changed by the user at runtime using the mouse to expand or contract the window size. The user can also move the form window by clicking in the title bar of the window and dragging the form window to a new location. Using SETFOCUS The SETFOCUS command switches focus from the "R:BASE R> Prompt" window to the MDI form window. Even though the form is displayed, R:BASE automatically returns focus to the "R:BASE R> Prompt" window unless you use the SETFOCUS command. A command file or application executes the commands in sequence, one right after the other. The keyword WAIT on the SETFOCUS command pauses the command file until the form is closed. If you don't use the keyword WAIT, R:BASE displays the form, makes the form window the active window, but the command file or application continues to execute in the background. To use the SETFOCUS command (and the CLOSEWINDOW command), you must give the MDI form an alias name using the AS keyword. The alias name is the name referenced by the SETFOCUS and CLOSEWINDOW commands. The alias name comes after the form location in the command syntax. For example: -- set the size of the R> prompt window MINIMIZE -- run the form EDIT MDI formname AT 10,100,430,470 AS alias1 -- make the form the active window SETFOCUS alias1 WAIT You probably won't need to use the CLOSEWINDOW command in your application. The form window is normally closed by exiting the form. You can only use CLOSEWINDOW to close a form that does not currently have focus or is not part of a form-in-a-form procedure. Form-in-a-Form Any form can be displayed in an MDI window. MDI forms can also be used to display a form-in-a-form. When using an MDI form as a form-in-a-form, the calling form must also be an MDI form. In other words, a full screen form can only call a full screen form; an MDI form can only call an MDI form. When using an MDI form-in-a-form, the EEP that calls the second form does not need to include a MINIMIZE or NORMALIZE command. The "R:BASE R> Prompt" window size has already been specified when the first form was displayed. You can't close the calling form until the form-in-a-form is closed. Don't use CLOSEWINDOW in an EEP to close the form-in-a-form, instead put a close or cancel button on the form. MDI forms are usually closed just by exiting the form itself. To specify a location for the form-in-a-form, remember that the first two numbers of the location are based on the upper left corner of the screen. Start the form-in-a-form lower and farther to the right than the calling form. For example, the following commands might call a form: MINIMIZE EDIT MDI form1 AT 10,80,500,400 AS form1 CAPTION+ 'Customer Information' SETFOCUS form1 WAIT MAXIMIZE -- more commands here that execute when the form is closed Form1 has a button, View Transactions, that runs an EEP to call the second form. the second form displays transactions for the current customer. The EEP might contain these commands: EDIT MDI form2 WHERE custid = .vcustid AT 80,140,480,420 + AS form2 CAPTION 'Customer Transactions' SETFOCUS form2 WAIT RETURN When form2 is exited, the form window is automatically closed and focus returns to form1. When form1 is exited, it is automatically closed and the command file that called form1 continues execution.