WINDOW.BAS As with MENU.BAS, you can learn much about using the procedures in WINDOW.BAS by studying the demonstration program UIDEMO.BAS, which is provided as a code example. However, a few words of introduction will be helpful. The best way to get a feel for the ease of use of the window procedures is to experiment for yourself, using the code in the demonstration as an example. In addition to the global-array declarations used with MENU.BAS, you must declare the following global arrays in your program, in the order shown, if you use the procedures in WINDOW.BAS. COMMON SHARED -uitools-GloWindow() AS WindowType COMMON SHARED -uitools-GloButton() AS ButtonType COMMON SHARED -uitools-GloEdit() AS EditFieldType COMMON SHARED -uitools-GloStorage AS WindowStorageType COMMON SHARED -uitools-GloBuffer$() DIM GloWindow(MAXWINDOW) AS WindowType DIM GloButton(MAXBUTTON) AS ButtonType DIM GloEdit(MAXEDITFIELD) AS EditFieldType DIM GloWindowStack(MAXWINDOW) AS INTEGER DIM GloBuffer$(MAXWINDOW +1,2) These global arrays are used to store information about the windows you plan to use in your program. The window effects provided by WINDOW.BAS let you open and use text windows virtually anywhere on your screen. For each window, you can independently define the following window characteristics. * Initial position, by row and column * Color * Ability to close window or not * Ability to move window or not * Ability to resize window or not * Window title * Border characters You also can define as modal windows any of the windows you make. A modal window is a window that forces the user to respond to a prompt within the window itself. You cannot select, either with the mouse or the keyboard, anything outside the window's border. An alert message box is an example of a modal window. A single WindowOpen statement lets you open your window. Once you've opened a window, you can fill it with text, edit fields, list boxes with scroll bars, and push buttons of several types, all of which behave much like the QBX user interface. If you open several windows, you can move between them by using the mouse to select the one you want. A single procedure, WindowDo, monitors your mouse and keyboard activity while a window is open, and responds according to your input. To put text in whatever window is active, WindowLocate lets you specify where the text is to go and WindowPrint lets you print it there. Edit fields (boxes that contain some text for you to either accept or change) are created in a window using EditFieldOpen. They are closed with EditFieldClose. List boxes with scroll bars are displayed by passing an array containing the items in the list to the ListBox procedure. In addition to a list of items, List boxes always contain OK and Cancel command buttons. An assortment of buttons, with a full range of features, are placed on the screen with the ButtonOpen procedure. Supported button types and their behavior are described in the following table. Button type Explanation Command button Confirms settings, gets help, or escapes. Option button Selects one of several options (use direction keys). Check box Turns one option on or off (use Spacebar). Area button An invisible button on the screen that occupies a defined area. When selected, causes some event to occur. Vertical scroll bar Vertically scrolls long lists or screen areas. Horizontal scroll bar Horizontally scrolls screen areas that are wider than the active window. Before opening a window - in fact, before using any of the routines in WINDOW.BAS - you must do some program initialization. The following code fragment illustrates how to do the initialization and how to use some of the procedures in WINDOW.BAS. MenuInit ' Initialize menus and mouse. WindowInit ' Initialize windows. MouseShow ' Make mouse cursor visible. WindowOpen 1,5,25,15,45,0,3,0,3,0,-1,-1,0,0,0,"-Window 1-" WindowPrint 1,"" ' Put a blank line at the top. WindowPrint 1,"Features." ' Put text in the window. WindowPrint 1,"Title bar" WindowPrint 1,"Closable window" WindowPrint 1,"No border" ButtonOpen 1,2,"OK",11,8,1,0,1 ' Open an OK button. WindowOpen 2,8,29,17,49,0,5,0,5,15,-1,-1,0,0,1,"-Window 2-" WindowPrint 1, "" ' Put a blank line at the top. WindowPrint 1, "Features." ' Put text in the window. WindowPrint 1, "Title bar" WindowPrint 1, "Closable window" WindowPrint 1, "Single-line border" WindowLine 9 ' Put a line across the bottom. ButtonOpen 1,2,"OK",11,8,1,0,1 ExitFlag = FALSE WHILE NOT ExitFlag WindowDo 1,0 ' Monitor for a window event. SELECT CASE Dialog(0) ' Return what event occurred. CASE 1,4,6 ' Handle user actions. WindowClose WindowCurrent ' Selecting OK, selecting the ' close box, or pressing Enter. IF WindowCurrent = 0 THEN ' Just in case it's the last ExitFlag = TRUE ' or only window. END IF CASE 3 ' Handle selecting another window WindowSetCurrent Dialog(3) ' and making it current. CASE 9 ' Handle pressing Esc. ExitFlag = TRUE CASE ELSE ' Handle everything else. END SELECT WEND WindowClose 0 ' Close all windows. MouseHide ' Hide the mouse cursor. COLOR 15, 0 ' Change colors back to original. CLS ' Clear the screen. END The code fragment opens two windows, each of a different color. Both contain some text about the features that are available in that window. Both also contain an OK command button that, when chosen, causes the selected window to close. Both windows are movable. To move a window, move the mouse cursor to any of the dot-pattern (ASCII 176) characters adjacent to the title bar, or to the title bar itself. Press the left mouse button and drag a window by moving the mouse. Release the button when you are satisfied with the position. Close a window by selecting the equal sign (=) in the upper-left corner of the window. Pressing Enter while either window is selected has the same effect as choosing the OK command button or selecting the window-close control character (=). Close a window by using WindowClose. WindowClose closes the window and any buttons or edit fields that may be open within the window. You can move between the two windows and close either or both of them in any order. When both are closed, the program ends. When a window can be resized (the windows in the example cannot), a plus (+) character is displayed in the lower-right corner. Select the plus character and drag the mouse to resize the window. The preceding information is intended to give you an overview of how the toolbox windows work. With this overview and the following detailed information about each procedure, you should be able to easily incorporate windows into your BASIC programs. The example code in UIDEMO.BAS demonstrates how most of the procedures are used. A description of each procedure that comprises WINDOW.BAS follows.