home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / SAMPLES / TTY / TTY.H_ / TTY.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  5.9 KB  |  188 lines

  1. //---------------------------------------------------------------------------
  2. //
  3. //  Module: tty.h
  4. //
  5. //  Purpose:
  6. //     This is the header file for the TTY sample.
  7. //
  8. //---------------------------------------------------------------------------
  9. //
  10. //  Written by Microsoft Product Support Services, Windows Developer Support.
  11. //  Copyright (c) 1991 Microsoft Corporation.  All Rights Reserved.
  12. //
  13. //---------------------------------------------------------------------------
  14.  
  15. #define WIN31        // this is a Windows 3.1 application
  16. #define USECOMM      // yes, we need the COMM API
  17. #define STRICT       // be bold!
  18.  
  19. #include <windows.h>
  20. #include <commdlg.h>
  21. #include <string.h>
  22.  
  23. #include "version.h"
  24. #include "resource.h"
  25.  
  26. // constant definitions
  27.  
  28. #define GWW_NPTTYINFO       0
  29. #define ABOUTDLG_USEBITMAP  1
  30.  
  31. #define ATOM_TTYINFO       0x100
  32.  
  33. // terminal size
  34.  
  35. #define MAXROWS         25
  36. #define MAXCOLS         80
  37.  
  38. #define MAXBLOCK        80
  39.  
  40. #define MAXLEN_TEMPSTR  81
  41.  
  42. #define RXQUEUE         4096
  43. #define TXQUEUE         4096
  44.  
  45. // cursor states
  46.  
  47. #define CS_HIDE         0x00
  48. #define CS_SHOW         0x01
  49.  
  50. // Flow control flags
  51.  
  52. #define FC_DTRDSR       0x01
  53. #define FC_RTSCTS       0x02
  54. #define FC_XONXOFF      0x04
  55.  
  56. // ascii definitions
  57.  
  58. #define ASCII_BEL       0x07
  59. #define ASCII_BS        0x08
  60. #define ASCII_LF        0x0A
  61. #define ASCII_CR        0x0D
  62. #define ASCII_XON       0x11
  63. #define ASCII_XOFF      0x13
  64.  
  65. // data structures
  66.  
  67. typedef struct tagTTYINFO
  68. {
  69.    int     idComDev ;
  70.    BYTE    bPort, abScreen[ MAXROWS * MAXCOLS ] ;
  71.    BOOL    fConnected, fXonXoff, fLocalEcho, fNewLine, fAutoWrap,
  72.            fUseCNReceive, fDisplayErrors;
  73.    BYTE    bByteSize, bFlowCtrl, bParity, bStopBits ;
  74.    WORD    wBaudRate, wCursorState ;
  75.    HFONT   hTTYFont ;
  76.    LOGFONT lfTTYFont ;
  77.    DWORD   rgbFGColor ;
  78.    int     xSize, ySize, xScroll, yScroll, xOffset, yOffset,
  79.            nColumn, nRow, xChar, yChar ;
  80.  
  81. } TTYINFO, NEAR *NPTTYINFO ;
  82.  
  83. // macros ( for easier readability )
  84.  
  85. #define GETHINST( hWnd )  ((HINSTANCE) GetWindowWord( hWnd, GWW_HINSTANCE ))
  86.  
  87. #define COMDEV( x ) (x -> idComDev)
  88. #define PORT( x )   (x -> bPort)
  89. #define SCREEN( x ) (x -> abScreen)
  90. #define CONNECTED( x ) (x -> fConnected)
  91. #define XONXOFF( x ) (x -> fXonXoff)
  92. #define LOCALECHO( x ) (x -> fLocalEcho)
  93. #define NEWLINE( x ) (x -> fNewLine)
  94. #define AUTOWRAP( x ) (x -> fAutoWrap)
  95. #define BYTESIZE( x ) (x -> bByteSize)
  96. #define FLOWCTRL( x ) (x -> bFlowCtrl)
  97. #define PARITY( x ) (x -> bParity)
  98. #define STOPBITS( x ) (x -> bStopBits)
  99. #define BAUDRATE( x ) (x -> wBaudRate)
  100. #define CURSORSTATE( x ) (x -> wCursorState)
  101. #define HTTYFONT( x ) (x -> hTTYFont)
  102. #define LFTTYFONT( x ) (x -> lfTTYFont)
  103. #define FGCOLOR( x ) (x -> rgbFGColor)
  104. #define XSIZE( x ) (x -> xSize)
  105. #define YSIZE( x ) (x -> ySize)
  106. #define XSCROLL( x ) (x -> xScroll)
  107. #define YSCROLL( x ) (x -> yScroll)
  108. #define XOFFSET( x ) (x -> xOffset)
  109. #define YOFFSET( x ) (x -> yOffset)
  110. #define COLUMN( x ) (x -> nColumn)
  111. #define ROW( x ) (x -> nRow)
  112. #define XCHAR( x ) (x -> xChar)
  113. #define YCHAR( x ) (x -> yChar )
  114. #define USECNRECEIVE( x ) (x -> fUseCNReceive)
  115. #define DISPLAYERRORS( x ) (x -> fDisplayErrors)
  116.  
  117. #define SET_PROP( x, y, z )  SetProp( x, MAKEINTATOM( y ), z )
  118. #define GET_PROP( x, y )     GetProp( x, MAKEINTATOM( y ) )
  119. #define REMOVE_PROP( x, y )  RemoveProp( x, MAKEINTATOM( y ) )
  120.  
  121. // global stuff
  122.  
  123. char     gszTTYClass[] = "TTYWndClass" ;
  124. char     gszAppName[] = "TTY" ;
  125. HANDLE   ghAccel ;
  126. WORD     gawBaudTable[] = { CBR_110,
  127.                             CBR_300,
  128.                             CBR_600,
  129.                             CBR_1200,
  130.                             CBR_2400,
  131.                             CBR_4800,
  132.                             CBR_9600,
  133.                             CBR_14400,
  134.                             CBR_19200,
  135.                             CBR_38400,
  136.                             CBR_56000,
  137.                             CBR_128000,
  138.                             CBR_256000   } ;
  139.  
  140. WORD     gawParityTable[] = { NOPARITY,
  141.                               EVENPARITY,
  142.                               ODDPARITY,
  143.                               MARKPARITY,
  144.                               SPACEPARITY } ;
  145.  
  146. WORD     gawStopBitsTable[] = { ONESTOPBIT,
  147.                                 ONE5STOPBITS,
  148.                                 TWOSTOPBITS } ;
  149.  
  150. // function prototypes (private)
  151.  
  152. BOOL NEAR InitApplication( HANDLE ) ;
  153. HWND NEAR InitInstance( HANDLE, int ) ;
  154. LRESULT NEAR CreateTTYInfo( HWND ) ;
  155. BOOL NEAR DestroyTTYInfo( HWND ) ;
  156. BOOL NEAR ResetTTYScreen( HWND, NPTTYINFO ) ;
  157. BOOL NEAR KillTTYFocus( HWND ) ;
  158. BOOL NEAR PaintTTY( HWND ) ;
  159. BOOL NEAR SetTTYFocus( HWND ) ;
  160. BOOL NEAR ScrollTTYHorz( HWND, WORD, WORD ) ;
  161. BOOL NEAR ScrollTTYVert( HWND, WORD, WORD ) ;
  162. BOOL NEAR SizeTTY( HWND, WORD, WORD ) ;
  163. BOOL NEAR ProcessTTYCharacter( HWND, BYTE ) ;
  164. BOOL NEAR WriteTTYBlock( HWND, LPSTR, int ) ;
  165. int NEAR ReadCommBlock( HWND, LPSTR, int ) ;
  166. BOOL NEAR WriteCommByte( HWND, BYTE ) ;
  167. BOOL NEAR MoveTTYCursor( HWND ) ;
  168. BOOL NEAR OpenConnection( HWND ) ;
  169. BOOL NEAR SetupConnection( HWND ) ;
  170. BOOL NEAR CloseConnection( HWND ) ;
  171. BOOL NEAR ProcessCOMMNotification( HWND, WORD, LONG ) ;
  172. VOID NEAR GoModalDialogBoxParam( HINSTANCE, LPCSTR, HWND, DLGPROC, LPARAM ) ;
  173. VOID NEAR FillComboBox( HINSTANCE, HWND, int, WORD NEAR *, WORD, WORD ) ;
  174. BOOL NEAR SelectTTYFont( HWND ) ;
  175. BOOL NEAR SettingsDlgInit( HWND ) ;
  176. BOOL NEAR SettingsDlgTerm( HWND ) ;
  177.  
  178. // function prototypes (public)
  179.  
  180. LRESULT FAR PASCAL __export TTYWndProc( HWND, UINT, WPARAM, LPARAM ) ;
  181. BOOL FAR PASCAL __export AboutDlgProc( HWND, UINT, WPARAM, LPARAM ) ;
  182. BOOL FAR PASCAL __export SettingsDlgProc( HWND, UINT, WPARAM, LPARAM ) ;
  183.  
  184. //---------------------------------------------------------------------------
  185. //  End of File: tty.h
  186. //---------------------------------------------------------------------------
  187.  
  188.