home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-04-29 | 95.1 KB | 2,301 lines |
- Page I-8
-
-
- POP UP WINDOW SUPPORT (registered version only).......(Section W)
- Introduction to Turbo ScrEdit Windows (TSW).............. W-1
- Including Turbo ScrEdit Windows in your porgrams......... W-1
- Intializing Turbo ScrEdit Windows........................ W-3
- Memory usage and fragmentation considerations............ W-4
- How many windows can you use............................. M-4
- How the screen memory is used............................ M-4
- Terms used in this document.............................. M-5
- Access a window by name or number........................ M-5
- MAXWINDOWS............................................... W-6
- USERWINDOW............................................... W-6
- ChangeWindow............................................. W-7
- ChgWindowBackGround...................................... W-9
- ClearWindow.............................................. W-11
- DefineWindow............................................. W-12
- EraseWindow.............................................. W-15
- MoveWindow............................................... W-15
- OpenWindow............................................... W-17
- PopWindow................................................ W-17
- PauseWindowUpdates....................................... W-19
- PushWindow............................................... W-18
- ReadWindowField.......................................... W-21
- ReadWindowLine........................................... W-24
- SaveWindow............................................... W-25
- ShutWindow............................................... W-26
- WindowsEnd............................................... W-27
- WindowsInit.............................................. W-28
- WriteWindowField......................................... W-29
- WriteWindowLine.......................................... W-32
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page W-1
-
- Introduction to Turbo ScrEdit Windows
- -----------------------------------------------------------------
- Before you can begin using Turbo ScrEdit Window's procedures and
- functions, you must compile the source code files "Windows.C" and
- "Windows.Pas". If you have installed Turbo ScrEdit on your
- system correctly this has already been done. For complete
- instructions on how to install Turbo ScrEdit on your system and
- prepare the window procedures for use, see pages 4 & 5 of the
- Turbo ScrEdit users manual, "Creating the Turbo Pascal Unit
- Files" and "Creating the Turbo C Libraries".
-
- Once you have installed Turbo ScrEdit in you system you are ready
- to begin using Turbo ScrEdit and Turbo ScrEdit Windows.
-
- From this point forward, throughout this document, I will refer
- to Turbo ScrEdit Windows as "TSW".
-
- TSW is a set of companion routines to Turbo ScrEdit. You do
- not have to include the window routines in your programs to
- use Turbo ScrEdit, but you do have to include the Turbo
- ScrEdit procedures in your program to use Turbo ScrEdit
- Windows.
-
-
-
-
-
- Including Turbo ScrEdit Windows procedures in your programs.
- -----------------------------------------------------------------
-
- Examples:
- Pascal C
- ------------------------------- --------------------------------
- #include <stdlib.h>
- Uses Windows, ScrMouse, ScrEdit; #include "ScrEdit.H"
- ------------------------------- --------------------------------
-
- Pascal example:
-
- In the pascal example above we see that the "UNIT" files
- "Windows.Tpu", "ScrMouse.Tpu", and "ScrEdit.Tpu" are being
- used in the current program.
-
-
- C example:
-
- There is five steps required to use TSW in a Turbo "C"
- program.
-
- Step 1: In the C example above we see that the header files
- "ScrEdit.H" and "Windows.H" are included into the
- source file. These file contain the prototypes for all
- of Turbo ScrEdit's and TSW's procedures and global
- variables.
-
- Step 2: Decide which memory model you wish to use for your
- program, MEDIUM, COMPACT, LARGE, or HUGE.
-
-
-
-
-
-
-
- Page W-2
-
-
- Step 3: Prepare a project file for your program. For this
- example lets say we are going to create a program
- called PAYROLL.C. Lets also assume that we have
- copied the Turbo ScrEdit and TSW library files into
- the library directory of the Turbo C compiler
- "C:\TC\LIBRARY."
-
- For the above scenario we would create one of the
- following project files depending on which memory
- model we selected, and store it in a file named
- "PAYROLL.PRJ".
-
- For MEDIUM memory model:
-
- PAYROLL
- C:\TC\LIBRARY\SCREDITM.LIB
- C:\TC\LIBRARY\WINDOWSM.LIB
-
- For COMPACT memory model:
-
- PAYROLL
- C:\TC\LIBRARY\SCREDITC.LIB
- C:\TC\LIBRARY\WINDOWSC.LIB
-
- For LARGE memory model:
-
- PAYROLL
- C:\TC\LIBRARY\SCREDITL.LIB
- C:\TC\LIBRARY\WINDOWSL.LIB
-
- For HUGE memory model:
-
- PAYROLL
- C:\TC\LIBRARY\SCREDITH.LIB
- C:\TC\LIBRARY\WINDOWSH.LIB
-
- Step 4: Set the Turbo C programming environment menu options
- PROJECT/PROJECT NAME to read "PAYROLL.PRJ".
-
- Step 5: Set the Turbo C programming environment menu options
- OPTIONS/COMPILER/MODEL to read COMPACT (or which ever
- memory model that you have selected.)
-
-
- When the above five steps are completed, you are ready to
- begin compiling and linking programs using Turbo ScrEdit and
- Turbo ScrEdit Windows.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page W-3
-
- Initializing Turbo ScrEdit Windows..
- -----------------------------------------------------------------
- Pascal example:
-
- No example is needed, initialization is automatic in pascal.
-
-
- C Examples 1:
- ----------------------------------------------------------
- .
- .
- S_OpenScreenFile("FileName");
- if (!WindowsInit)
- {
- cprintf("%s","Not enough free memory for Window");
- S_CloseScreenFile();
- exit(0);
- }
- .
- .
- ----------------------------------------------------------
-
-
- C Examples 2:
- ----------------------------------------------------------
- .
- .
- S_Init();
- if (!WindowsInit)
- {
- cprintf("%s","Not enough free memory for Window");
- S_CloseScreenFile();
- exit(0);
- }
- .
- .
- -----------------------------------------------------------
- You will notice in the two examples above that the windows
- initialization procedure "WindowsInit" is called after the
- call to "S_OpenScreenFile" in example 1 and after the call
- to "S_Init" in example 2. It is important that Turbo ScrEdit
- Windows be initialized AFTER Turbo ScrEdit is initialized.
- You will find more information on using "WindowsInit" in the
- procedure description of this manual.
-
- After you have done the above steps, you can then define
- as many windows as you wish for use in your programs.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page W-4
-
- Memory usage and fragmentation considerations.
- -----------------------------------------------------------------
- TSW allocates memory work space on the far heap. Each time a
- window is defined TSW allocates two blocks of memory large enough
- to hold the window image as well as the screen image that has
- been overlaid by the window image. When windows are defined using
- "DefineWindow" the memory is allocate. When windows are erase
- from memory using "EraseWindow" the memory is re-leased back to the
- heap manager. The next time memory is allocated by your program
- the heap manager will search for a contiguous block of memory
- large enough to meet the request. This process can small unused
- blocks of memory that can lead to memory fragmentation.
-
- To avoid memory fragmentation and possibly running out of memory
- while your program is running, it is recommended that you define
- all the windows that you want to use in your program during the
- initialization section of your program. This will have all window
- memory allocated from the heap in a contiguous block.
-
- This is a recommendation only. You can define windows and erase
- them any way that you wish. But you can run the risk of
- fragmenting memory and running out of blocks large enough for
- dynamic allocation of the local variables for your procedures, as
- well as when you try to define additional windows.
-
-
-
- Additional information about using Turbo ScrEdit Windows
- -----------------------------------------------------------------
- How many windows can you use:
-
- You can define as many windows as will fit in your computer's
- memory. Each window you define requires approximately 120
- bytes of data segment memory, with the actual window memory
- being allocated from the "heap". You can set the maximum
- number of windows that will be allowed by setting the value of
- the global constant MAXWINDOWS.
-
-
- How TSW uses screen memory:
-
- Imagine if you will that you could stack transparent screens
- one on top of another up to MAXWINDOWS deep in front of your
- video monitor screen. The first (or bottom) screen of the
- stack would be your video monitor screen, and the stack of
- transparent screens would be called the "window layer stack".
-
- The most important layer of the window layer stack is the
- surface layer, the one that would physically be furthest away
- from your video monitor screen and closest to you. This layer
- is called the "active" window layer.
-
- Each time you define a window using TSW, the window is placed
- on top of the window layer stack and any windows previously
- defined are pushed down a layer, or overlapped by the newly
- defined window.
-
-
-
-
-
-
-
-
- Page W-5
-
- Terms Used in this document:
-
- "WINDOW LAYER" - An imaginary layer on the screen. TSW places
- each window in its own "layer". No two
- windows may occupy the same window layer.
-
- "WINDOW LAYER STACK" - A term used to illustrate one or more
- overlapping window layers on a screen.
-
- "ACTIVE WINDOW" - The active window will be the open window
- that occupies the surface layer of the
- window stack. If you use the "clrscr"
- statement in your program the active
- window would have its contents erased.
- Likewise using a Write or WriteLn, or
- cprintf will display text in the active
- window. When no windows are displayed
- the normal monitor screen is considered the
- active window.
-
- "OPEN WINDOW" - An open window will be visible on the
- screen, or may be on the screen but covered
- by another window.
-
- "HIDDEN WINDOW" - A window that has been shut and is not
- visible on the window.
-
- "WINDOW NUMBER" - The window number is assigned by the
- DefineWindow function. This number can be
- used to specify the target window of most
- of TSW's procedures.
-
- "WINDOW NAME" - The window name is specified when the window
- is defined and can be used in place of the
- window number to specify the target window
- of many of TSW's procedures. Window name
- is optional in all procedure calls except
- Definewindow.
-
-
- Accessing Windows by Name and Number:
-
- Most of TSW's procedures for manipulating windows give you two
- options for specifying the target window to be acted upon by
- the procedure:
-
- 1 - Using the unique number that was returned by DefineWindow
- when you defined the window. This is the most efficient
- way of referencing a window.
-
- 2 - Using the window name that you specify when you define a
- window. When a window name is specified the window number
- argument is ignored. This is the least efficient method of
- accessing a window because the window list must be search
- and a string comparison made until the target window is
- located.
-
-
-
-
-
-
-
-
- Page W-6
-
-
- Global Variables and Constants:
- -----------------------------------------------------------------
- MAXWINDOW
- Function : Sets the maximum number of windows that any
- program using the windows "UNIT" or "LIRBRARY"
- file will be allowed to define.
- Remarks : MAXWINDOW must be set to a value BEFORE THE SOURCE
- FILES "Windows.Pas" or "Windows.C" are compiled.
-
- MAXWINDOW may be set to any value that you wish,
- limited only by the amount of memory that is
- available in your machine.
-
- MAXWINDOW is a constant defined at the beginning
- of the source files "Windows.Pas" and
- "Windows.C."
-
- Default : MAXWINDOW has a default value of 20, meaning
- by default a program may have no more that 20
- active windows at any given time.
-
-
- defined in C:
-
- #define MAXWINDOW 20
-
- defined in Pascal:
-
- Const
- MAXWINDOW = 20;
-
-
-
-
-
- USERWINDOW
-
- Integer : UserWindow will always contain the window number of
- the window that is currently the active window. The
- active window will always be the window that is
- occupying the surface layer of the screen.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page W-7
-
- ChangeWindow
- ----------------------------------------------------------------
- Function: Changes an existing window's characteristics that were
- assigned when the window was created.
-
- Remarks: Use this procedure to re-configure an existing window.
- You can change any of the visible characteristics. You
- cannot change the Row, or Column position of the window.
- Use MoveWindow to relocate a window. You cannot change
- the size of a window, that is, the lines in the window
- or the line length. To change a window size, create a
- new window and copy the contents of the existing window
- to the new window.
-
- Defined for Turbo C as:
-
- void ChangeWindow(char *WindowName,
- int WindowNo,
- int BorderStyle,
- int BorderBg,
- int BorderFg,
- char *WindowNm,
- int WindowNameBg,
- int WindowNameFg,
- int WindowNamePos,
- char *WindowFoot,
- int WindowFootBg,
- int WindowFootFg,
- int WindowFootPos,
- int TextBgColor,
- int TextFgColor)
-
-
- Defined for Turbo Pascal as:
-
- Procedure ChangeWindow(WindowName : S_Str80;
- WindowNo,
- BorderStyle,
- BorderBg,
- BorderFg:Integer;
- WindowNm :S_Str80;
- WindowNameBg,
- WindowNameFg,
- WindowNamePos : Byte;
- WindowFoot :S_Str80;
- WindowFootBg,
- WindowFootFg,
- WindowFootPos,
- TextBgColor,
- TextFgColor :Byte);
-
-
- Parameter description:
-
- WindowName...........The current name of the target window.
-
- WindowNo.............The unique number of the target window
- returned by DefineWindow.
-
-
- (continued on next page)
-
-
-
- Page W-8
-
-
- BorderStyle..........Border style of window
- 0 = no border on window.
- 1 = Bold line character set for border.
- 2 = use single line character set.
- 3 = use double line character set.
-
- BorderBg.............Border character background color (0-7)
-
- BorderFg.............Border character foreground color (0-15)
-
- WindowNm.............Window Name. The window name has two
- uses in TSW.
- 1 - The name will show as the window
- label in the top line of the
- border.
- 2 - All window functions can be
- performed using the window name
- instead of the window number. See
- each window function for an
- explanation.
-
- WindowNameBg.........Window Label background color. (0-7)
-
- WindowNameFg.........Window Label foreground color. (0-15)
-
- WindowNamePos........Window Label Position in top line of
- window border:
- 0 = No label to show on window.
- 1 = Place label on left side.
- 2 = Place label on right side.
- 3 = Center label.
-
- WindowFoot...........Footer message up to 78 characters long
- that will be in the bottom line of the
- window border.
-
- WindowFootBg.........Footer message background color.(0-7)
-
- WindowFootFg.........Footer Message foreground color.(0-15)
-
- WindowFootPos........Window footer position in bottom line
- of window border:
- 0 = No footer to show on window.
- 1 = Place footer on left side.
- 2 = Place footer on right side.
- 3 = Center footer.
-
- TextBgColor..........Default text background color for all
- characters written inside the
- window.(0-7)
-
- TextFgColor..........Default text foreground color for all
- characters written inside the
- window.(0-15)
-
-
-
-
-
-
-
-
-
- Page W-9
-
-
- Pascal C
- ------------------------------- -------------------------------
- . .
- . .
- => ChangeWindow( ChangeWindow(
- => '',MenuWindow, "",MenuWindow,
- => 3, {Border Sytle} 3, /* Border Style */
- => Red, {Border Bg } RED, /* Border Bg */
- => Yellow,{Border Fg } YELLOW,/* Border Fg */
- Config.WindowName, Config.WindowName,
- Config.WindowNameBg, Config.WindowNameBg,
- Config.WindowNameFg, Config.WindowNameFg,
- Config.WindowNamePos, Config.WindowNamePos,
- Config.WindowFoot, Config.WindowFoot,
- Config.WindowFootBg, Config.WindowFootBg,
- Config.WindowFootFg, Config.WindowFootFg,
- Config.WindowFootPos, Config.WindowFootPos,
- => Red, {Text Bg} RED, /* Text Bg */
- => Yellow);{Text Fg} YELLOW);/* Text Fg */
- . .
- . .
- ------------------------------- -------------------------------
- In this example we are going to temporarily change the border
- style and color, and the window text colors.
-
- In this example we are accessing the window by the window
- number assigned to the integer field "MenuWindow" when it was
- defined. See the description of "DefineWindow" for an example
- of how the field "MenuWindow" received it's value.
-
- The changes made to this window are temporary, at some other
- point in the program another call to ChangeWindow will be
- issued using the original parameters in the "Config" record.
-
-
-
-
-
- ChgWindowBackGround
- -----------------------------------------------------------------
- Function : Changes screen background while windows are visible.
-
- Remarks : Use this procedure to change the main screen background
- while windows are open and displayed on the screen. The
- old screen is completely replaced, including the screen
- segments that are saved and replaced when each window
- is opened and closed.
-
- Keep in mind that you must make sure that the memory to
- be sent to video memory has been formatted properly in
- character and video attribute pairs.
-
- If no windows are open and displayed this call will
- have no effect. The screen loaded will not be
- displayed, and will be overlaid by the current
- screens image when the next window is opened.
-
-
-
-
-
-
-
- Page W-10
-
- Defined for Turbo C as:
-
- void ChgWindowBackGround(char *Sc,
- int Length)
-
- Defined for Turbo Pascal as:
-
- Procedure ChgWindowBackGround(NS_Seg,
- NS_Ofs,
- Length:LongInt);
-
-
- Parameter description:
-
- *Sc (C)..............Pointer to memory containing screen image.
-
- NS_Seg (Pascal)......The memory segment of the new screen
- area.
-
- NS_Ofs (Pascal)......The memory offset of the new screen area.
-
- Length...............The number of bytes to be transferred.
-
-
- Pascal C
- ------------------------------- -------------------------------
- . .
- . .
- If S_F1 Then if (S_F1)
- Begin {
- Seek(HFile,Screen7); fseek(HFile,(Size*7),SEEK_SET
- Read(HFile,HelpRec); fread(HelpRec,4000L,1,HFile);
- ==> ChgWindowBackGround( ChgWindowBackGround(
- Seg(HelpRec.V[1]), &HelpRec.V[0],
- Ofs(HelpRec.V[1]), 4000L);
- 4000); }
- End;
- . .
- . .
- ------------------------------- -------------------------------
- When the user presses the F1 key In the above code segment,
- the program will retrieve record 7 from the file assigned to
- "FFile" and read the record into the buffer "HelpRec".
-
- Next the call to the procedure "ChgWindowBackGround" is
- passing the memory address of the first character in the
- record. When this procedure is called it will cause the new
- screen to appear behind any windows that are open and visible
- on the screen.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page W-11
-
- ClearWindow
- -----------------------------------------------------------------
- Function : Clears all lines of the specified window and set the
- window text back ground color and foreground colors.
-
- Remarks : This function erase all data from all the text lines
- of a windows and sets the foreground and background
- color attributes of the window to the specified
- colors. This procedure will clear any window that has
- been defined, ever if the target window is hidden (not
- visible on the screen), or partially or completely
- overlapped by another window.
-
- The call has no effect if the window specified by
- WindowName or WindowNumber has not been defined.
-
- Defined for Turbo C as:
- void ClearWindow(char *WindowName,
- int WindowNo,
- int OverRideBg,
- int OverRideFg)
-
- Defined for Turbo Pascal as:
- Procedure ClearWindow(WindowName:S_Str80;
- WindowNo,
- OverRideBg,
- OverRideFg :Byte);
-
- Parameter description:
-
- WindowName...........The name of the target window that was
- assigned when the window was defined.
-
- WindowNo.............The unique number of the target window
- returned by DefineWindow.
-
- OverRideBg...........Overrides the normal text background
- color specified when the window was
- defined. A value of zero will not over-
- ride TextBg.
-
- OverRideFg...........Overrides the normal text foreground
- color specified when the window was
- defined. A value of zero will not over-
- ride TextFg.
-
- Pascal C
- ------------------------------- -------------------------------
- . .
- . .
- => ClearWindow('',ResultWindow); ClearWindow("",ResultWindow);
- LoadResultWindow; LoadResultWindow();
- OpenWindow('',ResultWindow); OpenWindow("",ResultWindow);
- . .
- . .
- ------------------------------- -------------------------------
- In the above example a window has been defined to present the
- results of some process performed by the program. The Window
- is cleared by a call to ClearWindow before the text is loaded
- into it and it is opened for viewing.
-
-
-
-
- Page W-12
-
- DefineWindow
- ----------------------------------------------------------------
- Function: Builds a window record in memory and allocates the
- memory required to store the window and the screen
- memory that is covered by the window when it is
- displayed on the screen.
-
- Return Value:
-
- 0 - If DefineWindow was unable to create the window
- successfully. There are two possible reasons:
- - insufficient memory (heap)
- - there are already MAXWINDOWS windows defined.
-
- >0 - Is the window number that has been assigned. You can Use
- this number to refer to the window when calling other
- Turbo Window operations on this window.
-
-
- Remarks: Windows are created when they are defined. When a window
- is defined it is given a status of "HIDDEN". You must
- use OpenWindow to display the new window on the screen.
-
- Defined for Turbo C as:
- int DefineWindow(int WindowRow,
- int WindowCol,
- int WindowLength,
- int WindowLines,
- int BorderStyle,
- int BorderBg,
- int BorderFg,
- char *WindowName,
- int WindowNameBg,
- int WindowNameFg,
- int WindowNamePos,
- char *WindowFoot,
- int WindowFootBg,
- int WindowFootFg,
- int WindowFootPos,
- int TextBgColor,
- int TextFgColor)
-
- Defined for Turbo Pascal as:
- Function DefineWindow(WindowRow,
- WindowCol,
- WindowLength,
- WindowLines,
- BorderStyle,
- BorderBg,
- BorderFg:Integer;
- WindowName :S_Str80;
- WindowNameBg,
- WindowNameFg,
- WindowNamePos : Byte;
- WindowFoot :S_Str80;
- WindowFootBg,
- WindowFootFg,
- WindowFootPos,
- TextBgColor,
- TextFgColor :Byte):Integer;
-
-
-
-
- Page W-13
-
- Parameter description:
- WindowRow............The screen row (1-23) where the top
- left corner of the window will be
- placed.
-
- WindowCol............The screen column (1-77) where the top
- left corner of the window will be
- placed.
-
- WindowLength.........The length in characters (1-77) of a
- window line.
- If WindowLength + WindowCol exceeds 80
- characters then WindowLength is reduced
- to 78 - WindowCol;
-
- WindowLines..........The number of text lines (1-22) inside
- the window.
- If WindowLines + WindowRow exceeds 24
- then WindowLines is reduced to 22 -
- WindowRow.
-
- BorderStyle..........Border style of window
- 0 = no border on window.
- 1 = bold line character set.
- 2 = use single line character set.
- 3 = use double line character set.
-
- BorderBg.............Border character background color (0-7)
-
- BorderFg.............Border character foreground color (0-15)
-
- WindowName...........Window Name. The window name has two
- uses in TSW. First the name will show
- as the window label in the top line of
- the border. All window functions can be
- performed using the window name instead
- of the window number. See each window
- function for an explanation.
-
- WindowNameBg.........Window Label background color. (0-7)
-
- WindowNameFg.........Window Label foreground color. (0-15)
-
- WindowNamePos........Window Label Position in top line of
- window border:
- 0 = No label to show on window.
- 1 = Place label on left side.
- 2 = Place label on right side.
- 3 = Center label.
-
- WindowFoot...........Footer message up to 78 characters long
- that will be in the bottom line of the
- window border.
-
- WindowFootBg.........Footer message background color.(0-7)
-
- WindowFootFg.........Footer Message foreground color.(0-15)
-
-
-
-
-
-
-
- Page W-14
-
- WindowFootPos........Window footer position in bottom line
- of window border:
- 0 = No footer to show on window.
- 1 = Place footer on left side.
- 2 = Place footer on right side.
- 3 = Center footer.
-
- TextBgColor..........Default text background color for all
- characters written inside the
- window.(0-7)
-
- TextFgColor..........Default text foreground color for all
- characters written inside the
- window.(0-15)
-
- Memory requirements:
-
- To calculate bytes of heap memory usage use the following
- formula:
- ((((WindowLines + 2) * (WindowLength + 2)) * 2) * 2)
-
- To calculate data segment memory usage:
- MemoryNeeded = MAXWINDOWS * 120;
-
-
- Pascal C
- ------------------------------- -------------------------------
- . .
- Var .
- => MenuWindow : Integer; int MenuWindow;
- . .
- . .
- => MenuWindow := MenuWindow =
- => DefineWindow( DefineWindow(
- Config.WindowRow, Config.WindowRow,
- Config.WindowCol, Config.WindowCol,
- Config.WindowLength, Config.WindowLength,
- Config.WindowLines, Config.WindowLines,
- Config.BorderStyle, Config.BorderStyle,
- Config.BorderBg, Config.BorderBg,
- Config.BorderFg, Config.BorderFg,
- Config.WindowName, Config.WindowName,
- Config.WindowNameBg, Config.WindowNameBg,
- Config.WindowNameFg, Config.WindowNameFg,
- Config.WindowNamePos, Config.WindowNamePos,
- Config.WindowFoot, Config.WindowFoot,
- Config.WindowFootBg, Config.WindowFootBg,
- Config.WindowFootFg, Config.WindowFootFg,
- Config.WindowFootPos, Config.WindowFootPos,
- Config.TextBg, Config.TextBg,
- Config.TextFg); Config.TextFg);
- . .
- . .
- ------------------------------- -------------------------------
- In the above example we see an integer variable MenuWindow is
- defined.
-
- Next we set a call to DefineWindow. The parameters for
- defining the window have been stored in a configuration file
- and are fields in a record name "Config".
-
-
-
-
- Page W-15
-
- As a result of the call to DefineWindow, the field MenuWindow
- is being assigned a value. The integer value assigned to
- MenuWindow will be use to access the new window in all
- subsequent calls to other TSW window routines.
-
-
-
-
- EraseWindow
- -----------------------------------------------------------------
- Function: De-allocates a window and returns the memory allocated
- by DefineWindow back to the heap. All references to the
- window are erased from memory.
-
- Defined for Turbo C as:
- void EraseWindow(char *WindowName,int WindowNo)
-
- Defined for Turbo Pascal as:
- Procedure EraseWindow(WindowName:S_Str80;WindowNo:Integer);
-
- Parameter description:
- WindowName...........The name of the target window.
-
- WindowNo.............The unique number of the target window
- returned by DefineWindow.
-
- Pascal C
- ------------------------------- -------------------------------
- . .
- . .
- CloseDataFiles; CloseDataFiles();
- For X := 1 to 7 for (x=1;x<8;x++)
- => EraseWindow('',X); EraseWindow("",x);
- . .
- . .
- ------------------------------- -------------------------------
- In the above example three program is absolute to end and perhaps
- return to the system menu. The program is closing it's data
- files, and releasing the heap memory allocated for windows
- back to the "heap manager".
-
-
-
-
- MoveWindow
- ----------------------------------------------------------------
- Function : Moves the specified window to a new screen location.
-
- Defined for Turbo C as:
- void MoveWindow(char *WindowName,
- int WindowNo,
- int RowMovement,
- int ColMovement,
- char Tipe)
-
- Defined for Turbo Pascal as:
- Procedure MoveWindow(WindowName:S_Str80;
- WindowNo,
- RowMovement,
- ColMovement : Integer;
- Tipe : Char);
-
-
-
- Page W-16
-
- Parameter description:
- WindowName...........The name of the target window.
-
- WindowNo.............The unique number of the target window
- returned by DefineWindow.
-
- RowMovement..........Depending on the value of Tipe
- RowMovement is either a new screen row
- for the window or the number of rows to
- move the window.
-
- ColMovement..........Depending on the value of Tipe
- ColMovement is either a new screen row
- column or the number of columns to move
- the window.
-
- Tipe.................Specifies how the window is to be moved
- where:
-
- A = RowMovement and ColMovement are the
- absolute screen coordinates for the
- new location of the top right
- corner of the widow.
-
- R = RowMovement and ColMovement are
- relative coordinates to be added to
- the current row and column and the
- window is to be move relative to
- the new calculated row and column.
- (Use this option to DRAG windows on
- the screen).
-
- Pascal C
- ------------------------------- -------------------------------
- . .
- . .
- => MoveWindow('',4,1,50,'a'); MoveWindow("",4,1,50,'a');
- OpenWindow('',4); OpenWindow('',4);
- Row := 1; Row = 1;
- Col := -3; Col = -3;
- For X := 1 to 17 Do for (X=1;X<18;X++)
- => MoveWindow("",4, MoveWindow("",4,
- Row,Col,'r'); Row,Col,'r');
- . .
- . .
- ------------------------------- -------------------------------
- This example demonstrates how to "drag" a window from one
- location on the screen to another.
-
- First MoveWindow statement performed will move the window to
- the absolute screen coordinates of row 1 and column 50. The
- window is then opened, or made visible, in the upper right
- hand corner of the screen.
-
- Next a loop is performed 17 times. Each time MoveWindow is
- performed with a row value of 1, a column value of -3, and a
- "R" or relative option . Each time MoveWindow is called the
- window move down one row and left three columns on the screen.
- The effect to the user of the program would be that the window
- smoothly slides across the screen.
-
-
-
-
- Page W-17
-
- OpenWindow
- -----------------------------------------------------------------
- Function: Makes a window visible on the screen.
-
- Remarks: This call is ignored if the specified window has not
- been defined, or if the window is already open.
-
- Defined for Turbo C as:
-
- void OpenWindow(char *WindowName,int WindowNo)
-
- Defined for Turbo Pascal as:
-
- Procedure OpenWindow(WindowName:S_Str80;WindowNo:Integer);
-
- Parameter description:
-
- WindowName...........The name of the target window.
-
- WindowNo.............The unique number of the target window
- returned by DefineWindow.
-
- Pascal C
- ------------------------------- -------------------------------
- Var MenuWindow : Integer; int MenuWindow;
- : :
- MenuWindow := DefineWindow( MenuWindow = DefineWindow(
- : :
- => OpenWindow('',MenuWindow) OpenWindow("",MenuWindow);
- : :
- ------------------------------- -------------------------------
- In the above example an integer variable name MenuWindow is
- defined at the beginning of a program. Later in the program
- MenuWindow is assigned a value when the window is defined.
-
- Finally the window is opened for use and displayed on the
- screen.
-
-
- PopWindow
- -----------------------------------------------------------------
- Function: Pops the specified window from its current position in
- the window layer stack to the top or surface layer
- of the screen stack.
-
- Remarks: If the specified window is open (displayed on the
- screen), it is established as the "current active"
- window. All windows displayed on the screen that
- occupied a window layer above the popped window are
- pushed down in the window stack.
-
- If the specified window is hidden (not visible on the
- screen), it is popped to the surface but remains
- invisible. The current active screen before the window
- is popped remains the active window until the popped
- window is opened using OpenWindow.
-
- If the specified window has not been defined by using
- DefineWindow the call is ignored.
-
-
-
-
-
- Page W-18
-
- Defined for Turbo C as:
-
- void PopWindow(char *WindowName,int WindowNo)
-
- Defined for Turbo Pascal as:
-
- Procedure PopWindow(WindowName:S_Str80;WindowNo:Integer);
-
- Parameter description:
- WindowName...........The name of the target window.
-
- WindowNo.............The unique number of the target window
- returned by DefineWindow.
-
- Pascal C
- ------------------------------- -------------------------------
- . .
- . .
- OpenWindow('',4); OpenWindow("",4);
- => PopWindow('',4); PopWindow("",4);
- . .
- . .
- ------------------------------- -------------------------------
- Window number 4 is opened or made visible on the screen. It is
- then "popped" to the surface layer of the screen.
-
-
-
-
- PushWindow
- -----------------------------------------------------------------
- Function: Moves the target window from one layer of the window
- layer stack to another.
-
- Remarks: Both the FromWindow and the window occupying the
- ToLayer must be defined before this call is performed.
- Either of the windows specified may be hidden.
-
- If the FromWindow is deeper in the stack than the
- ToLayer, all windows above the FromWindow up to and
- including the ToLayer are pushed down in the stack and
- the FromWindow is placed in the ToLayer.
-
- If the FromWindow is above the ToLayer in the stack,
- all windows from the ToLayer to the FromWindow are
- pushed up in the window layer stack and the FromWindow
- is inserted in the vacant ToLayer.
-
- After the push occurs the open window closest to the
- surface layer of the stack will become the active
- window.
-
-
- Defined for Turbo C as:
-
- void PushWindow(char *WindowName,
- int FromWindow,
- int ToLayer);
-
-
-
-
-
-
- Page W-19
-
- Defined for Turbo Pascal as:
-
- Procedure PushWindow(WindowName:S_Str80;
- FromWindow:Integer,
- ToLayer:Integer);
-
-
- Parameter description:
- WindowName...........The name of the target window to be
- moved.
-
- FromWindow...........The unique number of the window to be
- moved.
-
- ToLayer..............The Physical window layer that you wish
- to place the FromWindow in.
-
- Pascal C
- ------------------------------- -------------------------------
- . .
- . .
- OpenWindow('',1); OpenWindow("",1);
- OpenWindow('',2); OpenWindow("",2);
- OpenWindow('',3); OpenWindow("",3);
- => PushWindow('',3,1); PushWindow("",3,1);
- . .
- . .
- ------------------------------- -------------------------------
- In this example windows 1, 2, and 3 are opened on the screen.
- Window 3 is then pushed to layer 1 of the window stack. On the
- screen window three would move from being fully visible to
- begin overlaid by windows 1 and two.
-
-
-
- PauseWindowUpdates
- -----------------------------------------------------------------
- Function : Pauses or Resumes video memory updates.
-
- Remarks : Proper use of this procedure will greatly enhance the
- efficiency of programs using TSW.
-
- I/O to the video screen can be the slowest operation
- performed by TSW. Normally the results of each
- operation that you perform on a window becomes visible
- immediately on the screen. For example, in an
- application where you were going to close two windows
- and open one, you would be able to detect the first
- window as it disappeared, then the second window, then
- the new window would appear. Even though the changes
- happen very quickly, you would see all three steps.
-
- Calling PauseWindowUpdates with an argument of TRUE
- before you began updating the screen would allow TSW
- to perform the three steps quickly in memory. The
- results of closing two windows and opening one would
- not appear on the video memory until you called
- PauseWindowUpdates again with an argument of FALSE.
- Then the updated screen would appear. TSW only updated
- video memory once, and from the user's perspective,
- the video screen changed instantly.
-
-
-
- Page W-20
-
- Defined for Turbo C as:
-
- void PauseWindowUpdates(unsigned char Switch);
-
- Defined for Turbo Pascal as:
-
- Procedure PauseWindowUpdates(Switch:Boolean);
-
- Parameter description:
-
- Switch.......In pascal the switch is a boolean variable with
- the values:
- TRUE = Pause video memory updates
- FALSE = Resume video memory updates.
- In C is the switch is an unsigned character
- variable with the values:
- 1 = Pause video memory updates
- 0 = Resume video memory updates.
-
-
-
- Pascal C
- ------------------------------- -------------------------------
- . .
- . .
- => PauseWindowUpdates(True); PauseWindowUpdates(1);
-
- For X := 1 to 14 do for (X=1;X<15;X++)
- WriteWindowLine("",5, WriteWindowLine("",5,
- X,W_Off,0, X,W_Off,0,
- 0,0, 0,0,
- Msg_5[X+8]); Msg_5[X+8]);
-
- => PauseWindowUpdates(False); PauseWindowUpdates(0);
- . .
- . .
- ------------------------------- -------------------------------
- In this example 15 lines of text are to be written to Window
- number 5. Normally each time a line of text is written TSW
- wants to update the screen memory and the user would see each
- line appear one after the other.
-
- The first call to PauseWindowUpdates with a TRUE argument
- instructs TSW to postpone screen updates until further notice.
-
- The 15 lines of text are then written much faster to the
- memory image of the window.
- -
- The second call to PauseWindowUpdates with a FALSE argument
- instructs TSW to update the screen with the current screen and
- window status and resume immediate screen updates.
-
- Using PauseWindowUpdates will make the entire process seem to
- have happened instantly.
-
-
-
-
-
-
-
-
-
-
- Page W-21
-
- ReadWindowField
- ----------------------------------------------------------------
- Function: Accepts a string of characters into a user defined data
- entry field in the current or active window.
-
- Remarks: If the specified window is not the current active
- window, it is popped before data the data entry field
- is displayed on the screen. See "POPWINDOW".
-
- Field editing has all the characteristics of any field
- of a Turbo ScrEdit data entry screens.
-
- Defined for Turbo C as:
-
- char *ReadWindowField(char *WindowName,
- int WindowNo,
- int WindowRow,
- int WindowCol,
- int DataType,
- int DataLength,
- int PromptBgColor,
- int PromptFgColor,
- char *CharString)
-
- Defined for Turbo Pascal as:
-
- Procedure ReadWindowField(WindowName:S_Str80;
- WindowNo,
- WindowRow,
- WindowCol,
- DataType,
- DataLength,
- PromptBgColor,
- PromptFgColor:Integer;
- Var CharString :S_Str80);
-
- Parameter description:
-
- WindowName...........The name of the target window.
-
- WindowNo.............The unique number of the target window
- returned by DefineWindow.
-
- WindowRow............The window line to be written to.
-
- WindowCol............The column (-1) on the row where the
- data entry field is to begin. Remember
- Turbo ScrEdit adds one character to the
- beginning and ending of fields.
-
- DataType.............Specifies the type of keystrokes that
- will be accepted into the data entry
- field.
-
- 0 = Integer value.
- 2 - 7 = decimal values with absolute
- decimal position in string being
- at DataType.
- 8 = alphabetical key and space only.
- 9 = any keyboard character.
-
-
-
-
- Page W-22
-
-
- DataLength...........The length of the field.
-
- ** NOTE ** if the length of the field
- will exceed the length of the window
- line, the field length is adjusted to:
-
- (Length of Window Line) - (WindowCol) - 1;
-
- PromptBgColor........The background color attribute for the
- data entry field.
-
- PromptFgColor........The foreground color attribute for the
- data entry field.
-
- CharString...........Is a pointer to a string variable
- containing the current value of the
- data entry field.
-
- On exiting this procedure the variable
- pointed to by CharString will contain
- the new or edited string value.
-
- Pascal
- -------------------------------------------------------------
- :
- Var
- => Response : S_Str80;
- :
- Repeat
- Case Y Of
- 1 :Begin
- => Response := Employe.Name;
- => ReadWindowField ('',NameWindow,5,21,8,30,7,0,Response);
- Employe.Name := Response;
- End;
- 2 :Begin
- Response := Employe.Address;
- => ReadWindowField ('',NameWindow,6,21,0,30,7,0,Response);
- Employe.Address := Response;
- End;
- 3 :Begin
- Response := Employe.City_State_Zip;
- => ReadWindowField ('',NameWindow,7,21,0,30,7,0,Response);
- Employe.City_State_Zip := Response;
- End;
- End;
- If S_Tab Then If S_Shift Then Dec(Y) else Inc(Y);
- If Y>3 Then Y := 1;
- If Y<1 Then Y := 3;
- Until S_Enter;
- :
- -----------------------------------------------------------
- In Pascal the field "Response" is defined as type "S_Str80"
- and is used as a work field for passing a field value to and
- from ReadWindowField for editing. (S_Str80 is defined in Turbo
- ScrEdit.).
-
- See the description following the C example for further
- discussion of this procedure.
-
-
-
-
- Page W-23
- C
- -----------------------------------------------------------
- => char Response[81];
- :
- do{
- switch (Y)
- {
- case 1 :{
- => strcpy(Response,Employe.Name);
- => ReadWindowField ("",NameWindow,5,21,8,8,7,0,Response);
- strcpy(Employe.Name,Response[0]);
- break;
- };
- case 2 :{
- strcpy(Response,Employe.Address);
- => ReadWindowField ("",NameWindow,6,21,0,8,7,0,Response);
- strcpy(Employe.Address,Response);
- break;
- };
- case 3 :{
- strcpy(Response,Employe.City_State_Zip);
- => ReadWindowField ("",NameWindow,7,21,0,8,7,0,Response);
- strcpy(Employe.City_State_Zip,Response);
- break;
- };
- }
- if (S_Tab) if (S_Shift) Y--; else Y++;
- if (Y>3) Y = 1;
- if (Y<1) Y = 3;
- }while (!S_Enter);
- ----------------------------------------------------------------
- In C the field "Response" is defined as an eighty element
- array of type char. This field is to be used as the work field
- for value passed a field value to and from ReadWindowField for
- editing.
-
- In this code segment we see a do/while and a Repeat/Until
- loop is began that will continue until S_Enter is pressed.
-
- Next the value of Y is tested to determine which of the two
- fields are to be edited.
-
- When Y has a value of one:
- 1 - Response is assigned the value of Employe.Name.
- 2 - ReadWindowField is call to edit employee name in the
- window addressed by "NameWindow".
- - It is to edit a field on line 6.
- - Beginning at column 21 of the line.
- - The field is of type 9 which allow any keyboard
- character to be keyed into it.
- - The field has a length of 30 characters
- - TSW is to display the field with a background color
- of 7 and a foreground color of 0 while it is editing
- the field.
- - The memory address of "Response" is passed to the
- procedure.
- 3 - The new value of the field is returned in Response and
- assigned to the record field Employe.Name.
-
- Each of the three fields is processed similarly as the user
- presses TAB to move from field to field and S_Enter to end the
- loop.
-
-
-
- Page W-24
-
- ReadWindowLine
- -----------------------------------------------------------------
- Function: Returns a string containing the contents of the
- specified line of the specified window.
-
- Remarks: Use this option to read the contents of any line from
- any window. The target window may be OPEN, HIDDEN, or
- OVERLAPPED by another window.
-
- A NULL string is returned if the specified window is
- not defined or if the specified line is less than 1 or
- greater than the number of lines in the window.
-
- Defined for Turbo C as:
- Function ReadWindowLine(WindowName:S_Str80;
- WindowNo,
- WindowRow:Byte):S_Str80;
-
- Defined for Turbo Pascal as:
- Function ReadWindowLine(WindowName:S_Str80;
- WindowNo,
- WindowRow:Byte):S_Str80;
- Parameter description:
-
- WindowName...........The name of the target window.
-
- WindowNo.............The unique number of the target window
- returned by DefineWindow.
-
- WindowRow............The line of the window that you to be
- read.
-
- Pascal
- -------------------------------------------------------
- => Var Response : S_Str80;
- :
- Y := 1;
- Repeat
- PauseWindowUpdates(True);
- If (S_Up)Or(S_Down) then
- Begin
- => Response := ReadWindowLine('',MenuWindow,Y);
- WriteWindowLine('',MenuWindow,Y,W_Off,0,0,2,Response);
- If S_Up Then If Y > 1 Then Dec(Y) Else Y := 6;
- If S_Down Then If Y < 6 Then Inc(Y) Else Y := 1;
- => Response := ReadWindowLine('',MenuWindow,Y);
- WriteWindowLine('',MenuWindow,y,W_Off,0,7,0,Response);
- End;
- PauseWindowUpdates(False);
- S_NextKey;
- Until S_Esc Or S_Enter;
- :
- -------------------------------------------------------
- In Pascal the field "Response" is defined as type "S_Str80"
- and is used to receive the line of text returned by
- ReadWindowLine. (S_Str80 is defined in Turbo ScrEdit.).
-
- See the description following the C example for further
- discussion of this procedure.
-
-
-
-
-
- Page W-25
-
- C
- ----------------------------------------------------
- => char Response[81];
- :
- Y = 1;
- do{
- PauseWindowUpdates(1);
- if ((S_Up)||(S_Down))
- {
- => strcpy(Response,ReadWindowLine("",MenuWindow,Y));
- WriteWindowLine("",MenuWindow,Y,W_Off,0,0,2,Response);
- if (S_Up) if (Y > 1) Y--; else Y = 6;
- if (S_Down) if (Y < 6) Y++; else Y = 1;
- => strcpy(Response,ReadWindowLine("",MenuWindow,Y));
- WriteWindowLine("",MenuWindow,Y,W_Off,0,7,0,Response);
- }
- PauseWindowUpdates(0);
- S_NextKey();
- }while ((!S_Esc)&&(!S_Enter));
- :
- ----------------------------------------------------
- In C the field "Response" is defined as an eighty element
- array of type char. This field is to be used to receive the
- line of text returned by calling ReadWindowLine.
-
- In this code segment we see that Y is assigned a value of 1
- to point to the first menu option. A do/while or a
- Repeat/Until loop is began that will continue until either
- S_Esc or S_Enter is pressed.
-
- Next the field Response is assigned the string of characters
- read from line Y of MenuWindow.
-
- The field is then written back to the same window using the
- normal text attributes assigned to the window.
-
- Y is then incremented or decremented depending on which of the
- up or down arrow key have been pressed.
-
- The new line of text pointed to by Y is then read into
- Response and re-written to the window with bright background
- and black foreground colors.
-
- This process is continued. The user of the program will see a
- highlighted bar that moves up and down through the menu
- options.
-
-
-
- SaveWindow
- -----------------------------------------------------------------
- Function: Stores the current "active" window's contents.
-
- Remarks: This procedure stores the current window's contents. It
- is useful when you have used your language's screen I/O
- statements like clrscr, writeln, cprintf, etc.
-
- This statement will also store the current row and
- column position of the cursor, allowing the cursor
- position to be restored when the window is made the
- active window again.
-
-
-
- Page W-26
-
- Defined for Turbo C as:
-
- void SaveWindow()
-
-
- Defined for Turbo Pascal as:
-
- Procedure SaveWindow;
-
- Pascal C
- ------------------------------- -------------------------------
- #include <conio.h>
- #include "ScrEdit.h"
- uses Crt,Windows,Scredit; #include "Windows.h"
- . .
- . .
- Procedure Help1(Msg:Integer); void Help1(int Msg);
- Begin {
- OpenWindow('',HelpWind); OpenWindow("",HelpWind);
- ClrScr; clrscr();
- For x := 1 to 10 do for (x=1;x<10;x++)
- WriteLn(HelpMsg[Msg,x]); cprintf
- ("%s",HelpMsg[Msg][x]);
- S_NextKey; S_Nextkey();
- => SaveWindow('',HelpWind); SaveWindow("",HelpWind);
- ShutWindow('',HelpWind); ShutWindow("",HelpWind);
- End; }
- . .
- . .
- -------------------------------- -------------------------------
- In the above code segment a help window is opened. This
- routine uses the languages regular I/O statements to clear the
- screen and write a help message in the window.
-
- The window is displayed until the user responds by pressing a
- key.
-
- When any key is pressed the program then calls "SaveWindow" to
- store the current contents of the window.
-
- The window is then removed from the screen by calling
- "ShutWindow" and the program resumes.
-
-
-
- ShutWindow
- -----------------------------------------------------------------
- Function: Removes a window from the screen and restores the
- screen memory that was overlaid by the window.
-
- Remarks: No action is taken if the window specified is not
- currently displayed on the screen.
-
- Defined for Turbo C as:
-
- void ShutWindow(char *WindowName,int WindowNo)
-
- Defined for Turbo Pascal as:
-
- Procedure ShutWindow(WindowName:S_Str80;WindowNo:Integer);
-
-
-
-
- Page W-27
-
- Parameter description:
- WindowName...........The name of the target window.
-
- WindowNo.............The unique number of the target window
- returned by DefineWindow.
-
-
- Pascal C
- ------------------------------- -------------------------------
- #include <conio.h>
- #include "ScrEdit.h"
- uses Crt,Windows,Scredit; #include "Windows.h"
- . .
- . .
- Procedure Help1(Msg:Integer); void Help1(int Msg);
- Begin {
- OpenWindow('',HelpWind); OpenWindow("",HelpWind);
- ClrScr; clrscr();
- For x := 1 to 10 do for (x=1;x<10;x++)
- WriteLn(HelpMsg[Msg,x]); cprintf
- ("%s",HelpMsg[Msg][x]);
- S_NextKey; S_Nextkey();
- SaveWindow('',HelpWind); SaveWindow("",HelpWind);
- => ShutWindow('',HelpWind); ShutWindow("",HelpWind);
- End; }
- . .
- . .
- -------------------------------- -------------------------------
- In the above code segment a help window is opened. This
- routine uses the languages regular I/O statements to clear the
- screen and write a help message in the window.
-
- The window is displayed until the user responds by pressing a
- key. When any key is pressed the program then calls
- "SaveWindow" to store the current contents of the window.
-
- The window is then removed from the screen by calling
- "ShutWindow" and the program resumes.
-
-
-
-
-
-
- WindowsEnd;
- -----------------------------------------------------------------
- Function : De-allocates all window work areas and returns all
- allocated memory back to the heap.
-
- Remarks : Use this procedure when you are finished with a program
- segment and are ready to return to the main menu of a
- system.
-
- Defined as:
-
- Turbo C:
- void WindowsEnd();
-
- Turbo Pascal:
- Procedure WindowEnd;
-
-
-
-
- Page W-28
-
- WindowsInit
- -----------------------------------------------------------------
- Function : Initializes the window system.
-
- IMPORTANT: You must call this procedure before you use any other
- window procedure. If you do not you will get
- unpredictable results.
-
- Remarks : This procedure allocates memory from the heap for
- screen work areas.
-
- Defined as:
-
- Turbo C:
- void WindowsInit();
-
- Turbo Pascal:
- Procedure WindowInit;
-
- C Examples 1:
- ----------------------------------------------------------
- .
- .
- S_OpenScreenFile("FileName");
- if (!WindowsInit)
- {
- cprintf("%s","Not enough free memory for Window");
- S_CloseScreenFile();
- exit(0);
- }
- .
- .
- ----------------------------------------------------------
-
-
- C Examples 2:
- ----------------------------------------------------------
- .
- .
- S_Init();
- if (!WindowsInit)
- {
- cprintf("%s","Not enough free memory for Window");
- S_CloseScreenFile();
- exit(0);
- }
- .
- .
- -----------------------------------------------------------
- The above examples demonstrate initializing the windows
- environment.
-
- Example 1 demonstrates how to initialize in a program that
- will be using Turbo ScrEdit screens to interact
- with the user of a program.
-
- Example 2 demonstrates how to initialize for a program that
- is only going to use window procedures and is not
- expected to access a screen file or use any of
- Turbo ScrEdit's data entry screens.
-
-
-
-
- Page W-29
-
- WriteWindowField
- -----------------------------------------------------------------
- Function: Displays a string of characters to a user defined field
- in the active window of the screen.
-
- Remarks: Dispal
-
- Defined for Turbo C as:
-
- void WriteWindowField(char *WindowName,
- int WindowNo,
- int WindowRow,
- int WindowCol,
- int DataType,
- int DataLength,
- int DataBgColor,
- int DataFgColor,
- int EmptyBgColor,
- int EmptyFgColor,
- char *CharString)
-
- Defined for Turbo Pascal as:
-
- Procedure WriteWindowField(WindowName:S_Str80;
- WindowNo,
- WindowRow,
- WindowCol,
- DataType,
- DataLength,
- DataBgColor,
- DataFgColor,
- EmptyBgColor,
- EmptyFgColor:Integer;
- Var CharString :S_Str80);
-
-
- Parameter description:
-
- WindowName...........The name of the target window.
-
- WindowNo.............The unique number of the target window
- returned by DefineWindow.
-
- WindowRow............The window line to be written to.
-
- WindowCol............The column (-1) on the row where the
- data entry field is to begin. Remember
- Turbo ScrEdit adds one character to the
- beginning and ending of fields.
-
- DataType.............Specifies how the data is to be
- displayed in the screen field. Works
- the same as fields on Turbo ScrEdit
- screens.
-
- 0 = Integer value.
- 2 - 7 = decimal values with absolute
- decimal portion in string being
- at DataType.
- 8 = alphabetical key and space only.
- 9 = any keyboard character.
-
-
-
- Page W-30
-
- DataLength...........The length of the field.
-
- ** NOTE ** if the length of the field
- will exceed the length of the window
- line, the field length is adjusted to:
-
- (Length of Window Line) - (WindowCol) - 1;
-
- DataBgColor..........The background color attribute for
- displaying a field that has a value
- assigned to CharString.
-
- DataFgColor..........The foreground color attribute for
- displaying a field that has a value
- assigned to CharString.
-
- EmptyBgColor.........The background color attribute for
- displaying a empty or NULL field.
-
- EmptyFgColor.........The foreground color attribute for
- displaying a empty or Null field.
-
- CharString...........Is a pointer to a string variable
- containing the current value to be
- displayed.
-
-
- Pascal
- ----------------------------------------------------------
- Var Response : S_Str80;
- :
- X := EmployeeEditWindow;
- Y := 1;
- Repeat
- Case Y Of
- 1 :Begin
- Response := Employe.Name;
- WriteWindowField('',X,5,33,9,30,0,14,0,14,Response);
- End;
- 2 :Begin
- Response := Employe.Address;
- WriteWindowField('',X,6,33,9,30,0,14,0,14,Response);
- End;
- 3 :Begin
- Response := Employe.City_State_Zip;
- WriteWindowField('',X,7,33,9,30,0,14,0,14,Response);
- End;
- End;
- Inc(Y);
- Until Y > 3;
- :
- ----------------------------------------------------------
- In Pascal the field "Response" is defined as type "S_Str80"
- and is used to pass the field value to be written by
- WriteWindowField. (S_Str80 is defined in Turbo ScrEdit.).
-
- See the description following the C example for further
- discussion of this procedure.
-
-
-
-
-
-
- Page W-31
-
- C
- ----------------------------------------------------------
- char Response[81];
- :
- X = EmployeeEditWindow;
- Y = 0;
- do{
- switch (Y++)
- {
- case 1 :{
- Response[0]=Employe.Name;
- WriteWindowField("",X,5,33,9,30,0,14,0,14,Response);
- break;
- };
- case 2 :{
- Response[0]=Employe.Address;
- WriteWindowField("",X,6,33,9,30,0,14,0,14,Response);
- break;
- };
- case 3 :{
- Response[0]=Employe.City_State_Zip;
- WriteWindowField("",X,7,33,9,30,0,14,0,14,Response);
- break;
- }
- }
- }while (!S_Enter);
- :
- ----------------------------------------------------------
- In C the field "Response" is defined as an eighty element
- array of type char. This field is to be used to pass the field
- value to be written to ReadWindowLine.
-
- In this code segment we see that Y is assigned a value of 1
- to point to the first field of the window. A do/while or a
- Repeat/Until loop is began that will continue until Y is
- greater than three.
-
- Inside the loop when the value of Y determines which record
- field is to be written to which line of the window. When Y has
- a value of 1:
-
- 1 - Response is assigned the value of the record field
- Employee.Name.
- 2 - The contents of Response is then written to Window
- number referenced by X.
- - Then value is written to Row 5 and column 33 of the
- window.
- - The field to be written is data type 9 or any ascii
- character.
- - The field is 30 characters long.
- - If the field has a value greater than null string it
- is to be displayed in 0 background and 14 foreground
- colors.
- - If the field has a value of NULL string, a blank field
- is to be displayed with 0 background and 14 foreground
- colors.
- - The field Response contains the value to be written in
- the screen location.
-
- Each field in the window is handled in a similar manner.
-
-
-
-
- Page W-32
-
- WriteWindowLine
- -----------------------------------------------------------------
- Function : Displays a string of text on the specified line of the
- specified window.
-
- Remarks : Use this option to write text to any line in any
- window. The target window can be hidden (not displayed
- on the screen) or overlapped by another window.
-
- Defined for Turbo C as:
- enum WScrollType (W_Off=0,W_Up=1,W_Down=2);
- void WriteWindowLine(char *WindowName,
- int WindowNo,
- int WindowRow,
- int WindowScroll,
- int MaxLines
- int OverRideBg,
- int OverRideFg,
- char *CharString)
-
- Defined for Turbo Pascal as:
- Type WScrollType = (W_Off,W_Up,W_Down);
- Procedure WriteWindowLine(WindowName:S_Str80;
- WindowNo,
- WindowRow :Byte;
- WindowScroll:WScrollType;
- MaxLines,
- OverRideBg,
- OverRideFg :Byte;
- CharString :S_Str80);
- Parameter description:
-
- WindowName...........The name of the target window.
-
- WindowNo.............The unique number of the target window
- returned by DefineWindow.
-
- WindowRow............The window line to be written to.
-
- WindowScroll.........This field will accept three possible
- values. You can used the enumerated
- types of:
- W_Off or 0 = No Scrolling. The window
- line is overlaid with
- the new value.
- W_Up or 1 = Scroll the specified
- lines up before writing
- the new value to the
- line.
- W_Down or 3 = Scroll the specified
- lines down before
- writing the new value to
- the line.
-
- MaxLines.............Specifies the maximum number of lines
- in the window that are to be scrolled
- when WindowScroll is set to W_Up or
- W_Down.
-
-
-
-
-
-
- Page W-33
-
- A value of 0 implies all the lines
- above or below the line to be written
- are to be scrolled.
-
- If MaxLines is assigned a value that
- would exceed the number of lines that
- can be scrolled, then all possible
- lines are scrolled.
-
- OverRideBg...........Overrides the normal text background
- color specified when the window was
- defined. A value of zero will not over-
- ride TextBg.
-
- OverRideFg...........Overrides the normal text foreground
- color specified when the window was
- defined. A value of zero will not over-
- ride TextFg.
-
- CharString...........Is the string of characters to be
- written to the window line.
-
- If the string length exceeds the line
- length, it is truncated.
-
- If the string length is less than the
- line length the line is padded with
- spaces.
-
- Pascal
- -------------------------------------------------------
- => Var Response : S_Str80;
- :
- Y := 1;
- Repeat
- PauseWindowUpdates(True);
- If (S_Up)Or(S_Down) then
- Begin
- Response := ReadWindowLine('',MenuWindow,Y);
- => WriteWindowLine('',MenuWindow,Y,W_Off,0,0,2,Response);
- If S_Up Then If Y > 1 Then Dec(Y) Else Y := 6;
- If S_Down Then If Y < 6 Then Inc(Y) Else Y := 1;
- Response := ReadWindowLine('',MenuWindow,Y);
- => WriteWindowLine('',MenuWindow,y,W_Off,0,7,0,Response);
- End;
- PauseWindowUpdates(False);
- S_NextKey;
- Until S_Esc Or S_Enter;
- :
- -------------------------------------------------------
- In Pascal the field "Response" is defined as type "S_Str80"
- and is used to receive the line of text returned by
- ReadWindowLine which is then passed to WriteWindowLine.
- (S_Str80 is defined in Turbo ScrEdit.).
-
- See the description following the C example for further
- discussion of this procedure.
-
-
-
-
-
-
-
- Page W-34
-
- C
- ----------------------------------------------------
- => char Response[81];
- :
- Y = 1;
- do{
- PauseWindowUpdates(1);
- if ((S_Up)||(S_Down))
- {
- strcpy(Response,ReadWindowLine("",MenuWindow,Y));
- => WriteWindowLine("",MenuWindow,Y,W_Off,0,0,2,Response);
- if (S_Up) if (Y > 1) Y--; else Y = 6;
- if (S_Down) if (Y < 6) Y++; else Y = 1;
- strcpy(Response,ReadWindowLine("",MenuWindow,Y));
- => WriteWindowLine("",MenuWindow,Y,W_Off,0,7,0,Response);
- }
- PauseWindowUpdates(0);
- S_NextKey();
- }while ((!S_Esc)&&(!S_Enter));
- :
- ----------------------------------------------------
- In C the field "Response" is defined as an eighty element
- array of type char. This field is to be used to receive the
- line of text returned by calling ReadWindowLine that is in
- turn passed to WriteWindowLine.
-
- In this code segment we see that Y is assigned a value of 1
- to point to the first menu option. A do/while or a
- Repeat/Until loop is began that will continue until either
- S_Esc or S_Enter is pressed.
-
- Next the field Response is assigned the string of characters
- read from line Y of MenuWindow.
-
- The field is then written back to the same window using the
- normal text attributes assigned to the window.
-
- Y is then incremented or decremented depending on which of the
- up or down arrow key have been pressed.
-
- The new line of text pointed to by Y is then read into
- Response and re-written to the window with bright background
- and black foreground colors.
-
- This process is continued. The user of the program will see a
- highlighted bar that moves up and down through the menu
- options as the PgUp and PgDn.
-
-
-
-
-
-
-
-