home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / windows / c / textview / docs / textview.prn < prev    next >
Encoding:
Text File  |  1991-06-16  |  149.0 KB  |  2,752 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.                                        The                                       The                                       The
  18.                                      TextView                                     TextView                                     TextView
  19.                                        DLL                                       DLL                                       DLL
  20.  
  21.  
  22.                                    Version 1.00                                   Version 1.00                                   Version 1.00
  23.  
  24.  
  25.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  26.  
  27.  
  28.        I       I       INTRODUCTION TO         NTRODUCTION TO         NTRODUCTION TO T                       T                       TEXT                        EXT                        EXTV                           V                           VIEW                            IEW                            IEW
  29.  
  30.  
  31.        Thank you for using the  TextView                                TextView                                TextView system. The author  hopes that it
  32.        will prove to be a powerful and useful tool to Windows applications
  33.        writers, providing  a facility  that is  both useful  in  the final
  34.        application, and helpful in the development phase.
  35.  
  36.        This manual covers all aspects  of the system. It  assumes that you
  37.        are  an   experienced  Windows   application  developer,   and  are
  38.        conversant with the use of the Windows API.
  39.  
  40.        The author is always interested  to hear any reports  about how you
  41.        find TextView,  what  further  facilities  you  would  like  it  to
  42.        include, and  any  problems you  may  find when  using  it. Contact
  43.        addresses are given later in this manual.
  44.  
  45.  
  46.           What is TextView?          What is TextView?          What is TextView?
  47.  
  48.           TextView          TextView          TextView is a system that provides  a Windows 3 application with
  49.           the ability to write lines of text to  a window with the minimum
  50.           of effort.   TextView                       TextView                       TextView itself  handles  all  the  many  operations
  51.           needed to manage the  window displaying the text;  you need only
  52.           call the function that writes the text,  in exactly the same way
  53.           as you would call printf                            printf                            printf in a DOS application.
  54.  
  55.           You can create as many  TextView                                  TextView                                  TextView windows as you require, and  all
  56.           will operate independently.  TextView                                       TextView                                       TextView windows can  be resized by
  57.           the user,  minimized,  maximized and  scrolled  horizontally and
  58.           vertically with no work needed by the application. They can also
  59.           have  File menus  that  notify  the  application  when the  user
  60.           requests that the window contents be written to disk.
  61.  
  62.           TextView          TextView          TextView windows can, of course, be used for an infinite variety
  63.           of purposes. One possibility is to use TextView                                                 TextView                                                 TextView to provide a way
  64.           of outputting tracing and debugging  information when developing
  65.           an application. Included with  the system are the  sources for a
  66.           demonstration application that contain a flexible tracing system
  67.           that may be incorporated into your own code.
  68.  
  69.           TextView          TextView          TextView is supplied as a  Dynamic Link Library  or DLL. In this
  70.           form it is not added to the application's code at link time, but
  71.           instead is  bound  to  it  dynamically  by Windows  whenever  an
  72.           application needing it  is run. All  applications using  TextView                                                                   TextView                                                                   TextView
  73.           will share the same  code segments, making it  very efficient in
  74.           memory utilisation.
  75.  
  76.  
  77.           What you need to use TextView          What you need to use TextView          What you need to use TextView
  78.  
  79.           In order  to  use  TextView                             TextView                             TextView you  will  need to  have  a  suitable
  80.           compiler that can generate  Windows 3 code, such  as Microsoft C
  81.           6.0. The TextView                   TextView                   TextView functions follow the same conventions  as used
  82.           in the Windows API,  and their descriptions later  in this guide
  83.           use the  same layout  as in  the Microsoft  Windows Programmer's
  84.           Reference.
  85.  
  86.  
  87.                                       Page                                       Page                                       Page 1                                           1                                           1
  88.  
  89.  
  90.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  91.  
  92.  
  93.           Distribution and Use of TextView          Distribution and Use of TextView          Distribution and Use of TextView
  94.  
  95.           TextView          TextView          TextView is Copyright (c)  Alan Phillips 1991. It  may be freely
  96.           distributed by anyone,  to anyone.  Apart from  reasonable media
  97.           and  handling   costs,  no   charge  may   be  levied   for  its
  98.           distribution. It  may be  stored on  Bulletin Board  systems and
  99.           other archives so long as all  the files comprising the original
  100.           distribution are  included. It  may  be repackaged  to  suit the
  101.           storage conventions in use for the  system concerned. It may not
  102.           be distributed as part of commercial  disk libraries without the
  103.           prior agreement of the author.
  104.  
  105.           TextView          TextView          TextView may  be  freely  used  in  any  non-commercial  Windows
  106.           application.  Authors  of  such  applications  may  include  the
  107.           TextView          TextView          TextView DLL with the products either  with or without the other
  108.           files  comprising  the  full  distribution  set.  However,  such
  109.           application should  include  in their  documentation  (or should
  110.           display in their About dialog box or in their  online help) that
  111.           they are using TextView                         TextView                         TextView, and should list the author's copyright.
  112.  
  113.           The demonstration sources  supplied with  TextView                                                    TextView                                                    TextView may be  freely
  114.           adapted and included in other applications as required.
  115.  
  116.           Authors of ShareWare or commercial products may not use  TextView                                                                   TextView                                                                   TextView
  117.           without the author's written permission.
  118.  
  119.  
  120.           Disclaimer          Disclaimer          Disclaimer
  121.  
  122.           TextView          TextView          TextView is  distributed  on an  as is  basis.  No  guarantee is
  123.           offered,  and   none  should   be  inferred,   of   its  correct
  124.           functionality, nor of  its suitability for  any task whatsoever.
  125.           The  author  accepts  no  liability  for   any  loss  or  damage
  126.           whatsoever caused  as  a  result  of  using   TextView                                                        TextView                                                        TextView  with  any
  127.           application, whether written by the user or a third party.
  128.  
  129.           TextView          TextView          TextView is  written  as  a  private  activity  by  the  author,
  130.           unconnected in any way with his  employment at the University of
  131.           Lancaster.
  132.  
  133.  
  134.           Contacting the Author          Contacting the Author          Contacting the Author
  135.  
  136.           The author may be  contacted c/o  The Computer Centre,  Lancaster                                            The Computer Centre,  Lancaster                                            The Computer Centre,  Lancaster
  137.           University, Lancaster LA1  4YW, United Kingdom          University, Lancaster LA1  4YW, United Kingdom          University, Lancaster LA1  4YW, United Kingdom . Electronic mail
  138.           may be addressed to one of the following addresses:
  139.  
  140.                  alan@uk.ac.lancaster                 alan@uk.ac.lancaster                 alan@uk.ac.lancaster     JANET network                                          JANET network                                          JANET network
  141.                  alan@lancaster.ac.uk                 alan@lancaster.ac.uk                 alan@lancaster.ac.uk     Internet or BITNET                                          Internet or BITNET                                          Internet or BITNET
  142.                  alan%uk.ac.lancaster@ukc                 alan%uk.ac.lancaster@ukc                 alan%uk.ac.lancaster@ukc UUCP network                                          UUCP network                                          UUCP network
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.                                       Page                                       Page                                       Page 2                                           2                                           2
  153.  
  154.  
  155.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  156.  
  157.  
  158.        I       I       INSTALLING         NSTALLING         NSTALLING T                  T                  TEXT                   EXT                   EXTV                      V                      VIEW                       IEW                       IEW
  159.  
  160.  
  161.        There are three components to the  TextView                                          TextView                                          TextView system. The DLL itself,
  162.        textview.dll       textview.dll       textview.dll, should  be  copied  to  your  Windows directory.  The
  163.        model-independent import library  textview.lib                                         textview.lib                                         textview.lib should be  copied to
  164.        one of the directories named in your LIB                                            LIB                                            LIB environment variable - the
  165.        directory containing your Windows SDK libraries  or your C compiler
  166.        libraries would normally  be suitable.  The header  file  textview.h                                                                 textview.h                                                                 textview.h
  167.        should be copied  to one of  the directories named  in your  INCLUDE                                                                    INCLUDE                                                                    INCLUDE
  168.        environment variable  -  the  directory  containing your   windows.h                                                                  windows.h                                                                  windows.h
  169.        header file would be suitable.
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.                                       Page                                       Page                                       Page 3                                           3                                           3
  218.  
  219.  
  220.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  221.  
  222.  
  223.        U       U       USING         SING         SING T             T             TEXT              EXT              EXTV                 V                 VIEW                  IEW                  IEW
  224.  
  225.  
  226.        The TextView           TextView           TextView DLL extends the Windows API with  a number of specific
  227.        functions, which you call from your  application. All the functions
  228.        have names  beginning  with   TV                                     TV                                     TV,  to  avoid  clashes  with  Windows
  229.        functions, those in your application or in other DLLs.
  230.  
  231.        All the functions  use the Pascal  calling convention, and  must be
  232.        declared FAR                FAR                FAR. Full function prototypes are contained in the include
  233.        file textview.h            textview.h            textview.h; including this  in your source  will automatically
  234.        select the right calling mode, and  will also perform any necessary
  235.        casts to far pointers.
  236.  
  237.        You must take two additional steps when building your application:
  238.  
  239.             - Include the TextView                          TextView                          TextView import library textview.lib                                                  textview.lib                                                  textview.lib in the list
  240.               of libraries that you name for the linker to scan.
  241.  
  242.             - Make  sure  you  declare  sufficient   stack  size  in  your
  243.               application's .DEF                            .DEF                            .DEF file. As  a rough  guide, try  increasing
  244.               the size by 2Kbytes over what your application itself uses.
  245.  
  246.        You  must  not  use  the  Windows   LoadLibrary                                           LoadLibrary                                           LoadLibrary  and  GetProcAddress                                                             GetProcAddress                                                             GetProcAddress
  247.        functions to link  TextView routines  at run-time. This  is because
  248.        some of the  functions are actually  within the import  library and
  249.        must be statically-linked.
  250.  
  251.        The  sections  below   describe  how   to  use   TextView                                                        TextView                                                        TextView  in  your
  252.        application. The text assumes that you're familiar with the Windows
  253.        API and with how to program  Windows applications: there is general
  254.        information  on  this  in  the  documentation   supplied  with  the
  255.        Microsoft Windows Software  Developer's Kit,  and in  several other
  256.        published books.
  257.  
  258.        Besides this manual, there is a  comprehensively-commented set of C
  259.        source routines supplied  in the  distribution set. These  show you
  260.        how you can use  TextView                        TextView                        TextView to add a  dynamic tracing utility to  your
  261.        application, which provides  you with  a very  powerful development
  262.        aid that enables you to  keep a log of  your application's activity
  263.        that can be scrolled back and consulted when necessary.
  264.  
  265.  
  266.           A Summary of TextView Usage          A Summary of TextView Usage          A Summary of TextView Usage
  267.  
  268.           Although  it  offers   your  application   powerful  facilities,
  269.           TextView          TextView          TextView's API is very straightforward, and  has been written to
  270.           parallel closely  the way  you use  the Windows  API.  The basic
  271.           concepts of how the system works are these:
  272.  
  273.  
  274.              The TextView Window             The TextView Window             The TextView Window
  275.  
  276.              A window created by TextView                                 TextView                                 TextView is an ordinary  overlapped window
  277.              that belongs to  your application. Within  certain limits you
  278.              have full control over the appearance  of the window: you can
  279.              allow the user to resize  it or not, supply  it with maximize
  280.              and minimize boxes, and so on.
  281.  
  282.                                       Page                                       Page                                       Page 4                                           4                                           4
  283.  
  284.  
  285.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  286.  
  287.  
  288.              Creation of a TextView                           TextView                           TextView window is done with the  TVCreateWindow                                                             TVCreateWindow                                                             TVCreateWindow
  289.              function, which  looks  similar to  the  Windows  CreateWindow                                                               CreateWindow                                                               CreateWindow
  290.              function. The major difference is that  for a TextView                                                           TextView                                                           TextView window
  291.              the message loop  is handled within  the DLL and  not by your
  292.              application, so that you do not need to concern yourself with
  293.              managing the window. TextView                                  TextView                                  TextView will look after aspects such as
  294.              text scrolling on your behalf.
  295.  
  296.              Although your application  does not supply  the message loop,
  297.              it can  still  interact  fully  with  the window.  A  set  of
  298.              functions allow you to test  what state the window  in and to
  299.              change that  state, and  to  destroy the  window  when you've
  300.              finished with it.
  301.  
  302.              If you  choose,  you  can  specify  that  a   TextView                                                           TextView                                                           TextView  window
  303.              displays a  File menu with  Save, Save As and  Print options.
  304.              You do not see clicks on these menu items directly, since you
  305.              do not  supply  the message  loop,  but you  can  arrange for
  306.              TextView             TextView             TextView to call back  into a routine in  your application to
  307.              notify you when menu items are selected.
  308.  
  309.  
  310.              How Text is Stored             How Text is Stored             How Text is Stored
  311.  
  312.              TextView             TextView             TextView maintains  the lines  written  to each  window  in a
  313.              cyclic buffer  held  in an  area  of memory  private  to that
  314.              window. Each window operates independently of the others, and
  315.              the only practical limit  to the total amount  of data stored
  316.              will be how much memory your system has available.
  317.  
  318.              When you  create  a  window  by  calling   TVCreateWindow                                                        TVCreateWindow                                                        TVCreateWindow  you
  319.              specify the  maximum number  of  lines that  each  window can
  320.              store, up  to  a limit  of  4096 lines.  Specifying  a larger
  321.              number requires TextView                             TextView                             TextView to allocate more control  memory for
  322.              the window, so you should not  request a larger capacity that
  323.              you need.
  324.  
  325.              Whenever a line is written, TextView                                         TextView                                         TextView stores the contents in
  326.              dynamically-allocated memory. When the window contains the
  327.              specified maximum number of lines, the next to be written
  328.              will replace the oldest line, and so on. A line can be up to
  329.              512 characters long.
  330.  
  331.  
  332.              Scrolling             Scrolling             Scrolling
  333.  
  334.              When you create  a  TextView                                 TextView                                 TextView window  it will  be in  automatic
  335.              scrolling state.  In this  state  TextView                                               TextView                                               TextView will  automatically
  336.              move existing lines of text up  to make room as  new ones are
  337.              written, without your application needing to be aware of what
  338.              is happening. Old  lines, of  course, will disappear  off the
  339.              top of  the window,  but they  will remain  stored  in memory
  340.              until the  window  reaches  its  set  capacity and  they  are
  341.              overwritten with new lines of text.
  342.  
  343.              If the  user wishes  to look  at older  messages that  are no
  344.              longer visible  in the  window, he  can put  the  window into
  345.              manual scrolling  state.  TextView                                       TextView                                       TextView will  draw  horizontal and
  346.  
  347.                                       Page                                       Page                                       Page 5                                           5                                           5
  348.  
  349.  
  350.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  351.  
  352.  
  353.              vertical scroll bars on the window  (you may select either or
  354.              both) and the user may  use them to scroll  around the stored
  355.              text. You can specify when  you create the window  that it is
  356.              to have a Scrolling menu to enable the user  to select manual
  357.              scrolling mode, or you may choose  to control the window from
  358.              your own application using the TVSetScrollMode                                            TVSetScrollMode                                            TVSetScrollMode function.
  359.  
  360.              When the  window is  in manual  scroll mode  it is  unable to
  361.              display any text  written to it.  However, it will  count the
  362.              number of messages  lost should  this occur,  and will  add a
  363.              line itself to  the window to  warn the user  when the window
  364.              returns to automatic scroll mode.
  365.  
  366.  
  367.           Registering a TextView Window Class          Registering a TextView Window Class          Registering a TextView Window Class
  368.  
  369.           As  with  the  Windows  CreateWindow                                  CreateWindow                                  CreateWindow  function,  you  must  have
  370.           registered a  suitable  window class  before  you  can create  a
  371.           TextView          TextView          TextView window using  TVCreateWindow                                 TVCreateWindow                                 TVCreateWindow. Since most of the  details
  372.           of the window class have to be  supplied by TextView                                                      TextView                                                      TextView itself, you
  373.           must call a  TextView                       TextView                       TextView function  TVRegisterClass                                          TVRegisterClass                                          TVRegisterClass to do  this, and
  374.           must not use the ordinary Windows technique.
  375.  
  376.           When you call  TVRegisterClass                         TVRegisterClass                         TVRegisterClass you specify  four arguments:  for
  377.           example
  378.  
  379.                TVRegisterClass(hInstance,"TV_WINCLASS",               TVRegisterClass(hInstance,"TV_WINCLASS",               TVRegisterClass(hInstance,"TV_WINCLASS",
  380.                               LoadIcon(hInstance,"TV_WINICON"),                              LoadIcon(hInstance,"TV_WINICON"),                              LoadIcon(hInstance,"TV_WINICON"),
  381.                               GetStockObject(WHITE_BRUSH));                              GetStockObject(WHITE_BRUSH));                              GetStockObject(WHITE_BRUSH));
  382.  
  383.           will  register   a  class   using  an   icon  defined   in  your
  384.           application's resource area, and will use a white background for
  385.           the window.
  386.  
  387.           The function  will  return  FALSE                                      FALSE                                      FALSE if  it  fails to  register  the
  388.           window class, or if you pass incorrect arguments.
  389.  
  390.  
  391.           Creating a TextView Window          Creating a TextView Window          Creating a TextView Window
  392.  
  393.           Creating a Window with  TextView                                  TextView                                  TextView is closely analogous to how  you
  394.           use Windows' own  CreateWindow                            CreateWindow                            CreateWindow function. The routine you call  is
  395.           TVCreateWindow          TVCreateWindow          TVCreateWindow, and many of  the arguments you need  to pass are
  396.           have exact CreateWindow                     CreateWindow                     CreateWindow equivalents.
  397.  
  398.           The  lpClassName,  lpWindowTitle,  X,  Y,  nWidth,   nHeight  and
  399.           hInstance arguments are used in the same way as the  CreateWindow                                                               CreateWindow                                                               CreateWindow
  400.           arguments of  the same  name. The  one restriction  is  that the
  401.           window  class  you  specify  with  lpClassName  must  have  been
  402.           registered with the TVRegisterClass                              TVRegisterClass                              TVRegisterClass function.
  403.  
  404.           The remaining  arguments are  specific to  TextView and  have no
  405.           CreateWindow          CreateWindow          CreateWindow equivalents.
  406.  
  407.           hFont specifies a handle to the font  that you want text written
  408.           in the window to appear in. If you specify the argument as  NULL                                                                      NULL                                                                      NULL,
  409.           TextView          TextView          TextView will use  the system font;  otherwise, you can  use any
  410.           font created with the CreateFont                                CreateFont                                CreateFont function.
  411.  
  412.                                       Page                                       Page                                       Page 6                                           6                                           6
  413.  
  414.  
  415.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  416.  
  417.  
  418.           The  dWflags argument  specifies a  series of  bit settings  that
  419.           describe the appearance  you want the  window to take,  and what
  420.           facilities it provides. These are described in detail below.
  421.  
  422.           The nTabSize value specifies how you want tabs to be expanded in
  423.           lines written to the window. You  give the value as  a number of
  424.           characters; TextView multiplies this by the width of the average
  425.           character in the selected font to  calculate the actual spacing.
  426.           If you give a value of zero, tabs will be expanded to a width of
  427.           8 characters.
  428.  
  429.           The  nMaxLines argument  tells TextView  how many  lines of  text
  430.           should be stored with the window (note that this is not the size
  431.           of the actual  window, but the  size of its  data storage area).
  432.           You can set this value to be from 128 to 4096. If you write more
  433.           lines than  this  to  the  window,  the  oldest  lines  will  be
  434.           progressively overwritten.
  435.  
  436.           The lpMenuHandler argument is the procedure  instance address of
  437.           a  function  within   your  application   that  is   to  receive
  438.           notification  of  things  happening  in  the   window.  This  is
  439.           discussed in more detail below in  the section on  Receiving Menu
  440.           Notifications. The  value you  pass as  this argument  must have
  441.           been obtained by using the  MakeProcInstance                                      MakeProcInstance                                      MakeProcInstance function. Depending
  442.           on the values  you have specifies  in the  dwFlags argument, you
  443.           may be allowed to give a NULL                                   NULL                                   NULL value.
  444.  
  445.           The return value from  TVCreateWindow                                 TVCreateWindow                                 TVCreateWindow is a normal window  handle,
  446.           which you use  in other  TextView                                   TextView                                   TextView functions.  You can  also pass
  447.           this handle  to  Windows  functions  to  manipulate the  window;
  448.           however you  should  avoid calling  DestroyWindow                                              DestroyWindow                                              DestroyWindow to  close  it.
  449.           Instead, use the  TextView                            TextView                            TextView equivalent  TVDestroyWindow                                                 TVDestroyWindow                                                 TVDestroyWindow, which is
  450.           guaranteed to work in future releases.
  451.  
  452.  
  453.              The dwFlags Argument             The dwFlags Argument             The dwFlags Argument
  454.  
  455.              This argument  is a  collection  of bit  settings  that tells
  456.              TextView             TextView             TextView details of  how you want  the window to  appear, and
  457.              what facilities it should support.
  458.  
  459.              The  TVS_MAXIMIZE                  TVS_MAXIMIZE                  TVS_MAXIMIZE,   TVS_MINIMIZE                                  TVS_MINIMIZE                                  TVS_MINIMIZE  and  TVS_SYSMENU                                                     TVS_SYSMENU                                                     TVS_SYSMENU  settings
  460.              correspond directly to  dwStyle settings in CreateWindow                                                         CreateWindow                                                         CreateWindow, and
  461.              control whether  the window  has a  maximize box,  a minimize
  462.              box, and a system menu.
  463.  
  464.              The  TVS_NOCLOSE                  TVS_NOCLOSE                  TVS_NOCLOSE setting  can be  used  to disable  the  close
  465.              option  in  the  system  menu;  if   you  select  this,  your
  466.              application must destroy the window, as the user will have no
  467.              way to  do so.  If  you specify  a  system menu,  and  do  not
  468.              disable the close option, you must supply a procedure address
  469.              with the  lpMenuHandler argument so  that TextView                                                       TextView                                                       TextView can notify
  470.              your application when the user closes the window.
  471.  
  472.              The  TVS_NORESIZE                  TVS_NORESIZE                  TVS_NORESIZE setting  allows  you to  create  the  window
  473.              without a thick "resizing"  frame. The user will  not be able
  474.              to alter the size of  the window other than  by minimizing or
  475.              maximizing it.
  476.  
  477.                                       Page                                       Page                                       Page 7                                           7                                           7
  478.  
  479.  
  480.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  481.  
  482.  
  483.              TVS_HSCROLL             TVS_HSCROLL             TVS_HSCROLL and TVS_VSCROLL                             TVS_VSCROLL                             TVS_VSCROLL specify whether the window  is to
  484.              show horizontal and vertical scroll bars  if the user or your
  485.              application puts  it into  manual scroll  mode. If  you don't
  486.              include either of the settings, manual  scroll mode cannot be
  487.              selected, and the user will be unable  to scroll back to look
  488.              at text no longer in the window.
  489.  
  490.              TVS_TIMESTAMP             TVS_TIMESTAMP             TVS_TIMESTAMP controls whether TextView is  to timestamp text
  491.              written to the window. If  you specify it, all  lines will be
  492.              prefixed with the current  Windows time (that  is, the number
  493.              of milliseconds  since  Windows  started,  obtained from  the
  494.              GetCurrentTime             GetCurrentTime             GetCurrentTime function). Timestamping messages can be useful
  495.              if you are  using TextView  to trace the  path taken  by your
  496.              application in response to external events.
  497.  
  498.              The other settings all control what  menu items should appear
  499.              in the window's menu bar.  TVS_SCROLLMENU                                        TVS_SCROLLMENU                                        TVS_SCROLLMENU selects a  Scrolling
  500.              menu item, which will let the  user switch between manual and
  501.              automatic scroll  modes. You  can  use this  setting  only if
  502.              you've  also  given   either  or  both   of  TVS_HSCROLL                                                          TVS_HSCROLL                                                          TVS_HSCROLL  and
  503.              TVS_VSCROLL             TVS_VSCROLL             TVS_VSCROLL. If  you  specify a  procedure  address with  the
  504.              lpMenuHandler argument,  your  application  will be  notified
  505.              when the user clicks these menu items.
  506.  
  507.              TVS_FILESAVE             TVS_FILESAVE             TVS_FILESAVE, TVS_FILESAVEAS                           TVS_FILESAVEAS                           TVS_FILESAVEAS  and  TVS_FILEPRINT                                                TVS_FILEPRINT                                                TVS_FILEPRINT specify  that
  508.              the window is to have a File menu, which should include  Save,
  509.              Save As  and  Print options  respectively.   You can  use  the
  510.              three  settings  independently.  If  you  use  any  of  these
  511.              settings  you  must  specify  a  procedure  address   in  the
  512.              lpMenuHandler argument to receive notification when the items
  513.              are clicked.
  514.  
  515.  
  516.           Writing Text to a TextView Window          Writing Text to a TextView Window          Writing Text to a TextView Window
  517.  
  518.           Once a TextView                 TextView                 TextView window is created, writing text  to it is simply
  519.           done with the TVOutputText                        TVOutputText                        TVOutputText function. This takes three arguments:
  520.  
  521.                hWnd        This is the handle to the TextView                                                     TextView                                                     TextView window.
  522.  
  523.                lpBuffer    This is a  long pointer to  a buffer containing
  524.                            the line you wish to write.
  525.  
  526.                nSize       This is the number of characters in the buffer.
  527.                            If you  set  this value  to  zero,  TVOutputText                                                               TVOutputText                                                               TVOutputText
  528.                            will  assume  the  text  is  a  zero-terminated
  529.                            string and will write it out completely.
  530.  
  531.           You can write up to 512 bytes in a line,  less the length of the
  532.           timestamp details if  you used  the TVS_TIMESTAMP                                              TVS_TIMESTAMP                                              TVS_TIMESTAMP option in  the
  533.           dwFlags argument to  TVCreateWindow                               TVCreateWindow                               TVCreateWindow. If you supply a longer  line
  534.           than that, TextView                     TextView                     TextView will truncate it.
  535.  
  536.           What happens to  the text  depends on the  current state  of the
  537.           TextView          TextView          TextView window  you are  writing it  to.  If the  window  is in
  538.           automatic scroll mode, it will be displayed in the window, which
  539.           will be scrolled up  by one line  if necessary to  make room for
  540.           it. The text will be  written in the colour  last specified with
  541.  
  542.                                       Page                                       Page                                       Page 8                                           8                                           8
  543.  
  544.  
  545.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  546.  
  547.  
  548.           the  TVSetTextColor               TVSetTextColor               TVSetTextColor function  (or in  black, if  you haven't  set
  549.           another colour).
  550.  
  551.           If the  window  is  in  manual scroll  mode, the  text  will  be
  552.           discarded. TextView                     TextView                     TextView will record  the fact that  a line has  been
  553.           lost, and when the user (or your application) returns the window
  554.           to automatic  scroll  mode will  add  a line  itself  noting the
  555.           number of  lines that  have ben  lost.  If the  window  has been
  556.           suspended with a call  to TVSuspendWindow                                    TVSuspendWindow                                    TVSuspendWindow, or you  are currently
  557.           calling the  TVReturnData                       TVReturnData                       TVReturnData function to read  back the data  stored
  558.           in the window,  the text will  also be discarded.  Here, though,
  559.           TextView          TextView          TextView will not record the fact.
  560.  
  561.           If you choose,  you can  determine the status  of the  window by
  562.           calling the   TVGetWindowStatus                        TVGetWindowStatus                        TVGetWindowStatus function,  and  so  avoid  making
  563.           calls to TVOutputText                   TVOutputText                   TVOutputText at inappropriate moments.
  564.  
  565.  
  566.           Receiving Menu Notifications          Receiving Menu Notifications          Receiving Menu Notifications
  567.  
  568.           A  TextView             TextView             TextView window  is  an  independent  entity,  all  of  whose
  569.           functions are controlled  within the  TextView                                                TextView                                                TextView DLL  itself. Your
  570.           application does not  provide the  message loop for  the window,
  571.           and is normally unaware of what the user is doing to the window:
  572.           TextView          TextView          TextView handles  window resizing,  scrolling, iconizing  and so
  573.           on.
  574.  
  575.           However, you may wish to make your application aware of what the
  576.           window is doing for one of two reasons. Firstly, you may wish to
  577.           allow the user to control the window from either its own menu or
  578.           from the application's menu - for example, you  might include in
  579.           your application's menu the  ability for the user  to switch the
  580.           TextView          TextView          TextView window between manual and automatic scrolling. In order
  581.           to keep the application's menu state in line with the window, it
  582.           will be necessary  for the  application to be  informed whenever
  583.           the  state  is  changed   using  the  window's   own  menu.  The
  584.           application will probably also wish to be informed when the user
  585.           closes the window with the  Close option in its  System menu, so
  586.           that it can keep track of which windows are still active.
  587.  
  588.           The second reason is that some services  must be provided by the
  589.           application. TextView  allows  you to  specify  that the  window
  590.           should possess a File menu with options such as  Save and  Print,
  591.           but it  does  not itself  handle  these  functions. Instead,  it
  592.           notifies the  application  when  one  of  these  menu  items  is
  593.           clicked, so that it may then perform the required operations.
  594.  
  595.           All these examples of  menu notifications are done  via the  menu
  596.           handler routine  specified  when  you  create  the  window  with
  597.           TVCreateWindow          TVCreateWindow          TVCreateWindow. Whenever the user clicks a  menu item (including
  598.           the Close option in the  System menu) the TextView                                                    TextView                                                    TextView DLL will call
  599.           this routine, passing it the handle of the window concerned, and
  600.           a code indicating the menu item.
  601.  
  602.           Your code can then take  what action it wishes.  For example, if
  603.           the user clicked on File Save As , you might run a dialog  to ask
  604.           the user  for a  file  name, open  it,  and then  copy  the data
  605.  
  606.  
  607.                                       Page                                       Page                                       Page 9                                           9                                           9
  608.  
  609.  
  610.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  611.  
  612.  
  613.           currently in the window to the file using the  TVSaveWindowToFile                                                         TVSaveWindowToFile                                                         TVSaveWindowToFile
  614.           function.
  615.  
  616.           The example sources  contained in  the distribution  set contain
  617.           examples of how  you use menu  notification. The code  keeps the
  618.           main window's menu in line with the current state of the window,
  619.           graying some items when the window is destroyed and checking the
  620.           relevant scroll state selections.
  621.  
  622.  
  623.           Saving Data in a Window to File          Saving Data in a Window to File          Saving Data in a Window to File
  624.  
  625.           TextView          TextView          TextView allows you to save the  contents of a window  to a file
  626.           on disk at  any time. There  are two techniques  for doing this,
  627.           depending on  how  much processing  of  the data  you  wish your
  628.           application to do before it is written.
  629.  
  630.           If you application created the window  and specified a  File menu
  631.           with File Save or File Save As options, it will be notified when
  632.           they are clicked,  as described above,  but you can,  of course,
  633.           initiate a  file  save at  any  time and  not  solely when  this
  634.           occurs.
  635.  
  636.           The first  technique  for  saving  the  data  is  the  simplest.
  637.           TextView          TextView          TextView provides a function TVSaveWindowToFile                                       TVSaveWindowToFile                                       TVSaveWindowToFile which will write
  638.           a range of lines to a file exactly as they as stored, and if you
  639.           don't need to process the data yourself this will be the easiest
  640.           option. Your application will need to  determine the name of the
  641.           file to be written, probably by giving the  user a dialog box to
  642.           choose it,  and open  the file  for  writing; then  it  can call
  643.           TVSaveWindowToFile          TVSaveWindowToFile          TVSaveWindowToFile.
  644.  
  645.           For example, if the name of the file is stored in  file_name                                                             file_name                                                             file_name, you
  646.           could use code  like this to  save all  the data stored  for the
  647.           window:
  648.  
  649.                int               int               int    hFile;                      hFile;                      hFile;        /* handle to file */                                    /* handle to file */                                    /* handle to file */
  650.  
  651.                ...               ...               ...
  652.  
  653.                hFile = _lcreat(file_name,0);               hFile = _lcreat(file_name,0);               hFile = _lcreat(file_name,0);
  654.                TVSaveWindowToFile(hWnd,hFile,0,-1,0L);               TVSaveWindowToFile(hWnd,hFile,0,-1,0L);               TVSaveWindowToFile(hWnd,hFile,0,-1,0L);
  655.  
  656.           Specifying the start line as 0 and the  number of lines to write
  657.           as -1 causes all the stored data  to be saved. The demonstration
  658.           program sources in the distribution set  show you this technique
  659.           in use.
  660.  
  661.           The second technique for  saving data allows you  to process the
  662.           lines before they are  written. You can  obtain successive lines
  663.           from the window by calling the  TVReturnData                                          TVReturnData                                          TVReturnData function, described
  664.           in a following section, perform the  actions required, and write
  665.           to the file yourself.
  666.  
  667.           If you wish to  save only the  data that is  actually visible in
  668.           the window, you can use the TVGetWindowStatus                                      TVGetWindowStatus                                      TVGetWindowStatus function to obtain
  669.           the required line numbers, as shown here:
  670.  
  671.  
  672.                                      Page                                      Page                                      Page 10                                          10                                          10
  673.  
  674.  
  675.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  676.  
  677.  
  678.                TVWSTATUS               TVWSTATUS               TVWSTATUS  status;                          status;                          status;          /* window status details */                                           /* window status details */                                           /* window status details */
  679.                int               int               int        hFile;                          hFile;                          hFile;           /* handle to file */                                           /* handle to file */                                           /* handle to file */
  680.  
  681.                ...               ...               ...
  682.  
  683.                /* Get details of the window */               /* Get details of the window */               /* Get details of the window */
  684.  
  685.                TVGetWindowStatus(hWnd,&status);               TVGetWindowStatus(hWnd,&status);               TVGetWindowStatus(hWnd,&status);
  686.  
  687.                /* Open the file and write the data that is visible now */               /* Open the file and write the data that is visible now */               /* Open the file and write the data that is visible now */
  688.  
  689.                hFile               hFile               hFile  = _lcreat(file_name,0);                      = _lcreat(file_name,0);                      = _lcreat(file_name,0);
  690.                TVSaveWindowToFile(hWnd,hFile,status.nTopLine,               TVSaveWindowToFile(hWnd,hFile,status.nTopLine,               TVSaveWindowToFile(hWnd,hFile,status.nTopLine,
  691.                                            status.nRows,0L);                                           status.nRows,0L);                                           status.nRows,0L);
  692.  
  693.           Giving the number of lines to  be written as the  number of rows
  694.           in the window ensures that  all the visible data  is written. If
  695.           the window is  not actually full,  the function will  adjust the
  696.           number requested itself.
  697.  
  698.  
  699.           Printing Data in a Window          Printing Data in a Window          Printing Data in a Window
  700.  
  701.           TextView          TextView          TextView  does  not  itself  provide  facilities  to  print  the
  702.           contents of a window to file. If you wish your application to do
  703.           this, you will need  to use the  TVReturnData                                           TVReturnData                                           TVReturnData function described
  704.           below to read back the window's contents, and handle the printer
  705.           yourself.
  706.  
  707.           If you  create the  window  to have  a  File menu  with  a  Print
  708.           option,  TextView                   TextView                   TextView will  notify  your application  when  the  user
  709.           requests a print action by clicking it.
  710.  
  711.  
  712.           Reading Back the Contents of a TextView Window          Reading Back the Contents of a TextView Window          Reading Back the Contents of a TextView Window
  713.  
  714.           Your application can call the  TextView                                         TextView                                         TextView DLL at any  time to read
  715.           back the  data  stored  with  any   TextView                                              TextView                                              TextView  window,  using  the
  716.           TVReturnData          TVReturnData          TVReturnData function.
  717.  
  718.           The initial  call to  TVReturnData                                TVReturnData                                TVReturnData nominates  a buffer  that you
  719.           wish to use to receive the contents of the window, one line at a
  720.           time. You  also  specify the  address  of  a  callback function;
  721.           TextView          TextView          TextView will copy  the text  of one line  into your  buffer and
  722.           call this function to allow you  to process it, repeatedly until
  723.           either every  line  has been  processed,  or  you terminate  the
  724.           sequence.
  725.  
  726.           For example, the callback function might be declared like this:
  727.  
  728.                int               int               intFAR                  FAR                  FAR PASCAL                      PASCAL                      PASCAL  data_handler(HWND hWnd, LPSTR lpBuffer,                              data_handler(HWND hWnd, LPSTR lpBuffer,                              data_handler(HWND hWnd, LPSTR lpBuffer,
  729.                                            int nCount, BOOL nTruncated)                                           int nCount, BOOL nTruncated)                                           int nCount, BOOL nTruncated)
  730.  
  731.                {               {               {
  732.                   /* Make sure we didn't lose any bit of the line */                  /* Make sure we didn't lose any bit of the line */                  /* Make sure we didn't lose any bit of the line */
  733.  
  734.                   if ( nTruncated )                  if ( nTruncated )                  if ( nTruncated )
  735.                   {                  {                  {
  736.  
  737.                                      Page                                      Page                                      Page 11                                          11                                          11
  738.  
  739.  
  740.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  741.  
  742.  
  743.                       /* Buffer was too short, so a line has been cut                      /* Buffer was too short, so a line has been cut                      /* Buffer was too short, so a line has been cut
  744.                       *  short. Warn the user and abort the process                      *  short. Warn the user and abort the process                      *  short. Warn the user and abort the process
  745.                       */                      */                      */
  746.  
  747.                       MessageBox(NULL,"Buffer too short",NULL,                      MessageBox(NULL,"Buffer too short",NULL,                      MessageBox(NULL,"Buffer too short",NULL,
  748.                                  MB_ICONSTOP | MB_TASKMODAL);                                 MB_ICONSTOP | MB_TASKMODAL);                                 MB_ICONSTOP | MB_TASKMODAL);
  749.                       return(0);                      return(0);                      return(0);
  750.                   }                  }                  }
  751.  
  752.                   /* Got all the line, so process it */                  /* Got all the line, so process it */                  /* Got all the line, so process it */
  753.  
  754.                   process_line(lpBuffer);                  process_line(lpBuffer);                  process_line(lpBuffer);
  755.  
  756.                   /* And return non-zero to get the next line */                  /* And return non-zero to get the next line */                  /* And return non-zero to get the next line */
  757.  
  758.                   return(1);                  return(1);                  return(1);
  759.  
  760.                }               }               }
  761.  
  762.           This routine will be called once  for every line of  text in the
  763.           window. It checks that no data was lost  due to the buffer being
  764.           too small,  and if  it was  it terminates  the read  of  data by
  765.           returning a value  of zero  to the  DLL. If  not, it  calls some
  766.           routine called  process_file                          process_file                          process_file to  do something  to the  data, and
  767.           returns a non-zero  value requesting  the DLL  to pass  the next
  768.           line to it.
  769.  
  770.           While your application is engaged in  reading back lines of text
  771.           from a window, any calls to TVOutputText                                      TVOutputText                                      TVOutputText to add more text to it,
  772.           and most  of  the  functions  controlling  the window,  will  be
  773.           disabled.
  774.  
  775.           The example sources supplied in the distribution give you a full
  776.           example of how to use TVReturnData                                TVReturnData                                TVReturnData. In this case, they read back
  777.           the data from one window and make a copy of it in another.
  778.  
  779.  
  780.           Destroying a TextView Window          Destroying a TextView Window          Destroying a TextView Window
  781.  
  782.           A  TextView             TextView             TextView window  may be  destroyed in  one of  two ways.  Your
  783.           application may simply call the  TVDestroyWindow                                           TVDestroyWindow                                           TVDestroyWindow function, which
  784.           will remove  the  window from  the  screen and  release  all its
  785.           memory resources. This may be done at any time.
  786.  
  787.           Alternatively, if you specified in the  TVCreateWindow                                                  TVCreateWindow                                                  TVCreateWindow call that
  788.           the window was to  have a System  Menu, and did  not inhibit the
  789.           Close option, the user may close the window directly by clicking
  790.           that option. In this case,  TextView                                      TextView                                      TextView will remove the window from
  791.           the screen and release the memory  resources used by the window.
  792.           It will then  notify your application  that the window  has been
  793.           destroyed by  calling the  menu handler  function,  passing it  a
  794.           code of TVMI_CLOSE                  TVMI_CLOSE                  TVMI_CLOSE.
  795.  
  796.           You should not use the normal  Windows DestroyWindow                                                 DestroyWindow                                                 DestroyWindow function to
  797.           destroy a  TextView  window as  this  may  be incompatible  with
  798.           future releases.
  799.  
  800.  
  801.  
  802.                                      Page                                      Page                                      Page 12                                          12                                          12
  803.  
  804.  
  805.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  806.  
  807.  
  808.           Control Functions          Control Functions          Control Functions
  809.  
  810.           TextView          TextView          TextView provides  your  application  with  a  range of  control
  811.           functions  that  control  the  operation  of   its  windows,  as
  812.           described below:
  813.  
  814.  
  815.              Setting Text and Background Colour             Setting Text and Background Colour             Setting Text and Background Colour
  816.  
  817.              By default, text  will be displayed  in a  TextView                                                        TextView                                                        TextView window in
  818.              black. The TVSetTextColor                        TVSetTextColor                        TVSetTextColor function allows you to  specify any
  819.              RGB value to be used for  subsequent output. The  TVSetBKColor                                                               TVSetBKColor                                                               TVSetBKColor
  820.              function allows you to set the text background colour.
  821.  
  822.  
  823.              Setting the Scroll State             Setting the Scroll State             Setting the Scroll State
  824.  
  825.              If you  specify  the  TVS_SCROLLMENU                                   TVS_SCROLLMENU                                   TVS_SCROLLMENU setting  in  the  dwFlags
  826.              argument to TVCreateWindow                         TVCreateWindow                         TVCreateWindow, the window will have  a  Scrolling
  827.              menu that will permit  the user to switch  between manual and
  828.              automatic scroll modes at will.
  829.  
  830.              If you wish, your  application can force  a particular scroll
  831.              state itself with  the  TVSetScrollState                                     TVSetScrollState                                     TVSetScrollState function.  If you  do
  832.              not specify a Scrolling menu, this is the  only way to change
  833.              scroll modes.
  834.  
  835.  
  836.              Suspending Text Output             Suspending Text Output             Suspending Text Output
  837.  
  838.              At some point  in your application  you may wish  to suppress
  839.              output to a  TextView                          TextView                          TextView window. One  way of doing  so would, of
  840.              course, be to  set a global  flag in your  application's data
  841.              segment  that  is   checked  by  every   routine  that  calls
  842.              TVOutputText             TVOutputText             TVOutputText,  and   this   technique     is   used  in   the
  843.              demonstration application to activate or disable tracing.
  844.  
  845.              An alternative that does not involve a  global flag is to use
  846.              the  TVSuspendWindow                  TVSuspendWindow                  TVSuspendWindow function.  When  a window  is  marked  as
  847.              suspended, TVOutputText                        TVOutputText                        TVOutputText functions as normal, but  the text is
  848.              discarded.
  849.  
  850.  
  851.              Temporarily Inhibiting Window Updates             Temporarily Inhibiting Window Updates             Temporarily Inhibiting Window Updates
  852.  
  853.              Writing text  to  a  window,  particularly  if  the  existing
  854.              contents must be scrolled  to make room, can  be an expensive
  855.              operation in terms  of processor  power. If  your application
  856.              has to write a large number of lines  to a TextView                                                        TextView                                                        TextView window at
  857.              one time, it  will be considerably  slowed while the  data is
  858.              scrolled up through the display.
  859.  
  860.              The TVSetRedraw                  TVSetRedraw                  TVSetRedraw function                                                                              allows you to configure a window  so
  861.              that text lines are stored  as normal, but the  window is not
  862.              updated as they are received, letting you write the data with
  863.              TVOutputText             TVOutputText             TVOutputText very rapidly.  Then, when  you have  written all
  864.              the lines, you  can tell  TextView                                       TextView                                       TextView to  update the  window: it
  865.  
  866.  
  867.                                      Page                                      Page                                      Page 13                                          13                                          13
  868.  
  869.  
  870.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  871.  
  872.  
  873.              will display only the  final windowfull of  lines, which will
  874.              involve no scrolling.
  875.  
  876.              The demonstration program supplied with TextView                                                     TextView                                                     TextView lets you see
  877.              the effect  of suppressing  window updates:  the  Write Batch
  878.              menu option  writes 200  lines to  the window,  scrolling for
  879.              each  one;  the  Write  Batch  Fast  option  disables  window
  880.              updating, writes 200 lines and then updates the window.
  881.  
  882.  
  883.              Clearing a Window             Clearing a Window             Clearing a Window
  884.  
  885.              The TVResetWindow                 TVResetWindow                 TVResetWindow will destroy all data stored  for a window,
  886.              and it will  be redrawn  empty. The window  will be  set into
  887.              automatic scroll mode, and  the text colour used  will be set
  888.              to be black.
  889.  
  890.  
  891.           Information Functions          Information Functions          Information Functions
  892.  
  893.           You can find out  the exact status  of a  TextView                                                    TextView                                                    TextView window at  any
  894.           time by calling the  TVGetWindowStatus                               TVGetWindowStatus                               TVGetWindowStatus routine. This  fills in a
  895.           TVWSTATUS          TVWSTATUS          TVWSTATUS struct that you supply; the  details of the format are
  896.           shown in the Data Types and Structures section.
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.                                      Page                                      Page                                      Page 14                                          14                                          14
  933.  
  934.  
  935.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  936.  
  937.  
  938.        F       F       FUNCTIONS         UNCTIONS         UNCTIONS D                 D                 DIRECTORY                  IRECTORY                  IRECTORY
  939.  
  940.  
  941.        This chapter contains an alphabetical list  of functions comprising
  942.        the TextView           TextView           TextView system. The  specifications are laid  out in the  same
  943.        way as  those  in  the  Microsoft  Windows  Programmer's  reference
  944.        Manual.
  945.  
  946.        All TextView           TextView           TextView functions use the Pascal calling  convention, and must
  947.        be declared  FAR                    FAR                    FAR. Including the  header file  textview.h                                                     textview.h                                                     textview.h in sources
  948.        using these interfaces will declare their prototypes automatically,
  949.        and will ensure that they are being correctly used.
  950.  
  951.        Applications that make  use  TextView                                    TextView                                    TextView routines must  be linked  with
  952.        the TextView           TextView           TextView import library textview.lib                                   textview.lib                                   textview.lib.
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.                                      Page                                      Page                                      Page 15                                          15                                          15
  998.  
  999.  
  1000.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1001.  
  1002.  
  1003.        TVCreateWindow       TVCreateWindow       TVCreateWindow
  1004.  
  1005.        Syntax       Syntax       Syntax       BOOL                    BOOL                    BOOL      TVCreateWindow                              TVCreateWindow                              TVCreateWindow(lpClassName, lpWindowName,  X,
  1006.                     Y,  nWidth,   nHeight,   hInstance,   hFont,   dwFlags,
  1007.                     dwUnused, nTabSize, nMaxLines, lpMenuHandler)
  1008.  
  1009.                     This function creates  a TextView                                             TextView                                             TextView window. Many  of the
  1010.                     arguments  are   similar  to   those  used   with   the
  1011.                     CreateWindow function, but there are some  extra values
  1012.                     appropriate  to   TextView                                      TextView                                      TextView,  and   some   inappropriate
  1013.                     arguments may not be specified.
  1014.  
  1015.                     TVCreateWindow                    TVCreateWindow                    TVCreateWindow will always create an overlapped window.
  1016.                     Option  flags  allow  the  selection  of  minimize  and
  1017.                     maximize boxes, and  whether the user  will be able  to
  1018.                     resize it by dragging its borders.
  1019.  
  1020.                     TextView                    TextView                    TextView allows the  application to  interact with  the
  1021.                     window in a  controlled way. All  message handling  for
  1022.                     the  window   is  performed   by  TextView                                                      TextView                                                      TextView,  but   the
  1023.                     application can specify that  it wished to be  notified
  1024.                     when  events  such  as  menu  item  clicks  occur.  For
  1025.                     example, this allows the window  to appear to the  user
  1026.                     as a  normal application  window complete  with a  File
  1027.                     menu, but for handling  of the corresponding  functions
  1028.                     to be done by the application.
  1029.  
  1030.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  1031.  
  1032.                     lpClassName   LPSTR                                  LPSTR                                  LPSTR     Points to  a  null-terminated
  1033.                                   string that  names  the  window  class.
  1034.                                   This class  must  have  been previously
  1035.                                   registered    with     a     call    to
  1036.                                   TVRegisterClass.                                  TVRegisterClass.                                  TVRegisterClass.
  1037.  
  1038.                     lpWindowName  LPSTR                                  LPSTR                                  LPSTR     Points to  a  null-terminated
  1039.                                   character string  that  represents  the
  1040.                                   window name.
  1041.  
  1042.                     X             int                                  int                                  int  Specifies the  initial   x-position
  1043.                                   of the window. The value is the initial
  1044.                                   x-coordinate of the  upper left corner,
  1045.                                   in screen coordinates. If  the value is
  1046.                                   CW_USEDEFAULT,  Windows   selects   the
  1047.                                   default  position   for   the  window's
  1048.                                   upper-left corner.
  1049.  
  1050.                     Y             int                                  int                                  int  Specifies the  initial  y-position
  1051.                                   of the window. The value is the initial
  1052.                                   y-coordinate of the  upper left corner,
  1053.                                   in screen coordinates.
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.                                      Page                                      Page                                      Page 16                                          16                                          16
  1063.  
  1064.  
  1065.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1066.  
  1067.  
  1068.                     nWidth        int                                  int                                  int  Specifies the width  of the window
  1069.                                   in  device  units.  If   the  value  is
  1070.                                   CW_USEDEFAULT,   Windows    selects   a
  1071.                                   default  width   and  height   for  the
  1072.                                   window, and  the   nHeight  argument  is
  1073.                                   ignored.
  1074.  
  1075.                     nHeight       int                                  int                                  int  Specifies the height of the window
  1076.                                   in  device   units.  The   argument  is
  1077.                                   ignored if nWidth is CW_USEDEFAULT.
  1078.  
  1079.                     hInstance     HANDLE                                  HANDLE                                  HANDLE    Identifies  the  instance  of
  1080.                                   the module  to be  associated  with the
  1081.                                   window.
  1082.  
  1083.                     hFont         HFONT                                  HFONT                                  HFONT     Specifies  a  handle  to  the
  1084.                                   font to be used when text is written to
  1085.                                   the window. If  the value is  NULL, the
  1086.                                   system font is used.
  1087.  
  1088.                     dwFlags       DWORD                                  DWORD                                  DWORD     Specifies various  facilities
  1089.                                   required in the  window. It can  be any
  1090.                                   combination of the values  given in the
  1091.                                   list below.
  1092.  
  1093.                     dwUnused      DWORD                                  DWORD                                  DWORD     Must be zero.
  1094.  
  1095.                     nTabSize      int                                  int                                  int  Specifies the width of  a tab stop
  1096.                                   to be  used  when writing  text  to the
  1097.                                   window.
  1098.  
  1099.                     nMaxLines     int                                  int                                  int  Specifies how  many lines  of text
  1100.                                   are  to  be  stored   in  the  window's
  1101.                                   buffers. The value must  be between 128
  1102.                                   and 4096;  values  outside  this  range
  1103.                                   will be silently adjusted.
  1104.  
  1105.                     lpMenuHandler FARPROC                                  FARPROC                                  FARPROC   A  procedure  instance  of  a
  1106.                                   routine to  be  called  when  the  user
  1107.                                   clicks on an item in the window's menu.
  1108.                                   See the "Comments" section for details.
  1109.  
  1110.  
  1111.  
  1112.        Return Value       Return Value       Return Value The return value is a handle  to the new window. It  is
  1113.                     NULL if the window could not be created.
  1114.  
  1115.        Comments       Comments       Comments     Where the X argument is CW_USEDEFAULT,  the Y argument
  1116.                     can be one of the show-style parameters  described with
  1117.                     the ShowWindow                        ShowWindow                        ShowWindow function.
  1118.  
  1119.                     The address passed as  the lpMenuHandler argument must
  1120.                     be created by using the MakeProcInstance                                            MakeProcInstance                                            MakeProcInstance function. The
  1121.                     callback  function   must   use  the   Pascal   calling
  1122.                     convention and be declared FAR                                               FAR                                               FAR.
  1123.  
  1124.                     The dwFlags argument  should contain  values from  the
  1125.                     list below:
  1126.  
  1127.                                      Page                                      Page                                      Page 17                                          17                                          17
  1128.  
  1129.  
  1130.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1131.  
  1132.  
  1133.                     TVS_FILESAVE  Specifies that the  window is to  have a
  1134.                                   File menu that will  incorporates a  Save
  1135.                                   option. If this option  is specified the
  1136.                                   lpMenuHandler argument must not be NULL.
  1137.  
  1138.                     TVS_FILESAVEASSpecifies that the  window is to  have a
  1139.                                   File menu that will  incorporates a  Save
  1140.                                   As option. If this  option is  specified
  1141.                                   the lpMenuHandler argument  must not  be
  1142.                                   NULL.
  1143.  
  1144.                     TVS_FILEPRINT Specifies that the  window is to  have a
  1145.                                   File menu that includes  a Print option.
  1146.                                   If  this   option   is   specified   the
  1147.                                   lpMenuHandler argument must not be NULL.
  1148.  
  1149.                     TVS_HSCROLL   Specifies that the  window is  to permit
  1150.                                   horizontal scrolling by the user.
  1151.  
  1152.                     TVS_MAXIMIZE  Specifies that the  window is to  have a
  1153.                                   maximize box.
  1154.  
  1155.                     TVS_MINIMIZE  Specifies that the  window is to  have a
  1156.                                   minimize box.
  1157.  
  1158.                     TVS_NOCLOSE   Specifies that the  Close option  on the
  1159.                                   window's system menu is to be inhibited.
  1160.                                   If this  option is  used the  window can
  1161.                                   only  be   destroyed   by   a  call   to
  1162.                                   TVDestroyWindow                                  TVDestroyWindow                                  TVDestroyWindow. This option  is ignored
  1163.                                   if TVS_SYSMENU is not specified also.
  1164.  
  1165.                     TVS_NORESIZE  Specifies that the window is not to have
  1166.                                   a  thick  frame  allowing  the  user  to
  1167.                                   resize it.
  1168.  
  1169.                     TVS_SCROLLMENU
  1170.                                   Specifies that the  window is to  have a
  1171.                                   Scroll menu, allowing the user to switch
  1172.                                   between manual and  automatic scrolling.
  1173.                                   This option  requires  one  or  both  of
  1174.                                   TVS_HSCROLL and  TVS_VSCROLL to  also be
  1175.                                   defined.
  1176.  
  1177.                                   If   this   option   is   omitted,   the
  1178.                                   application must switch  scrolling modes
  1179.                                   if   required    with    a    call    to
  1180.                                   TVSetScrollState                                  TVSetScrollState                                  TVSetScrollState.
  1181.  
  1182.                     TVS_SYSMENU   Specifies that the  window is to  have a
  1183.                                   system menu. If this  option is used and
  1184.                                   the TVS_NOCLOSE option is  not used, the
  1185.                                   lpMenuHandler argument must not be NULL.
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.                                      Page                                      Page                                      Page 18                                          18                                          18
  1193.  
  1194.  
  1195.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1196.  
  1197.  
  1198.                     TVS_TIMESTAMP Specifies  that  lines  written  to  the
  1199.                                   window   are    to    automatically   be
  1200.                                   timestamped.  TextView                                                TextView                                                TextView will  prepend  the
  1201.                                   current  Windows  time  (the  number  of
  1202.                                   milliseconds since Windows  was started)
  1203.                                   to the text supplied.
  1204.  
  1205.                     TVS_VSCROLL   Specifies that the  window is  to permit
  1206.                                   vertical scrolling by the user.
  1207.  
  1208.        Callback       Callback       Callback     void FAR PASCAL                     void FAR PASCAL                     void FAR PASCAL MenuHandler(hWnd,nMenuItem)
  1209.                     HWND                    HWND                    HWND      hWnd;                                  ;                                  ;
  1210.                     WORD                    WORD                    WORD      nMenuItem;                                       ;                                       ;
  1211.  
  1212.                     MenuHandler is  a  place-holder  for  the  application-
  1213.                     supplied  function  name.  The  actual  name   must  be
  1214.                     exported by including it in an EXPORTS                                                   EXPORTS                                                   EXPORTS statement in the
  1215.                     application's module definition file.
  1216.  
  1217.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  1218.  
  1219.                     hWnd          HWND                                  HWND                                  HWND Identifies the  window  whose menu
  1220.                                   item has been selected
  1221.  
  1222.                     nMenuItem     WORD                                  WORD                                  WORD Identifies    the     menu    item
  1223.                                   concerned. The  value  will  be one  of
  1224.                                   those in the table below.
  1225.  
  1226.  
  1227.  
  1228.                     The menu handler callback function will be  informed of
  1229.                     which menu  option has  been clicked  in the  nMenuItem
  1230.                     argument. The value will  be one of  those in the  list
  1231.                     below; if the  dwFlags argument to  TVCreateWindow                                                        TVCreateWindow                                                        TVCreateWindow did
  1232.                     not enable a menu  item the corresponding  notification
  1233.                     value will not occur.
  1234.  
  1235.                     TVMI_AUTOSCROLL
  1236.                                   Specifies that the user  has clicked the
  1237.                                   Automatic   option   in   the   window's
  1238.                                   Scrolling  menu.   TextView   will  have
  1239.                                   already set  the  window  into automatic
  1240.                                   scrolling state  and  hidden  any scroll
  1241.                                   bars.
  1242.  
  1243.                     TVMI_CLOSE    Specifies that the user  has clicked the
  1244.                                   Close  option  on  the  window's  system
  1245.                                   menu. The window will  already have been
  1246.                                   destroyed when this event is notified.
  1247.  
  1248.                     TVMI_FILESAVE Specifies that the user  has clicked the
  1249.                                   Save option in the window's File menu.
  1250.  
  1251.                     TVMI_FILESAVEAS
  1252.                                   Specifies that the user  has clicked the
  1253.                                   Save As  option  in  the  window's   File
  1254.                                   menu.
  1255.  
  1256.  
  1257.                                      Page                                      Page                                      Page 19                                          19                                          19
  1258.  
  1259.  
  1260.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1261.  
  1262.  
  1263.                     TVMI_FILEPRINTSpecifies that the user  has clicked the
  1264.                                   Print option in the window's File menu.
  1265.  
  1266.                     TVMI_MANUALSCROLL
  1267.                                   Specifies that the user  has clicked the
  1268.                                   Manual option in  the window's  Scrolling
  1269.                                   menu. TextView will already have set the
  1270.                                   window into  manual  scrolling  mode and
  1271.                                   drawn the required scroll bars.
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.                                      Page                                      Page                                      Page 20                                          20                                          20
  1323.  
  1324.  
  1325.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1326.  
  1327.  
  1328.        TVDestroyWindow       TVDestroyWindow       TVDestroyWindow
  1329.  
  1330.        Syntax       Syntax       Syntax       BOOL                    BOOL                    BOOL      TVDestroyWindow                              TVDestroyWindow                              TVDestroyWindow(hWnd)
  1331.  
  1332.                     Destroys  a  window  created  with  the  TVCreateWindow                                                             TVCreateWindow                                                             TVCreateWindow
  1333.                     function.
  1334.  
  1335.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  1336.  
  1337.                     hWnd          HWND                                  HWND                                  HWND Specifies the handle to the window
  1338.                                   to be destroyed.                                                 .                                                 .
  1339.  
  1340.  
  1341.  
  1342.        Return Value       Return Value       Return Value The function  returns  TRUE                                           TRUE                                           TRUE if  the  window  has  been
  1343.                     destroyed.                             .                             .
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.                                      Page                                      Page                                      Page 21                                          21                                          21
  1388.  
  1389.  
  1390.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1391.  
  1392.  
  1393.        TVGetWindowStatus       TVGetWindowStatus       TVGetWindowStatus
  1394.  
  1395.        Syntax       Syntax       Syntax       BOOL                    BOOL                    BOOL      TVGetWindowStatus                              TVGetWindowStatus                              TVGetWindowStatus(hWnd,lpStatusBlock)
  1396.  
  1397.                     This function returns status information for a TextView                                                                   TextView                                                                   TextView
  1398.                     window.
  1399.  
  1400.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  1401.  
  1402.                     hWnd          HWND                                  HWND                                  HWND Specifies the handle to the window
  1403.                                   concerned.
  1404.  
  1405.                     lpStatusBlock LPTVWSTATUS                                  LPTVWSTATUS                                  LPTVWSTATUS    A  FAR   pointer   to  a
  1406.                                   TVWSTATUS                                  TVWSTATUS                                  TVWSTATUS block  whose  values  will be
  1407.                                   filled in by this call.
  1408.  
  1409.  
  1410.  
  1411.        Return Value       Return Value       Return Value The return value will be TRUE if the call succeeded and
  1412.                     the status information was returned.
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.                                      Page                                      Page                                      Page 22                                          22                                          22
  1453.  
  1454.  
  1455.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1456.  
  1457.  
  1458.        TVOutputText       TVOutputText       TVOutputText
  1459.  
  1460.        Syntax       Syntax       Syntax       BOOL                    BOOL                    BOOL      TVOutputText                              TVOutputText                              TVOutputText(hWnd,lpString,nCount)
  1461.  
  1462.                     Writes one line of text to a TextView                                                 TextView                                                 TextView window. The text
  1463.                     is stored in the window's buffer; if this  contains the
  1464.                     maximum number of lines  specified when the window  was
  1465.                     created, the oldest stored line will be replaced.
  1466.  
  1467.                     If the  TVS_TIMESTAMP                            TVS_TIMESTAMP                            TVS_TIMESTAMP option  was  specified  when the
  1468.                     window was created, TextView                                        TextView                                        TextView will prefix  the supplied
  1469.                     text with the  current Windows  time before  displaying
  1470.                     it.
  1471.  
  1472.                     Tab characters will be expanded to the  width specified
  1473.                     when the window was created.
  1474.  
  1475.                     The text will  be written using  the colour defined  by
  1476.                     the  last  call  to  TVSetTextColor                                         TVSetTextColor                                         TVSetTextColor,  or  in  black  by
  1477.                     default.
  1478.  
  1479.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  1480.  
  1481.                     hWnd          HWND                                  HWND                                  HWND Specifies the handle to the window
  1482.                                   concerned.
  1483.  
  1484.                     lpString      LPSTR                                  LPSTR                                  LPSTR     Points to  the  string  to be
  1485.                                   written.
  1486.  
  1487.                     nCount        int                                  int                                  int  Specifies the number of characters
  1488.                                   in the string. If the value is zero the
  1489.                                   string will  be  assumed  to  be  null-
  1490.                                   terminated and will  be written  in its
  1491.                                   entirety.
  1492.  
  1493.  
  1494.  
  1495.        Return Value       Return Value       Return Value The  return  value  will  be  TRUE                                                  TRUE                                                  TRUE  if  the  text  was
  1496.                     successfully displayed.
  1497.  
  1498.        Comments       Comments       Comments     There are three conditions in  which the text will  not
  1499.                     be displayed in the window as requested:
  1500.  
  1501.                     1. If the window has been put into suspended state with
  1502.                     a call  to TVSuspendWindow                               TVSuspendWindow                               TVSuspendWindow, the  call to   TVOutputText                                                               TVOutputText                                                               TVOutputText
  1503.                     will be silently ignored.
  1504.  
  1505.                     2. If the application  has called TVReturnData                                                      TVReturnData                                                      TVReturnData to read
  1506.                     back the lines stored  in the window,  and has not  yet
  1507.                     ended the call-back loop, the call to TVOutputText                                                          TVOutputText                                                          TVOutputText will
  1508.                     be silently ignored.
  1509.  
  1510.                     3. If the  window is  in manual scroll  mode, the  call
  1511.                     will  also  be  silently  ignored.  However,   TextView                                                                   TextView                                                                   TextView
  1512.                     records the number of lines lost when this  occurs, and
  1513.                     will add a line to the window itself to notify the user
  1514.                     when the window returns to automatic scroll mode.
  1515.  
  1516.  
  1517.                                      Page                                      Page                                      Page 23                                          23                                          23
  1518.  
  1519.  
  1520.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1521.  
  1522.  
  1523.                     In all  these cases,  TVOutputText                                          TVOutputText                                          TVOutputText returns  a value  of
  1524.                     TRUE                    TRUE                    TRUE to the  caller. A  FALSE                                            FALSE                                            FALSE value is  used solely  to
  1525.                     indicate a system problem such as insufficient memory.
  1526.  
  1527.                     Text longer than 512 bytes will be truncated.
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.                                      Page                                      Page                                      Page 24                                          24                                          24
  1583.  
  1584.  
  1585.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1586.  
  1587.  
  1588.        TVRegisterClass       TVRegisterClass       TVRegisterClass
  1589.  
  1590.        Syntax       Syntax       Syntax       BOOL                    BOOL                    BOOL
  1591.                               TVRegisterClass                              TVRegisterClass                              TVRegisterClass(hInstance,lpClassName,hIcon,h
  1592.                     brBackground)
  1593.  
  1594.                     This  function  registers  a  window  class   that  can
  1595.                     subsequently be passed  to TVCreateWindow                                               TVCreateWindow                                               TVCreateWindow to  create a
  1596.                     TextView                    TextView                    TextView window. The use of the function is  similar to
  1597.                     that of the RegisterClass                                RegisterClass                                RegisterClass function, with the exception
  1598.                     that TextView                         TextView                         TextView itself will  supply most  of the details
  1599.                     required.
  1600.  
  1601.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  1602.  
  1603.                     hInstance     HANDLE                                  HANDLE                                  HANDLE    Specifies  the  application's
  1604.                                   instance handle.
  1605.  
  1606.                     lpClassName   LPSTR                                  LPSTR                                  LPSTR     Points to  a  null-terminated
  1607.                                   string containing the name  to be given
  1608.                                   to the window class.
  1609.  
  1610.                     hIcon         HICON                                  HICON                                  HICON     Specifies  a  handle  to  the
  1611.                                   icon  to  be  used  when  the   TextView                                                                  TextView                                                                  TextView
  1612.                                   window is  minimized.  It  must not  be
  1613.                                   NULL.
  1614.  
  1615.                     hbrBackground HBRUSH                                  HBRUSH                                  HBRUSH    Specifies      the      class
  1616.                                   background brush to  be applied  to the
  1617.                                   window. The meaning  is as  defined for
  1618.                                   the hbrBackground item of  the  WNDCLASS                                                                  WNDCLASS                                                                  WNDCLASS
  1619.                                   structure, with the  exception that the
  1620.                                   value must not be NULL.
  1621.  
  1622.  
  1623.  
  1624.        Return Value       Return Value       Return Value The function returns TRUE                                         TRUE                                         TRUE if the class  was registered
  1625.                     successfully.
  1626.  
  1627.        Comments       Comments       Comments     An error return  value of FALSE                                              FALSE                                              FALSE will result  both from
  1628.                     the class name already having been registered, and from
  1629.                     invalid arguments being supplied.
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.                                      Page                                      Page                                      Page 25                                          25                                          25
  1648.  
  1649.  
  1650.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1651.  
  1652.  
  1653.        TVResetWindow       TVResetWindow       TVResetWindow
  1654.  
  1655.        Syntax       Syntax       Syntax       BOOL                    BOOL                    BOOL      TVResetWindow                              TVResetWindow                              TVResetWindow(hWnd)
  1656.  
  1657.                     This functions resets a  TextView                                             TextView                                             TextView window to an  'empty'
  1658.                     state. All stored text is discarded, and the  window is
  1659.                     redrawn empty. The  window will be  put into  automatic
  1660.                     scroll mode, and will be  marked as not suspended.  The
  1661.                     text colour will be set to black.
  1662.  
  1663.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  1664.  
  1665.                     hWnd          HWND                                  HWND                                  HWND Specifies the handle of the window
  1666.                                   concerned.
  1667.  
  1668.  
  1669.  
  1670.        Return Value       Return Value       Return Value The  function  will  return   TRUE                                                  TRUE                                                  TRUE  if  the   operation
  1671.                     succeeded.
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.                                      Page                                      Page                                      Page 26                                          26                                          26
  1713.  
  1714.  
  1715.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1716.  
  1717.  
  1718.        TVReturnData       TVReturnData       TVReturnData
  1719.  
  1720.        Syntax       Syntax       Syntax       int                    int                    int
  1721.                               TVReturnData                              TVReturnData                              TVReturnData(hWnd,lpBuffer,nSize,lpNotifyFunc
  1722.                     )
  1723.  
  1724.                     This function  requests  TextView to  return  the  data
  1725.                     stored  in  a  TextView  window  into  an  application-
  1726.                     supplied buffer.  TextView                                      TextView                                      TextView will  copy successive  lines
  1727.                     into the buffer, and will call back into a notification
  1728.                     function to inform  the application that  each line  is
  1729.                     ready. The process continues until either all the lines
  1730.                     have been  returned or  the callback  function  returns
  1731.                     zero.
  1732.  
  1733.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  1734.  
  1735.                     hWnd          HWND                                  HWND                                  HWND Specifies the handle to the window
  1736.                                   concerned.
  1737.  
  1738.                     lpBuffer      LPSTR                                  LPSTR                                  LPSTR     Points to  the  application's
  1739.                                   buffer into  which  TextView                                                      TextView                                                      TextView will  copy
  1740.                                   successive lines.
  1741.  
  1742.                     nSize         int                                  int                                  int  Specifies   the   size    of   the
  1743.                                   application's buffer.
  1744.  
  1745.                     lpNotifyFunc  FARPROC                                  FARPROC                                  FARPROC   The        procedure-instance
  1746.                                   address of  the callback  function used
  1747.                                   to notify  the  application  when  each
  1748.                                   line has been copied into the buffer.
  1749.  
  1750.  
  1751.  
  1752.        Return Value       Return Value       Return Value The return value specifies  the last value returned  by
  1753.                     the callback function. Its meaning is user-defined.
  1754.  
  1755.        Comments       Comments       Comments     The address passed as the lpNotifyFunc argument must be
  1756.                     created by using the MakeProcInstance                                         MakeProcInstance                                         MakeProcInstance function.
  1757.  
  1758.                     The callback  function  must  use  the  Pascal  calling
  1759.                     convention and be declared FAR                                               FAR                                               FAR.
  1760.  
  1761.        Callback       Callback       Callback     int FAR PASCAL                    int FAR PASCAL                    int FAR PASCAL
  1762.                     NotifyFunc(hWnd,lpBuffer,nCount,nTruncated)
  1763.                     HWND                    HWND                    HWND      hWnd;
  1764.                     LPSTR                    LPSTR                    LPSTR     lpBuffer;
  1765.                     int                    int                    int       nCount;
  1766.                     BOOL                    BOOL                    BOOL      nTruncated;
  1767.  
  1768.                     NotifyFunc  is  a  placeholder  for  the   application-
  1769.                     supplied  function  name.  The  actual  name   must  be
  1770.                     exported by including it in an EXPORTS statement in the
  1771.                     application's module definition file.
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.                                      Page                                      Page                                      Page 27                                          27                                          27
  1778.  
  1779.  
  1780.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1781.  
  1782.  
  1783.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  1784.  
  1785.                     hWnd          HWND                                  HWND                                  HWND Specifies the handle to the window
  1786.                                   concerned.
  1787.  
  1788.                     lpBuffer      LPSTR                                  LPSTR                                  LPSTR     Points  to  the  application-
  1789.                                   supplied buffer  that now  contains the
  1790.                                   text of a line of text from the window.
  1791.  
  1792.                     nCount        int                                  int                                  int  Specifies the  line  number within
  1793.                                   the window corresponding  to this call.
  1794.                                   The first line is numbered zero.
  1795.  
  1796.                     nTruncated    BOOL                                  BOOL                                  BOOL      This value  will  be  TRUE if
  1797.                                   the text  had  to be  truncated  to fit
  1798.                                   into the supplied buffer.
  1799.  
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.                                      Page                                      Page                                      Page 28                                          28                                          28
  1843.  
  1844.  
  1845.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1846.  
  1847.  
  1848.        TVSaveWindowToFile       TVSaveWindowToFile       TVSaveWindowToFile
  1849.  
  1850.        Syntax       Syntax       Syntax       BOOL                    BOOL                    BOOL
  1851.                               TVSaveWindowToFile                              TVSaveWindowToFile                              TVSaveWindowToFile(hWnd,hFile,nStart,nLines,d
  1852.                     wFlags)
  1853.  
  1854.                     This function  writes the  data stored  for a  TextView                                                                   TextView                                                                   TextView
  1855.                     window into a file. It can  be called at any time,  and
  1856.                     not only in response  to the user  clicking an item  in
  1857.                     the window's File menu.
  1858.  
  1859.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  1860.  
  1861.                     hWnd          HWND                                  HWND                                  HWND Specifies the handle to the window
  1862.                                   concerned.
  1863.  
  1864.                     hFile         int                                  int                                  int  Specifies the MSDOS  handle to the
  1865.                                   file  to  which  the   data  is  to  be
  1866.                                   written. The file must have been opened
  1867.                                   for writing.
  1868.  
  1869.                     nStart        int                                  int                                  int  Specifies the number  of the first
  1870.                                   stored line to be  written to the file.
  1871.                                   The first line is numbered zero.
  1872.  
  1873.                     nLines        int                                  int                                  int  Specifies the  number of  lines to
  1874.                                   be written.  A value  of -1  will write
  1875.                                   all the  lines  stored  from the  first
  1876.                                   specified to the end of the buffer.
  1877.  
  1878.                     dwFlags       DWORD                                  DWORD                                  DWORD     Must be set to 0L.
  1879.  
  1880.  
  1881.  
  1882.        Return Value       Return Value       Return Value The function returns TRUE                                         TRUE                                         TRUE if the operation succeeded. A
  1883.                     value of FALSE                             FALSE                             FALSE indicates either that the range of lines
  1884.                     requested  was  invalid,  or  that  an  error  occurred
  1885.                     writing the  file. In  the latter  case, TextView                                                             TextView                                                             TextView will
  1886.                     display a message to alert the user.
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.                                      Page                                      Page                                      Page 29                                          29                                          29
  1908.  
  1909.  
  1910.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1911.  
  1912.  
  1913.        TVSetBkColor       TVSetBkColor       TVSetBkColor
  1914.  
  1915.        Syntax       Syntax       Syntax       DWORD                    DWORD                    DWORD     TVSetBkColor                              TVSetBkColor                              TVSetBkColor(hWnd,crColor)
  1916.  
  1917.                     This function sets the background colour used when text
  1918.                     is written to a TextView                                    TextView                                    TextView window.
  1919.  
  1920.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  1921.  
  1922.                     hWnd          HWND                                  HWND                                  HWND Specifies the handle to the window
  1923.                                   concerned.
  1924.  
  1925.                     crColor       COLORREF                                  COLORREF                                  COLORREF  Specifies the  new background
  1926.                                   colour.
  1927.  
  1928.  
  1929.  
  1930.        Return Value       Return Value       Return Value The function will return the previously set  colour, or
  1931.                     -1 if an error occurs.
  1932.  
  1933.        Comments       Comments       Comments     TextView                    TextView                    TextView  does  not  record  background  colours   with
  1934.                     individual messages. As the screen is scrolled messages
  1935.                     that are written will use the text colour  defined when
  1936.                     they were  stored, but  the current background  colour
  1937.                     value.
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.                                      Page                                      Page                                      Page 30                                          30                                          30
  1973.  
  1974.  
  1975.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  1976.  
  1977.  
  1978.        TVSetRedraw       TVSetRedraw       TVSetRedraw
  1979.  
  1980.        Syntax       Syntax       Syntax       WORD                    WORD                    WORD      TVSetRedraw                              TVSetRedraw                              TVSetRedraw(hWnd,nNewState)
  1981.  
  1982.                     This function sets the redraw of a TextView                                                       TextView                                                       TextView window. If
  1983.                     the state is set to FALSE                                        FALSE                                        FALSE, lines written to the window
  1984.                     with TVOutputText                         TVOutputText                         TVOutputText will be stored,  but the screen will
  1985.                     not be updated until the state is changed to TRUE                                                                 TRUE                                                                 TRUE.
  1986.  
  1987.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  1988.  
  1989.                     hWnd          HWND                                  HWND                                  HWND Specifies the handle to the window
  1990.                                   concerned.
  1991.  
  1992.                     nNewState     BOOL                                  BOOL                                  BOOL      Specifies the new state to be
  1993.                                   set.
  1994.  
  1995.  
  1996.  
  1997.        Return Value       Return Value       Return Value The function will return  the previous redraw state  of
  1998.                     the window.
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.                                      Page                                      Page                                      Page 31                                          31                                          31
  2038.  
  2039.  
  2040.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  2041.  
  2042.  
  2043.        TVSetScrollState       TVSetScrollState       TVSetScrollState
  2044.  
  2045.        Syntax       Syntax       Syntax       WORD                    WORD                    WORD      TVSetScrollState                              TVSetScrollState                              TVSetScrollState(hWnd,nNewState)
  2046.  
  2047.                     This function sets  the scrolling state  of a  TextView                                                                   TextView                                                                   TextView
  2048.                     window.
  2049.  
  2050.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  2051.  
  2052.                     hWnd          HWND                                  HWND                                  HWND Specifies the handle to the window
  2053.                                   concerned.
  2054.  
  2055.                     nNewState     WORD                                  WORD                                  WORD Specifies the new state to be set.
  2056.                                   The value should be  TV_SCR_AUTO                                                       TV_SCR_AUTO                                                       TV_SCR_AUTO to set
  2057.                                   automatic scrolling,  or   TV_SCR_MANUAL                                                             TV_SCR_MANUAL                                                             TV_SCR_MANUAL
  2058.                                   to set manual scrolling.
  2059.  
  2060.  
  2061.  
  2062.        Return Value       Return Value       Return Value The function will return  the previous scrolling  state
  2063.                     of the window as  wither TV_SCR_AUTO                                             TV_SCR_AUTO                                             TV_SCR_AUTO or  TV_SCR_MANUAL                                                             TV_SCR_MANUAL                                                             TV_SCR_MANUAL.
  2064.                     It will return zero if an error occurs, or if  the call
  2065.                     to TVCreateWindow                       TVCreateWindow                       TVCreateWindow did not  specify one or  both of the
  2066.                     TVS_HSCROLL                    TVS_HSCROLL                    TVS_HSCROLL and TVS_VSCROLL                                    TVS_VSCROLL                                    TVS_VSCROLL options.
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.                                      Page                                      Page                                      Page 32                                          32                                          32
  2103.  
  2104.  
  2105.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  2106.  
  2107.  
  2108.        TVSetTextColor       TVSetTextColor       TVSetTextColor
  2109.  
  2110.        Syntax       Syntax       Syntax       DWORD                    DWORD                    DWORD     TVSetTextColor                              TVSetTextColor                              TVSetTextColor(hWnd,crColor)
  2111.  
  2112.                     This function sets the colour in which text  is written
  2113.                     to a TextView                         TextView                         TextView window.
  2114.  
  2115.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  2116.  
  2117.                     hWnd          HWND                                  HWND                                  HWND Specifies the handle to the window
  2118.                                   concerned.
  2119.  
  2120.                     crColor       COLORREF                                  COLORREF                                  COLORREF  Specifies the colour in which
  2121.                                   text is to be written.
  2122.  
  2123.  
  2124.  
  2125.        Return Value       Return Value       Return Value The function will return the previously set  colour, or
  2126.                     -1 if an error occurs.
  2127.  
  2128.        Comments       Comments       Comments     Using this function does not affect the colour  of text
  2129.                     that has already been written.
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.                                      Page                                      Page                                      Page 33                                          33                                          33
  2168.  
  2169.  
  2170.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  2171.  
  2172.  
  2173.        TVSuspendWindow       TVSuspendWindow       TVSuspendWindow
  2174.  
  2175.        Syntax       Syntax       Syntax       BOOL                    BOOL                    BOOL      TVSuspendWindow                              TVSuspendWindow                              TVSuspendWindow(hWnd,nNewState)
  2176.  
  2177.                     Sets the suspend state of a TextView                                                TextView                                                TextView window.
  2178.  
  2179.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  2180.  
  2181.                     hWnd          HWND                                  HWND                                  HWND Specifies the handle to the window
  2182.                                   concerned.
  2183.  
  2184.                     nNewState     BOOL                                  BOOL                                  BOOL      Specifies  the  state  to  be
  2185.                                   set. It should  be  TRUE                                                      TRUE                                                      TRUE to suspend  the
  2186.                                   window, and FALSE                                              FALSE                                              FALSE to desuspend it.
  2187.  
  2188.  
  2189.  
  2190.        Return Value       Return Value       Return Value The return value is the  previous suspend state of  the
  2191.                     window.
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.                                      Page                                      Page                                      Page 34                                          34                                          34
  2233.  
  2234.  
  2235.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  2236.  
  2237.  
  2238.        TVVersion       TVVersion       TVVersion
  2239.  
  2240.        Syntax       Syntax       Syntax       void                    void                    void      TVVersion                              TVVersion                              TVVersion(lpMark,lpVersion,lpCycle)
  2241.  
  2242.                     Returns the version identification of the TextView                                                              TextView                                                              TextView DLL.
  2243.                     This consists of a mark number, a version number within
  2244.                     that mark, and a  compilation cycle number within that
  2245.                     version.
  2246.  
  2247.                     _________                    Parameter                    _________                    Parameter                    _________                    Parameter     ________________                                  Type/Description                                  ________________                                  Type/Description                                  ________________                                  Type/Description
  2248.  
  2249.                     lpMark        LPINT                                  LPINT                                  LPINT     Pointer to an  int                                                           int                                                           int to receive
  2250.                                   the mark number.
  2251.  
  2252.                     lpVersion     LPINT                                  LPINT                                  LPINT     Pointer to an  int                                                           int                                                           int to receive
  2253.                                   the version number.
  2254.  
  2255.                     lpCycle       LPINT                                  LPINT                                  LPINT     Pointer to an  int                                                           int                                                           int to receive
  2256.                                   the cycle number.
  2257.  
  2258.  
  2259.  
  2260.        Return Value       Return Value       Return Value The function has no return value.
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.                                      Page                                      Page                                      Page 35                                          35                                          35
  2298.  
  2299.  
  2300.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  2301.  
  2302.  
  2303.        D       D       DATA         ATA         ATA T            T            TYPES AND              YPES AND              YPES AND S                      S                      STRUCTURES                       TRUCTURES                       TRUCTURES
  2304.  
  2305.  
  2306.        This section  describes  the data  types  and  structures that  are
  2307.        defined by  TextView                   TextView                   TextView. Definitions of  all the  items described here
  2308.        are contain in the header file textview.h                                      textview.h                                      textview.h.
  2309.  
  2310.  
  2311.           Data types          Data types          Data types
  2312.  
  2313.           The data types in the  following list are key  words that define
  2314.           the size and meaning  of arguments and  return values associated
  2315.           with TextView               TextView               TextView functions.
  2316.  
  2317.            ____           Type           ____           Type           ____           Type                   __________                                  Definition                                  __________                                  Definition                                  __________                                  Definition
  2318.  
  2319.            LPTVWSTATUS           LPTVWSTATUS           LPTVWSTATUS            Long  pointer  to  a   TVWSTATUS                                                         TVWSTATUS                                                         TVWSTATUS  data
  2320.                                   structure.
  2321.  
  2322.  
  2323.  
  2324.  
  2325.           Data structures          Data structures          Data structures
  2326.  
  2327.           This section lists data structures that are used by TextView                                                              TextView                                                              TextView.
  2328.  
  2329.           TVWSTATUS          TVWSTATUS          TVWSTATUS
  2330.  
  2331.           Status Information for a TextView Window          Status Information for a TextView Window          Status Information for a TextView Window
  2332.  
  2333.                  The TVWSTATUS                     TVWSTATUS                     TVWSTATUS structure contains  information giving  the
  2334.                  current status of a TextView                                     TextView                                     TextView window.
  2335.  
  2336.                  typedef struct sTVWSTATUS                 typedef struct sTVWSTATUS                 typedef struct sTVWSTATUS
  2337.                  {                 {                 {
  2338.                      DWORD                     DWORD                     DWORD      dwFlags;                                dwFlags;                                dwFlags;
  2339.                      int                     int                     int        nMaxLines;                                nMaxLines;                                nMaxLines;
  2340.                      int                     int                     int        nLinesStored;                                nLinesStored;                                nLinesStored;
  2341.                      BOOL                     BOOL                     BOOL       nSuspended;                                nSuspended;                                nSuspended;
  2342.                      BOOL                     BOOL                     BOOL       nReturningData;                                nReturningData;                                nReturningData;
  2343.                      BOOL                     BOOL                     BOOL       nRedraw;                                nRedraw;                                nRedraw;
  2344.                      WORD                     WORD                     WORD       nScrollState;                                nScrollState;                                nScrollState;
  2345.                      int                     int                     int        nTabSize;                                nTabSize;                                nTabSize;
  2346.                      int                     int                     int        nMessagesLost;                                nMessagesLost;                                nMessagesLost;
  2347.                      int                     int                     int        nRows;                                nRows;                                nRows;
  2348.                      int                     int                     int        nColumns;                                nColumns;                                nColumns;
  2349.                      int                     int                     int        nTopLine;                                nTopLine;                                nTopLine;
  2350.                      int                     int                     int        nNextRow;                                nNextRow;                                nNextRow;
  2351.                      COLORREF                     COLORREF                     COLORREF   crColor;                                crColor;                                crColor;
  2352.                      COLORREF                     COLORREF                     COLORREF   crBkColor;                                crBkColor;                                crBkColor;
  2353.                  } TVWSTATUS;                 } TVWSTATUS;                 } TVWSTATUS;
  2354.  
  2355.                  The TVWSTATUS structure has the following fields:
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.                                      Page                                      Page                                      Page 36                                          36                                          36
  2363.  
  2364.  
  2365.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  2366.  
  2367.  
  2368.                  _________                 Parameter                 _________                 Parameter                 _________                 Parameter      ___________                                Description                                ___________                                Description                                ___________                                Description
  2369.  
  2370.                  dwFlags                 dwFlags                 dwFlags        Contains a  copy of  the  dwFlags argument
  2371.                                 passed to  the  TVCreateWindow                                                TVCreateWindow                                                TVCreateWindow  call  that
  2372.                                 created the window.
  2373.  
  2374.                  nMaxLines                 nMaxLines                 nMaxLines      Specifies the maximum number of lines that
  2375.                                 may be stored with the window.
  2376.  
  2377.                  nLinesStored                 nLinesStored                 nLinesStored   Specifies the  number  of  lines currently
  2378.                                 stored with the window.
  2379.  
  2380.                  nSuspended                 nSuspended                 nSuspended     Specifies whether the  window is currently
  2381.                                 in suspended state.
  2382.  
  2383.                  nReturningDat                 nReturningDat                 nReturningDat  Specifies whether  TextView                                                   TextView                                                   TextView  is  currently
  2384.                  a                 a                 a              servicing a  TVReturnData                                             TVReturnData                                             TVReturnData  call  for  this
  2385.                                 window.
  2386.  
  2387.                  nRedraw                 nRedraw                 nRedraw        Specifies whether  lines  written  to  the
  2388.                                 window are being displayed immediately, or
  2389.                                 are being  held until  a window  redraw is
  2390.                                 permitted.
  2391.  
  2392.                  nScrollState                 nScrollState                 nScrollState   Specifies the current scroll  state of the
  2393.                                 window.   The   value   will   be   either
  2394.                                 TV_SCR_AUTO                                TV_SCR_AUTO                                TV_SCR_AUTO or TV_SCR_MANUAL                                               TV_SCR_MANUAL                                               TV_SCR_MANUAL.
  2395.  
  2396.                  nTabSize                 nTabSize                 nTabSize       Specifies the  width  of  a  tab  stop, in
  2397.                                 characters.
  2398.  
  2399.                  nMessagesLost                 nMessagesLost                 nMessagesLost  Specifies the number of messages that have
  2400.                                 been lost by  being written  to the window
  2401.                                 while it  is in  manual scroll  state. The
  2402.                                 value is cleared whenever the scroll state
  2403.                                 is set to automatic.
  2404.  
  2405.                  nRows                 nRows                 nRows          Specifies the current depth of the window,
  2406.                                 in text rows.
  2407.  
  2408.                  nColumns                 nColumns                 nColumns       Specifies the current width of the window,
  2409.                                 in average characters.
  2410.  
  2411.                  nTopLine                 nTopLine                 nTopLine       Specifies the  line  number  of  the  line
  2412.                                 currently displayed  at  the  top  of  the
  2413.                                 window.
  2414.  
  2415.                  nNextRow                 nNextRow                 nNextRow       Specifies the window row to which the next
  2416.                                 line of  text will  be written  (the first
  2417.                                 row is  numbered  zero). If  the  value is
  2418.                                 negative, the window is full and will need
  2419.                                 to be scrolled to accept the next line.
  2420.  
  2421.                  crColor                 crColor                 crColor        The current text colour.
  2422.  
  2423.                  crBkColor                 crBkColor                 crBkColor      The current background colour.
  2424.  
  2425.  
  2426.  
  2427.                                      Page                                      Page                                      Page 37                                          37                                          37
  2428.  
  2429.  
  2430.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.                                      Page                                      Page                                      Page 38                                          38                                          38
  2493.  
  2494.  
  2495.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  2496.  
  2497.  
  2498.        A       A       APPENDIX         PPENDIX         PPENDIX : T                : T                : THE                    HE                    HE D                      D                      DEMONSTRATION                        EMONSTRATION                        EMONSTRATION P                                    P                                    PROGRAM                                     ROGRAM                                     ROGRAM
  2499.  
  2500.  
  2501.        Supplied with the  TextView                          TextView                          TextView DLL in  the full  distribution set  are
  2502.        full sources for  a demonstration program  that both show  you what
  2503.        the system can do, and supplement the  information in this guide on
  2504.        how to program with it.
  2505.  
  2506.        The sources  are Copyright  (c)  Alan Phillips  1991.  However, the
  2507.        techniques shown within them may be freely used and adopted for any
  2508.        non-commercial applications.
  2509.  
  2510.  
  2511.           A real-time program trace facility          A real-time program trace facility          A real-time program trace facility
  2512.  
  2513.           The purpose of the demonstration program is  to show you how you
  2514.           can use  TextView                   TextView                   TextView to add  a real-time  tracing facility  to your
  2515.           application.
  2516.  
  2517.           Of course, there are many ways to debug  a program while you are
  2518.           developing it.  You  can  use  Microsoft's  CodeView  system  to
  2519.           monitor it; but  this is  relatively clumsy and,  until CodeView
  2520.           3.05, required you to have two monitors attached to your system.
  2521.           Even with single monitor capability, CodeView debugging can be a
  2522.           time-consuming business.
  2523.  
  2524.           If you know the area where  a bug is occurring,  you might plant
  2525.           MessageBox          MessageBox          MessageBox calls  at suitable  points  to stop  the  program and
  2526.           display details. This, though, is very  laborious, requiring you
  2527.           to click an OK box every time; and if your bug is  deep inside a
  2528.           loop might well be totally impractical.
  2529.  
  2530.           TextView          TextView          TextView lets you add a real-time trace facility to your program
  2531.           with ease.  In essence,  you can  regard  it as  giving  you the
  2532.           ability you have in  DOS programs of performing  printf                                                           printf                                                           printf calls to
  2533.           the screen: the  messages appear as  you write them,  and scroll
  2534.           off the top of  the screen to  make room for  new ones. However,
  2535.           with  TextView                TextView                TextView you  have a  permanent record  of as  many of  the
  2536.           lines as you  choose, and  can at any  time scroll  back through
  2537.           them.
  2538.  
  2539.           Typically, you  would  add  simple  text  output calls  to  your
  2540.           program as  you develop  it,  writing out  progress  records and
  2541.           useful values  as  you go.  The  trace                                           trace                                           trace routine  in  the supplied
  2542.           sources is  a basic  example of  such a  routine. Its  action is
  2543.           controlled by a simple  on or off  flag that  is settable from  a
  2544.           menu, so you  can activate  or de-activate tracing  whenever you
  2545.           want. Of course, you  could add more  sophisticated criteria, to
  2546.           allow you  to trace,  for  example, only  certain  categories of
  2547.           events or at certain debug levels.
  2548.  
  2549.  
  2550.           Running the demonstration          Running the demonstration          Running the demonstration
  2551.  
  2552.           To run  the  demonstration you  must  first  have installed  the
  2553.           TextView          TextView          TextView DLL as described  earlier. Then, you can  start it from
  2554.           the Program  Manager,  the File  Manager  or  any other  program
  2555.           launcher you may have.
  2556.  
  2557.                                      Page                                      Page                                      Page 39                                          39                                          39
  2558.  
  2559.  
  2560.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  2561.  
  2562.  
  2563.              Trace menu items             Trace menu items             Trace menu items
  2564.  
  2565.              All the actions  of the demonstration  program are controlled
  2566.              by options in the trace menu. Some of the options control the
  2567.              trace system's  operation;  others  simulate  an  application
  2568.              writing messages as it runs.
  2569.  
  2570.                 Start tracing                Start tracing                Start tracing
  2571.  
  2572.                 This option activates tracing. If a  trace window does not
  2573.                 already exist,  it  causes  a  call  to  TVCreateWindow                                                         TVCreateWindow                                                         TVCreateWindow to
  2574.                 create one. The global  tracing flag is set to on, so that
  2575.                 the trace routine becomes active.
  2576.  
  2577.                 Stop tracing                Stop tracing                Stop tracing
  2578.  
  2579.                 Sets the global  tracing flag to   off, so  that the  trace
  2580.                 routine does nothing.  The trace  window is  not affected.
  2581.                 These two options  show on  way of controlling  the system
  2582.                 from your application.
  2583.  
  2584.                 Write one message                Write one message                Write one message
  2585.  
  2586.                 Causes one call to  the trace routine to  write a message.
  2587.                 Depending on the setting of the  global tracing flag, text
  2588.                 either will or will not appear in the trace window.
  2589.  
  2590.                 Write batch                Write batch                Write batch
  2591.  
  2592.                 Writes a batch of  200 messages in a  loop, to demonstrate
  2593.                 how the TextView                        TextView                        TextView window scrolls.
  2594.  
  2595.                 Write batch fast                Write batch fast                Write batch fast
  2596.  
  2597.                 Writes a  batch  of 200  messages  in a  loop.  Unlike the
  2598.                 previous option,  the  TVSetRedraw                                       TVSetRedraw                                       TVSetRedraw function  is  called to
  2599.                 inhibit updating  of  the  TextView                                           TextView                                           TextView window  while  this  is
  2600.                 being done. The  effect is  that the messages  are written
  2601.                 substantially faster.
  2602.  
  2603.                 Reset trace window                Reset trace window                Reset trace window
  2604.  
  2605.                 Calls the TVResetWindow                          TVResetWindow                          TVResetWindow function to clear all  data stored
  2606.                 in the TextView                       TextView                       TextView window.
  2607.  
  2608.                 Show trace window                Show trace window                Show trace window
  2609.  
  2610.                 This option uses normal Windows API  functions to make the
  2611.                 TextView                TextView                TextView window visible,  and bring it  to the top  of the
  2612.                 screen. It shows you one case  in which you can manipulate
  2613.                 the window with normal  Windows functions as  well as with
  2614.                 TextView                TextView                TextView functions.
  2615.  
  2616.                 Show trace status                Show trace status                Show trace status
  2617.  
  2618.                 Calls  the  TVGetWindowStatus                            TVGetWindowStatus                            TVGetWindowStatus  function  to  display  some
  2619.                 details of what the TextView                                    TextView                                    TextView window is doing.
  2620.  
  2621.  
  2622.                                      Page                                      Page                                      Page 40                                          40                                          40
  2623.  
  2624.  
  2625.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  2626.  
  2627.  
  2628.                 Trace window scrolling                Trace window scrolling                Trace window scrolling
  2629.  
  2630.                 This menu  option  shows you  a  further  popup menu  item
  2631.                 containing two items:  Automatic and Manual. These let you
  2632.                 change the scrolling state of the TextView                                                  TextView                                                  TextView window from the
  2633.                 application's menu.
  2634.  
  2635.                 You can also change the scrolling state from the  Scrolling
  2636.                 item in  the  TextView                              TextView                              TextView window's   own menu.  Note  how  the
  2637.                 application uses  the menu  notification facility  to keep
  2638.                 the check marks on its  menu item in line  with the window
  2639.                 state when this is done.
  2640.  
  2641.                 Copy trace window                Copy trace window                Copy trace window
  2642.  
  2643.                 This menu item creates a second  TextView                                                 TextView                                                 TextView window, and uses
  2644.                 the TVReturnData                    TVReturnData                    TVReturnData function to  copy all  the data from  the
  2645.                 first one into it.
  2646.  
  2647.                 Kill trace window                Kill trace window                Kill trace window
  2648.  
  2649.                 This destroys  the  TextView                                    TextView                                    TextView window  and  deletes all  the
  2650.                 stored data.
  2651.  
  2652.  
  2653.           Source files          Source files          Source files
  2654.  
  2655.           The demonstration program source comprises a  number of modules,
  2656.           which are described briefly  below. For full  details you should
  2657.           consult the  actual sources,  which  contain a  large  amount of
  2658.           explanatory comment.
  2659.  
  2660.  
  2661.              main.c             main.c             main.c
  2662.  
  2663.              This is the entry point module for the demonstration program.
  2664.              It contains  the  message  processing  routine that  services
  2665.              messages sent to the  main window. Note, of  course, that the
  2666.              application contains no code at all to service  messages sent
  2667.              to the TextView                    TextView                    TextView window - the DLL handles all of this itself.
  2668.  
  2669.  
  2670.              trace.c             trace.c             trace.c
  2671.  
  2672.              This module contains  the routines  that service most  of the
  2673.              Trace menu items, and the  trace routine itself. This routine
  2674.              is written to  accept a  format string, such  as you  pass to
  2675.              printf, and a variable number of arguments of any type.
  2676.  
  2677.              Also in  this  module  is  the  menu handler  function.  This
  2678.              routine is called  back from  the Windows  DLL to  notify the
  2679.              application when  the user  clicks  an item  in  the  TextView                                                                   TextView                                                                   TextView
  2680.              window's menu.
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.                                      Page                                      Page                                      Page 41                                          41                                          41
  2688.  
  2689.  
  2690.                                  The TextView DLL                                 The TextView DLL                                 The TextView DLL
  2691.  
  2692.  
  2693.              copy.c             copy.c             copy.c
  2694.  
  2695.              This module handles the  Copy Trace Window menu item. It sets
  2696.              up a second  TextView                          TextView                          TextView window and  calls  TVReturnData                                                      TVReturnData                                                      TVReturnData to read
  2697.              the contents of the first.
  2698.  
  2699.  
  2700.              utils.c             utils.c             utils.c
  2701.  
  2702.              This contains a few small utility routines.
  2703.  
  2704.  
  2705.           Building the program          Building the program          Building the program
  2706.  
  2707.           The demonstration  sources  are  written  to  be  compiled  with
  2708.           Microsoft C 6.00A. You may need to  make adjustments if you have
  2709.           a different compiler.
  2710.  
  2711.           The makefile is written for a  UNIX-compatible make program such
  2712.           as  ndmake. If  you  use  the  Microsoft  nmake utility  in  the
  2713.           Programmer's Work Bench you will need to amend it.
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.  
  2735.  
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.                                      Page                                      Page                                      Page 42                                          42                                          42