|
|
1.1.1.3 ! root 1: ! 2: /******************************************************************************\ ! 3: * This is a part of the Microsoft Source Code Samples. ! 4: * Copyright (C) 1993 Microsoft Corporation. ! 5: * All rights reserved. ! 6: * This source code is only intended as a supplement to ! 7: * Microsoft Development Tools and/or WinHelp documentation. ! 8: * See these sources for detailed information regarding the ! 9: * Microsoft samples programs. ! 10: \******************************************************************************/ ! 11: 1.1 root 12: //--------------------------------------------------------------------------- 13: // 14: // Module: tty.c 15: // 16: // Purpose: 17: // The sample application demonstrates the usage of the COMM 18: // API. It implements the new COMM API of Windows 3.1. 19: // 20: // NOTE: no escape sequences are translated, only 21: // the necessary control codes (LF, CR, BS, etc.) 22: // 23: // Description of functions: 24: // Descriptions are contained in the function headers. 25: // 26: //--------------------------------------------------------------------------- 27: // 28: // Written by Microsoft Product Support Services, Windows Developer Support. 29: // Copyright (c) 1991 Microsoft Corporation. All Rights Reserved. 30: // 31: //--------------------------------------------------------------------------- 32: 33: #include "tty.h" 34: 35: //--------------------------------------------------------------------------- 36: // int PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance, 37: // LPSTR lpszCmdLine, int nCmdShow ) 38: // 39: // Description: 40: // This is the main window loop! 41: // 42: // Parameters: 43: // As documented for all WinMain() functions. 44: // 45: // History: Date Author Comment 46: // 5/ 8/91 BryanW Wrote it. 47: // 48: //--------------------------------------------------------------------------- 49: 50: int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, 51: LPSTR lpszCmdLine, int nCmdShow ) 52: { 53: HWND hTTYWnd ; 54: MSG msg ; 55: 56: if (!hPrevInstance) 57: if (!InitApplication( hInstance )) 58: return ( FALSE ) ; 59: 60: if (NULL == (hTTYWnd = InitInstance( hInstance, nCmdShow ))) 61: return ( FALSE ) ; 62: 63: while (GetMessage( &msg, NULL, 0, 0 )) 64: { 65: if (!TranslateAccelerator( hTTYWnd, ghAccel, &msg )) 66: { 67: TranslateMessage( &msg ) ; 68: DispatchMessage( &msg ) ; 69: } 70: } 71: return ( (int) msg.wParam ) ; 72: 73: } // end of WinMain() 74: 75: //--------------------------------------------------------------------------- 76: // BOOL NEAR InitApplication( HANDLE hInstance ) 77: // 78: // Description: 79: // First time initialization stuff. This registers information 80: // such as window classes. 81: // 82: // Parameters: 83: // HANDLE hInstance 84: // Handle to this instance of the application. 85: // 86: // History: Date Author Comment 87: // 5/ 8/91 BryanW Wrote it. 88: // 10/22/91 BryanW Fixed background color problem. 89: // 90: //--------------------------------------------------------------------------- 91: 92: BOOL NEAR InitApplication( HANDLE hInstance ) 93: { 94: WNDCLASS wndclass ; 95: 96: // register tty window class 97: 1.1.1.3 ! root 98: wndclass.style = 0 ; 1.1 root 99: wndclass.lpfnWndProc = TTYWndProc ; 100: wndclass.cbClsExtra = 0 ; 101: wndclass.cbWndExtra = TTYEXTRABYTES ; 102: wndclass.hInstance = hInstance ; 103: wndclass.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE( TTYICON ) ); 104: wndclass.hCursor = LoadCursor( NULL, IDC_ARROW ) ; 105: wndclass.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1) ; 106: wndclass.lpszMenuName = MAKEINTRESOURCE( TTYMENU ) ; 107: wndclass.lpszClassName = gszTTYClass ; 108: 109: return( RegisterClass( &wndclass ) ) ; 110: 111: } // end of InitApplication() 112: 113: //--------------------------------------------------------------------------- 114: // HWND NEAR InitInstance( HANDLE hInstance, int nCmdShow ) 115: // 116: // Description: 117: // Initializes instance specific information. 118: // 119: // Parameters: 120: // HANDLE hInstance 121: // Handle to instance 122: // 123: // int nCmdShow 124: // How do we show the window? 125: // 126: // History: Date Author Comment 127: // 5/ 8/91 BryanW Wrote it. 128: // 129: //--------------------------------------------------------------------------- 130: 131: HWND NEAR InitInstance( HANDLE hInstance, int nCmdShow ) 132: { 133: HWND hTTYWnd ; 134: 135: // load accelerators 136: ghAccel = LoadAccelerators( hInstance, MAKEINTRESOURCE( TTYACCEL ) ) ; 137: 138: // create the TTY window 139: hTTYWnd = CreateWindow( gszTTYClass, gszAppName, 140: WS_OVERLAPPEDWINDOW, 141: CW_USEDEFAULT, CW_USEDEFAULT, 142: CW_USEDEFAULT, CW_USEDEFAULT, 143: NULL, NULL, hInstance, NULL ) ; 144: 145: if (NULL == hTTYWnd) 146: return ( NULL ) ; 147: 148: ShowWindow( hTTYWnd, nCmdShow ) ; 149: UpdateWindow( hTTYWnd ) ; 150: 151: return ( hTTYWnd ) ; 152: 153: } // end of InitInstance() 154: 155: //--------------------------------------------------------------------------- 156: // LRESULT FAR PASCAL TTYWndProc( HWND hWnd, UINT uMsg, 157: // WPARAM wParam, LPARAM lParam ) 158: // 159: // Description: 160: // This is the TTY Window Proc. This handles ALL messages 161: // to the tty window. 162: // 163: // Parameters: 164: // As documented for Window procedures. 165: // 166: // Win-32 Porting Issues: 167: // - WM_HSCROLL and WM_VSCROLL packing is different under Win-32. 168: // - Needed LOWORD() of wParam for WM_CHAR messages. 169: // 170: // History: Date Author Comment 171: // 5/ 9/91 BryanW Wrote it. 172: // 6/15/92 BryanW Kill focus before disconnecting. 173: // 6/15/92 BryanW Ported to Win-32. 174: // 175: //--------------------------------------------------------------------------- 176: 177: LRESULT FAR PASCAL TTYWndProc( HWND hWnd, UINT uMsg, 178: WPARAM wParam, LPARAM lParam ) 179: { 180: switch (uMsg) 181: { 182: case WM_CREATE: 183: return ( CreateTTYInfo( hWnd ) ) ; 184: 185: case WM_COMMAND: 186: { 187: switch ( LOWORD( wParam ) ) 188: { 189: case IDM_CONNECT: 190: if (!OpenConnection( hWnd )) 191: MessageBox( hWnd, "Connection failed.", gszAppName, 192: MB_ICONEXCLAMATION ) ; 193: break ; 194: 195: case IDM_DISCONNECT: 196: KillTTYFocus( hWnd ) ; 197: CloseConnection( hWnd ) ; 198: break ; 199: 200: case IDM_SETTINGS: 201: { 202: NPTTYINFO npTTYInfo ; 203: 204: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 205: return ( FALSE ) ; 206: GoModalDialogBoxParam( GETHINST( hWnd ), 207: MAKEINTRESOURCE( SETTINGSDLGBOX ), hWnd, 1.1.1.3 ! root 208: (DLGPROC) SettingsDlgProc, 1.1 root 209: (LPARAM) (LPSTR) npTTYInfo ) ; 210: 211: // if fConnected, set new COM parameters 212: 213: if (CONNECTED( npTTYInfo )) 214: { 215: if (!SetupConnection( hWnd )) 216: MessageBox( hWnd, "Settings failed!", gszAppName, 217: MB_ICONEXCLAMATION ) ; 218: } 219: } 220: break ; 221: 222: case IDM_ABOUT: 223: GoModalDialogBoxParam ( GETHINST( hWnd ), 224: MAKEINTRESOURCE( ABOUTDLGBOX ), 225: hWnd, 1.1.1.3 ! root 226: (DLGPROC) AboutDlgProc, 0L ) ; 1.1 root 227: break; 228: 229: case IDM_EXIT: 1.1.1.3 ! root 230: PostMessage( hWnd, WM_CLOSE, 0, 0L ) ; 1.1 root 231: break ; 232: } 233: } 234: break ; 235: 236: case WM_COMMNOTIFY: 237: ProcessCOMMNotification( hWnd, wParam, lParam ) ; 238: break ; 239: 240: case WM_PAINT: 241: PaintTTY( hWnd ) ; 242: break ; 243: 244: case WM_SIZE: 245: SizeTTY( hWnd, HIWORD( lParam ), LOWORD( lParam ) ) ; 246: break ; 247: 248: case WM_HSCROLL: 249: #ifdef WIN32 250: ScrollTTYHorz( hWnd, LOWORD( wParam ), HIWORD( wParam ) ) ; 251: #else 252: ScrollTTYHorz( hWnd, (WORD) wParam, LOWORD( lParam ) ) ; 253: #endif 254: break ; 255: 256: case WM_VSCROLL: 257: #ifdef WIN32 258: ScrollTTYVert( hWnd, LOWORD( wParam ), HIWORD( wParam ) ) ; 259: #else 260: ScrollTTYVert( hWnd, (WORD) wParam, LOWORD( lParam ) ) ; 261: #endif 262: break ; 263: 264: case WM_CHAR: 265: #ifdef WIN32 266: ProcessTTYCharacter( hWnd, LOBYTE( LOWORD( wParam ) ) ) ; 267: #else 268: ProcessTTYCharacter( hWnd, LOBYTE( wParam ) ) ; 269: #endif 270: break ; 271: 272: case WM_SETFOCUS: 273: SetTTYFocus( hWnd ) ; 274: break ; 275: 276: case WM_KILLFOCUS: 277: KillTTYFocus( hWnd ) ; 278: break ; 279: 280: case WM_DESTROY: 281: DestroyTTYInfo( hWnd ) ; 282: PostQuitMessage( 0 ) ; 283: break ; 284: 285: case WM_CLOSE: 286: if (IDOK != MessageBox( hWnd, "OK to close window?", "TTY Sample", 287: MB_ICONQUESTION | MB_OKCANCEL )) 288: break ; 289: 290: // fall through 291: 292: default: 293: return( DefWindowProc( hWnd, uMsg, wParam, lParam ) ) ; 294: } 295: return 0L ; 296: 297: } // end of TTYWndProc() 298: 299: //--------------------------------------------------------------------------- 300: // LRESULT NEAR CreateTTYInfo( HWND hWnd ) 301: // 302: // Description: 303: // Creates the tty information structure and sets 304: // menu option availability. Returns -1 if unsuccessful. 305: // 306: // Parameters: 307: // HWND hWnd 308: // Handle to main window. 309: // 310: // Win-32 Porting Issues: 311: // - Needed to initialize TERMWND( npTTYInfo ) for secondary thread. 312: // - Needed to create/initialize overlapped structures used in reads & 313: // writes to COMM device. 314: // 315: // History: Date Author Comment 316: // 10/18/91 BryanW Pulled from tty window proc. 317: // 1/13/92 BryanW Fixed bug with invalid handle 318: // caused by WM_SIZE sent by 319: // ResetTTYScreen(). 320: // 321: //--------------------------------------------------------------------------- 322: 323: LRESULT NEAR CreateTTYInfo( HWND hWnd ) 324: { 325: HMENU hMenu ; 326: NPTTYINFO npTTYInfo ; 327: 328: if (NULL == (npTTYInfo = 329: (NPTTYINFO) LocalAlloc( LPTR, sizeof( TTYINFO ) ))) 330: return ( (LRESULT) -1 ) ; 331: 332: // initialize TTY info structure 333: 334: COMDEV( npTTYInfo ) = 0 ; 335: CONNECTED( npTTYInfo ) = FALSE ; 336: CURSORSTATE( npTTYInfo ) = CS_HIDE ; 337: LOCALECHO( npTTYInfo ) = FALSE ; 338: AUTOWRAP( npTTYInfo ) = TRUE ; 339: PORT( npTTYInfo ) = 1 ; 340: BAUDRATE( npTTYInfo ) = CBR_9600 ; 341: BYTESIZE( npTTYInfo ) = 8 ; 342: FLOWCTRL( npTTYInfo ) = FC_RTSCTS ; 343: PARITY( npTTYInfo ) = NOPARITY ; 344: STOPBITS( npTTYInfo ) = ONESTOPBIT ; 345: XONXOFF( npTTYInfo ) = FALSE ; 346: XSIZE( npTTYInfo ) = 0 ; 347: YSIZE( npTTYInfo ) = 0 ; 348: XSCROLL( npTTYInfo ) = 0 ; 349: YSCROLL( npTTYInfo ) = 0 ; 350: XOFFSET( npTTYInfo ) = 0 ; 351: YOFFSET( npTTYInfo ) = 0 ; 352: COLUMN( npTTYInfo ) = 0 ; 353: ROW( npTTYInfo ) = 0 ; 354: HTTYFONT( npTTYInfo ) = NULL ; 355: FGCOLOR( npTTYInfo ) = RGB( 0, 0, 0 ) ; 356: USECNRECEIVE( npTTYInfo ) = TRUE ; 357: DISPLAYERRORS( npTTYInfo ) = TRUE ; 358: #ifdef WIN32 359: TERMWND( npTTYInfo ) = hWnd ; 360: 361: // create I/O event used for overlapped reads / writes 362: 363: READ_OS( npTTYInfo ).hEvent = CreateEvent( NULL, // no security 364: TRUE, // explicit reset req 365: FALSE, // initial event reset 366: NULL ) ; // no name 367: if (READ_OS( npTTYInfo ).hEvent == NULL) 368: { 369: LocalFree( npTTYInfo ) ; 370: return ( -1 ) ; 371: } 372: WRITE_OS( npTTYInfo ).hEvent = CreateEvent( NULL, // no security 373: TRUE, // explicit reset req 374: FALSE, // initial event reset 375: NULL ) ; // no name 376: if (NULL == WRITE_OS( npTTYInfo ).hEvent) 377: { 378: CloseHandle( READ_OS( npTTYInfo ).hEvent ) ; 379: LocalFree( npTTYInfo ) ; 380: return ( -1 ) ; 381: } 382: 383: // create "posted notification" event 384: 385: POSTEVENT( npTTYInfo ) = CreateEvent( NULL, // no security 386: TRUE, // manual reset 387: TRUE, // initial event is set 388: NULL ) ; // no name 389: 390: if (POSTEVENT( npTTYInfo ) == NULL) 391: { 392: CloseHandle( READ_OS( npTTYInfo ).hEvent ) ; 393: CloseHandle( WRITE_OS( npTTYInfo ).hEvent ) ; 394: LocalFree( npTTYInfo ) ; 395: return ( -1 ) ; 396: } 397: #endif 398: 399: // clear screen space 400: 401: _fmemset( SCREEN( npTTYInfo ), ' ', MAXROWS * MAXCOLS ) ; 402: 403: // setup default font information 404: 1.1.1.3 ! root 405: LFTTYFONT( npTTYInfo ).lfHeight = 9 ; 1.1 root 406: LFTTYFONT( npTTYInfo ).lfWidth = 0 ; 407: LFTTYFONT( npTTYInfo ).lfEscapement = 0 ; 408: LFTTYFONT( npTTYInfo ).lfOrientation = 0 ; 409: LFTTYFONT( npTTYInfo ).lfWeight = 0 ; 410: LFTTYFONT( npTTYInfo ).lfItalic = 0 ; 411: LFTTYFONT( npTTYInfo ).lfUnderline = 0 ; 412: LFTTYFONT( npTTYInfo ).lfStrikeOut = 0 ; 413: LFTTYFONT( npTTYInfo ).lfCharSet = OEM_CHARSET ; 414: LFTTYFONT( npTTYInfo ).lfOutPrecision = OUT_DEFAULT_PRECIS ; 415: LFTTYFONT( npTTYInfo ).lfClipPrecision = CLIP_DEFAULT_PRECIS ; 416: LFTTYFONT( npTTYInfo ).lfQuality = DEFAULT_QUALITY ; 417: LFTTYFONT( npTTYInfo ).lfPitchAndFamily = FIXED_PITCH | FF_MODERN ; 1.1.1.3 ! root 418: lstrcpy( LFTTYFONT( npTTYInfo ).lfFaceName, "FixedSys" ) ; 1.1 root 419: 420: // set TTYInfo handle before any further message processing. 421: 422: SETNPTTYINFO( hWnd, npTTYInfo ) ; 423: 424: // reset the character information, etc. 425: 426: ResetTTYScreen( hWnd, npTTYInfo ) ; 427: 428: hMenu = GetMenu( hWnd ) ; 429: EnableMenuItem( hMenu, IDM_DISCONNECT, 430: MF_GRAYED | MF_DISABLED | MF_BYCOMMAND ) ; 431: EnableMenuItem( hMenu, IDM_CONNECT, MF_ENABLED | MF_BYCOMMAND ) ; 432: 433: return ( (LRESULT) TRUE ) ; 434: 435: } // end of CreateTTYInfo() 436: 437: //--------------------------------------------------------------------------- 438: // BOOL NEAR DestroyTTYInfo( HWND hWnd ) 439: // 440: // Description: 441: // Destroys block associated with TTY window handle. 442: // 443: // Parameters: 444: // HWND hWnd 445: // handle to TTY window 446: // 447: // Win-32 Porting Issues: 448: // - Needed to clean up event objects created during initialization. 449: // 450: // History: Date Author Comment 451: // 5/ 8/91 BryanW Wrote it. 452: // 6/15/92 BryanW Ported to Win-32. 453: // 454: //--------------------------------------------------------------------------- 455: 456: BOOL NEAR DestroyTTYInfo( HWND hWnd ) 457: { 458: NPTTYINFO npTTYInfo ; 459: 460: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 461: return ( FALSE ) ; 462: 463: // force connection closed (if not already closed) 464: 465: if (CONNECTED( npTTYInfo )) 466: CloseConnection( hWnd ) ; 467: 468: #ifdef WIN32 469: // clean up event objects 470: 471: CloseHandle( READ_OS( npTTYInfo ).hEvent ) ; 472: CloseHandle( WRITE_OS( npTTYInfo ).hEvent ) ; 473: CloseHandle( POSTEVENT( npTTYInfo ) ) ; 474: #endif 475: 476: DeleteObject( HTTYFONT( npTTYInfo ) ) ; 477: 478: LocalFree( npTTYInfo ) ; 479: return ( TRUE ) ; 480: 481: } // end of DestroyTTYInfo() 482: 483: //--------------------------------------------------------------------------- 484: // BOOL NEAR ResetTTYScreen( HWND hWnd, NPTTYINFO npTTYInfo ) 485: // 486: // Description: 487: // Resets the TTY character information and causes the 488: // screen to resize to update the scroll information. 489: // 490: // Parameters: 491: // NPTTYINFO npTTYInfo 492: // pointer to TTY info structure 493: // 494: // History: Date Author Comment 495: // 10/20/91 BryanW Wrote it. 496: // 497: //--------------------------------------------------------------------------- 498: 499: BOOL NEAR ResetTTYScreen( HWND hWnd, NPTTYINFO npTTYInfo ) 500: { 501: HDC hDC ; 502: TEXTMETRIC tm ; 503: RECT rcWindow ; 504: 505: if (NULL == npTTYInfo) 506: return ( FALSE ) ; 507: 508: if (NULL != HTTYFONT( npTTYInfo )) 509: DeleteObject( HTTYFONT( npTTYInfo ) ) ; 510: 511: HTTYFONT( npTTYInfo ) = CreateFontIndirect( &LFTTYFONT( npTTYInfo ) ) ; 512: 513: hDC = GetDC( hWnd ) ; 514: SelectObject( hDC, HTTYFONT( npTTYInfo ) ) ; 515: GetTextMetrics( hDC, &tm ) ; 516: ReleaseDC( hWnd, hDC ) ; 517: 518: XCHAR( npTTYInfo ) = tm.tmAveCharWidth ; 519: YCHAR( npTTYInfo ) = tm.tmHeight + tm.tmExternalLeading ; 520: 521: // a slimy hack to force the scroll position, region to 522: // be recalculated based on the new character sizes 523: 524: GetWindowRect( hWnd, &rcWindow ) ; 525: SendMessage( hWnd, WM_SIZE, SIZENORMAL, 526: (LPARAM) MAKELONG( rcWindow.right - rcWindow.left, 527: rcWindow.bottom - rcWindow.top ) ) ; 528: 529: return ( TRUE ) ; 530: 531: } // end of ResetTTYScreen() 532: 533: //--------------------------------------------------------------------------- 534: // BOOL NEAR PaintTTY( HWND hWnd ) 535: // 536: // Description: 537: // Paints the rectangle determined by the paint struct of 538: // the DC. 539: // 540: // Parameters: 541: // HWND hWnd 542: // handle to TTY window (as always) 543: // 544: // History: Date Author Comment 545: // 5/ 9/91 BryanW Wrote it. 546: // 10/22/91 BryanW Problem with background color 547: // and "off by one" fixed. 548: // 549: // 2/25/92 BryanW Off-by-one not quite fixed... 550: // also resolved min/max problem 551: // for windows extended beyond 552: // the "TTY display". 553: // 554: //--------------------------------------------------------------------------- 555: 556: BOOL NEAR PaintTTY( HWND hWnd ) 557: { 558: int nRow, nCol, nEndRow, nEndCol, nCount, nHorzPos, nVertPos ; 559: HDC hDC ; 560: HFONT hOldFont ; 561: NPTTYINFO npTTYInfo ; 562: PAINTSTRUCT ps ; 563: RECT rect ; 564: 565: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 566: return ( FALSE ) ; 567: 568: hDC = BeginPaint( hWnd, &ps ) ; 569: hOldFont = SelectObject( hDC, HTTYFONT( npTTYInfo ) ) ; 570: SetTextColor( hDC, FGCOLOR( npTTYInfo ) ) ; 571: SetBkColor( hDC, GetSysColor( COLOR_WINDOW ) ) ; 572: rect = ps.rcPaint ; 573: nRow = 574: min( MAXROWS - 1, 575: max( 0, (rect.top + YOFFSET( npTTYInfo )) / YCHAR( npTTYInfo ) ) ) ; 576: nEndRow = 577: min( MAXROWS - 1, 578: ((rect.bottom + YOFFSET( npTTYInfo ) - 1) / YCHAR( npTTYInfo ) ) ) ; 579: nCol = 580: min( MAXCOLS - 1, 581: max( 0, (rect.left + XOFFSET( npTTYInfo )) / XCHAR( npTTYInfo ) ) ) ; 582: nEndCol = 583: min( MAXCOLS - 1, 584: ((rect.right + XOFFSET( npTTYInfo ) - 1) / XCHAR( npTTYInfo ) ) ) ; 585: nCount = nEndCol - nCol + 1 ; 586: for (; nRow <= nEndRow; nRow++) 587: { 588: nVertPos = (nRow * YCHAR( npTTYInfo )) - YOFFSET( npTTYInfo ) ; 589: nHorzPos = (nCol * XCHAR( npTTYInfo )) - XOFFSET( npTTYInfo ) ; 590: rect.top = nVertPos ; 591: rect.bottom = nVertPos + YCHAR( npTTYInfo ) ; 592: rect.left = nHorzPos ; 593: rect.right = nHorzPos + XCHAR( npTTYInfo ) * nCount ; 594: SetBkMode( hDC, OPAQUE ) ; 595: ExtTextOut( hDC, nHorzPos, nVertPos, ETO_OPAQUE | ETO_CLIPPED, &rect, 596: (LPSTR)( SCREEN( npTTYInfo ) + nRow * MAXCOLS + nCol ), 597: nCount, NULL ) ; 598: } 599: SelectObject( hDC, hOldFont ) ; 600: EndPaint( hWnd, &ps ) ; 601: MoveTTYCursor( hWnd ) ; 602: return ( TRUE ) ; 603: 604: } // end of PaintTTY() 605: 606: //--------------------------------------------------------------------------- 607: // BOOL NEAR SizeTTY( HWND hWnd, WORD wVertSize, WORD wHorzSize ) 608: // 609: // Description: 610: // Sizes TTY and sets up scrolling regions. 611: // 612: // Parameters: 613: // HWND hWnd 614: // handle to TTY window 615: // 616: // WORD wVertSize 617: // new vertical size 618: // 619: // WORD wHorzSize 620: // new horizontal size 621: // 622: // History: Date Author Comment 623: // 5/ 8/ 91 BryanW Wrote it 624: // 625: //--------------------------------------------------------------------------- 626: 627: BOOL NEAR SizeTTY( HWND hWnd, WORD wVertSize, WORD wHorzSize ) 628: { 629: int nScrollAmt ; 630: NPTTYINFO npTTYInfo ; 631: 632: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 633: return ( FALSE ) ; 634: 635: YSIZE( npTTYInfo ) = (int) wVertSize ; 636: YSCROLL( npTTYInfo ) = max( 0, (MAXROWS * YCHAR( npTTYInfo )) - 637: YSIZE( npTTYInfo ) ) ; 638: nScrollAmt = min( YSCROLL( npTTYInfo ), YOFFSET( npTTYInfo ) ) - 639: YOFFSET( npTTYInfo ) ; 640: ScrollWindow( hWnd, 0, -nScrollAmt, NULL, NULL ) ; 641: 642: YOFFSET( npTTYInfo ) = YOFFSET( npTTYInfo ) + nScrollAmt ; 643: SetScrollPos( hWnd, SB_VERT, YOFFSET( npTTYInfo ), FALSE ) ; 644: SetScrollRange( hWnd, SB_VERT, 0, YSCROLL( npTTYInfo ), TRUE ) ; 645: 646: XSIZE( npTTYInfo ) = (int) wHorzSize ; 647: XSCROLL( npTTYInfo ) = max( 0, (MAXCOLS * XCHAR( npTTYInfo )) - 648: XSIZE( npTTYInfo ) ) ; 649: nScrollAmt = min( XSCROLL( npTTYInfo ), XOFFSET( npTTYInfo )) - 650: XOFFSET( npTTYInfo ) ; 651: ScrollWindow( hWnd, 0, -nScrollAmt, NULL, NULL ) ; 652: XOFFSET( npTTYInfo ) = XOFFSET( npTTYInfo ) + nScrollAmt ; 653: SetScrollPos( hWnd, SB_HORZ, XOFFSET( npTTYInfo ), FALSE ) ; 654: SetScrollRange( hWnd, SB_HORZ, 0, XSCROLL( npTTYInfo ), TRUE ) ; 655: 656: InvalidateRect( hWnd, NULL, TRUE ) ; 657: 658: return ( TRUE ) ; 659: 660: } // end of SizeTTY() 661: 662: //--------------------------------------------------------------------------- 663: // BOOL NEAR ScrollTTYVert( HWND hWnd, WORD wScrollCmd, WORD wScrollPos ) 664: // 665: // Description: 666: // Scrolls TTY window vertically. 667: // 668: // Parameters: 669: // HWND hWnd 670: // handle to TTY window 671: // 672: // WORD wScrollCmd 673: // type of scrolling we're doing 674: // 675: // WORD wScrollPos 676: // scroll position 677: // 678: // History: Date Author Comment 679: // 5/ 8/91 BryanW Wrote it. 680: // 681: //--------------------------------------------------------------------------- 682: 683: BOOL NEAR ScrollTTYVert( HWND hWnd, WORD wScrollCmd, WORD wScrollPos ) 684: { 685: int nScrollAmt ; 686: NPTTYINFO npTTYInfo ; 687: 688: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 689: return ( FALSE ) ; 690: 691: switch (wScrollCmd) 692: { 693: case SB_TOP: 694: nScrollAmt = -YOFFSET( npTTYInfo ) ; 695: break ; 696: 697: case SB_BOTTOM: 698: nScrollAmt = YSCROLL( npTTYInfo ) - YOFFSET( npTTYInfo ) ; 699: break ; 700: 701: case SB_PAGEUP: 702: nScrollAmt = -YSIZE( npTTYInfo ) ; 703: break ; 704: 705: case SB_PAGEDOWN: 706: nScrollAmt = YSIZE( npTTYInfo ) ; 707: break ; 708: 709: case SB_LINEUP: 710: nScrollAmt = -YCHAR( npTTYInfo ) ; 711: break ; 712: 713: case SB_LINEDOWN: 714: nScrollAmt = YCHAR( npTTYInfo ) ; 715: break ; 716: 717: case SB_THUMBPOSITION: 718: nScrollAmt = wScrollPos - YOFFSET( npTTYInfo ) ; 719: break ; 720: 721: default: 722: return ( FALSE ) ; 723: } 724: if ((YOFFSET( npTTYInfo ) + nScrollAmt) > YSCROLL( npTTYInfo )) 725: nScrollAmt = YSCROLL( npTTYInfo ) - YOFFSET( npTTYInfo ) ; 726: if ((YOFFSET( npTTYInfo ) + nScrollAmt) < 0) 727: nScrollAmt = -YOFFSET( npTTYInfo ) ; 728: ScrollWindow( hWnd, 0, -nScrollAmt, NULL, NULL ) ; 729: YOFFSET( npTTYInfo ) = YOFFSET( npTTYInfo ) + nScrollAmt ; 730: SetScrollPos( hWnd, SB_VERT, YOFFSET( npTTYInfo ), TRUE ) ; 731: 732: return ( TRUE ) ; 733: 734: } // end of ScrollTTYVert() 735: 736: //--------------------------------------------------------------------------- 737: // BOOL NEAR ScrollTTYHorz( HWND hWnd, WORD wScrollCmd, WORD wScrollPos ) 738: // 739: // Description: 740: // Scrolls TTY window horizontally. 741: // 742: // Parameters: 743: // HWND hWnd 744: // handle to TTY window 745: // 746: // WORD wScrollCmd 747: // type of scrolling we're doing 748: // 749: // WORD wScrollPos 750: // scroll position 751: // 752: // History: Date Author Comment 753: // 5/ 8/91 BryanW Wrote it. 754: // 755: //--------------------------------------------------------------------------- 756: 757: BOOL NEAR ScrollTTYHorz( HWND hWnd, WORD wScrollCmd, WORD wScrollPos ) 758: { 759: int nScrollAmt ; 760: NPTTYINFO npTTYInfo ; 761: 762: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 763: return ( FALSE ) ; 764: 765: switch (wScrollCmd) 766: { 767: case SB_TOP: 768: nScrollAmt = -XOFFSET( npTTYInfo ) ; 769: break ; 770: 771: case SB_BOTTOM: 772: nScrollAmt = XSCROLL( npTTYInfo ) - XOFFSET( npTTYInfo ) ; 773: break ; 774: 775: case SB_PAGEUP: 776: nScrollAmt = -XSIZE( npTTYInfo ) ; 777: break ; 778: 779: case SB_PAGEDOWN: 780: nScrollAmt = XSIZE( npTTYInfo ) ; 781: break ; 782: 783: case SB_LINEUP: 784: nScrollAmt = -XCHAR( npTTYInfo ) ; 785: break ; 786: 787: case SB_LINEDOWN: 788: nScrollAmt = XCHAR( npTTYInfo ) ; 789: break ; 790: 791: case SB_THUMBPOSITION: 792: nScrollAmt = wScrollPos - XOFFSET( npTTYInfo ) ; 793: break ; 794: 795: default: 796: return ( FALSE ) ; 797: } 798: if ((XOFFSET( npTTYInfo ) + nScrollAmt) > XSCROLL( npTTYInfo )) 799: nScrollAmt = XSCROLL( npTTYInfo ) - XOFFSET( npTTYInfo ) ; 800: if ((XOFFSET( npTTYInfo ) + nScrollAmt) < 0) 801: nScrollAmt = -XOFFSET( npTTYInfo ) ; 802: ScrollWindow( hWnd, -nScrollAmt, 0, NULL, NULL ) ; 803: XOFFSET( npTTYInfo ) = XOFFSET( npTTYInfo ) + nScrollAmt ; 804: SetScrollPos( hWnd, SB_HORZ, XOFFSET( npTTYInfo ), TRUE ) ; 805: 806: return ( TRUE ) ; 807: 808: } // end of ScrollTTYHorz() 809: 810: //--------------------------------------------------------------------------- 811: // BOOL NEAR SetTTYFocus( HWND hWnd ) 812: // 813: // Description: 814: // Sets the focus to the TTY window also creates caret. 815: // 816: // Parameters: 817: // HWND hWnd 818: // handle to TTY window 819: // 820: // History: Date Author Comment 821: // 5/ 9/91 BryanW Wrote it. 822: // 823: //--------------------------------------------------------------------------- 824: 825: BOOL NEAR SetTTYFocus( HWND hWnd ) 826: { 827: NPTTYINFO npTTYInfo ; 828: 829: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 830: return ( FALSE ) ; 831: 832: if (CONNECTED( npTTYInfo ) && (CURSORSTATE( npTTYInfo ) != CS_SHOW)) 833: { 834: CreateCaret( hWnd, NULL, XCHAR( npTTYInfo ), YCHAR( npTTYInfo ) ) ; 835: ShowCaret( hWnd ) ; 836: CURSORSTATE( npTTYInfo ) = CS_SHOW ; 837: } 838: MoveTTYCursor( hWnd ) ; 839: return ( TRUE ) ; 840: 841: } // end of SetTTYFocus() 842: 843: //--------------------------------------------------------------------------- 844: // BOOL NEAR KillTTYFocus( HWND hWnd ) 845: // 846: // Description: 847: // Kills TTY focus and destroys the caret. 848: // 849: // Parameters: 850: // HWND hWnd 851: // handle to TTY window 852: // 853: // History: Date Author Comment 854: // 5/ 9/91 BryanW Wrote it. 855: // 856: //--------------------------------------------------------------------------- 857: 858: BOOL NEAR KillTTYFocus( HWND hWnd ) 859: { 860: NPTTYINFO npTTYInfo ; 861: 862: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 863: return ( FALSE ) ; 864: 865: if (CONNECTED( npTTYInfo ) && (CURSORSTATE( npTTYInfo ) != CS_HIDE)) 866: { 867: HideCaret( hWnd ) ; 868: DestroyCaret() ; 869: CURSORSTATE( npTTYInfo ) = CS_HIDE ; 870: } 871: return ( TRUE ) ; 872: 873: } // end of KillTTYFocus() 874: 875: //--------------------------------------------------------------------------- 876: // BOOL NEAR MoveTTYCursor( HWND hWnd ) 877: // 878: // Description: 879: // Moves caret to current position. 880: // 881: // Parameters: 882: // HWND hWnd 883: // handle to TTY window 884: // 885: // History: Date Author Comment 886: // 5/ 9/91 BryanW Wrote it. 887: // 888: //--------------------------------------------------------------------------- 889: 890: BOOL NEAR MoveTTYCursor( HWND hWnd ) 891: { 892: NPTTYINFO npTTYInfo ; 893: 894: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 895: return ( FALSE ) ; 896: 897: if (CONNECTED( npTTYInfo ) && (CURSORSTATE( npTTYInfo ) & CS_SHOW)) 898: SetCaretPos( (COLUMN( npTTYInfo ) * XCHAR( npTTYInfo )) - 899: XOFFSET( npTTYInfo ), 900: (ROW( npTTYInfo ) * YCHAR( npTTYInfo )) - 901: YOFFSET( npTTYInfo ) ) ; 902: 903: return ( TRUE ) ; 904: 905: } // end of MoveTTYCursor() 906: 907: //--------------------------------------------------------------------------- 908: // BOOL NEAR ProcessCOMMNotification( HWND hWnd, 909: // WPARAM wParam, LPARAM lParam ) ; 910: // 911: // Description: 912: // Processes the WM_COMMNOTIFY message from the COMM.DRV. 913: // 914: // Parameters: 915: // HWND hWnd 916: // handle to TTY window 917: // 918: // WPARAM wParam 919: // specifes the device (nCid) 920: // 921: // LPARAM lParam 922: // LOWORD contains event trigger 923: // HIWORD is NULL 924: // 925: // Win-32 Porting Issues: 926: // - Function was constrained by WORD and LONG declarations. 927: // - Processing under Win-32 is much simpler and additionally 928: // requires the "posted message" flag to be cleared. 929: // 930: // History: Date Author Comment 931: // 5/10/91 BryanW Wrote it. 932: // 10/18/91 BryanW Updated to verify the event. 933: // 6/15/92 BryanW Removed WORD and LONG constraints. 934: // 6/15/92 BryanW Ported to Win-32. 935: // 936: //--------------------------------------------------------------------------- 937: 938: BOOL NEAR ProcessCOMMNotification( HWND hWnd, WPARAM wParam, LPARAM lParam ) 939: { 940: int nLength ; 941: BYTE abIn[ MAXBLOCK + 1] ; 942: NPTTYINFO npTTYInfo ; 943: MSG msg ; 944: 945: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 946: return ( FALSE ) ; 947: 1.1.1.3 ! root 948: if (!CONNECTED( npTTYInfo )) ! 949: return ( FALSE ) ; ! 950: 1.1 root 951: #ifdef WIN32 952: // verify that it is a COMM event sent by our thread 953: 954: if (CN_EVENT & LOWORD( lParam ) != CN_EVENT) 955: return ( FALSE ) ; 956: 957: // We loop here since it is highly likely that the buffer 958: // can been filled while we are reading this block. This 959: // is especially true when operating at high baud rates 960: // (e.g. >= 9600 baud). 961: 962: do 963: { 964: if (nLength = ReadCommBlock( hWnd, (LPSTR) abIn, MAXBLOCK )) 965: { 966: WriteTTYBlock( hWnd, (LPSTR) abIn, nLength ) ; 967: 968: // force a paint 969: 970: UpdateWindow( hWnd ) ; 971: } 972: } 973: while (!PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE) || (nLength > 0)) ; 974: 975: // clear our "posted notification" flag 976: 977: SetEvent( POSTEVENT( npTTYInfo ) ) ; 978: #else 979: if (!USECNRECEIVE( npTTYInfo )) 980: { 981: // verify that it is a COMM event specified by our mask 982: 983: if (CN_EVENT & LOWORD( lParam ) != CN_EVENT) 984: return ( FALSE ) ; 985: 986: // For Windows 3.1, rested reset the event word so we are notified 987: // when the next event occurs 988: 989: GetCommEventMask( COMDEV( npTTYInfo ), EV_RXCHAR ) ; 990: 991: // We loop here since it is highly likely that the buffer 992: // can been filled while we are reading this block. This 993: // is especially true when operating at high baud rates 994: // (e.g. >= 9600 baud). 995: 996: do 997: { 998: if (nLength = ReadCommBlock( hWnd, (LPSTR) abIn, MAXBLOCK )) 999: { 1000: WriteTTYBlock( hWnd, (LPSTR) abIn, nLength ) ; 1001: 1002: // force a paint 1003: 1004: UpdateWindow( hWnd ) ; 1005: } 1006: } 1007: while (!PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE) || (nLength > 0)) ; 1008: } 1009: else 1010: { 1011: // verify that it is a receive event 1012: 1013: if (CN_RECEIVE & LOWORD( lParam ) != CN_RECEIVE) 1014: return ( FALSE ) ; 1015: 1016: do 1017: { 1018: if (nLength = ReadCommBlock( hWnd, (LPSTR) abIn, MAXBLOCK )) 1019: { 1020: WriteTTYBlock( hWnd, (LPSTR) abIn, nLength ) ; 1021: 1022: // force a paint 1023: 1024: UpdateWindow( hWnd ) ; 1025: } 1026: } 1027: while ((!PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE )) || 1028: (ComStat.cbInQue >= MAXBLOCK)) ; 1029: } 1030: #endif 1031: 1032: return ( TRUE ) ; 1033: 1034: } // end of ProcessCOMMNotification() 1035: 1036: //--------------------------------------------------------------------------- 1037: // BOOL NEAR ProcessTTYCharacter( HWND hWnd, BYTE bOut ) 1038: // 1039: // Description: 1040: // This simply writes a character to the port and echos it 1041: // to the TTY screen if fLocalEcho is set. Some minor 1042: // keyboard mapping could be performed here. 1043: // 1044: // Parameters: 1045: // HWND hWnd 1046: // handle to TTY window 1047: // 1048: // BYTE bOut 1049: // byte from keyboard 1050: // 1051: // History: Date Author Comment 1052: // 5/11/91 BryanW Wrote it. 1053: // 1054: //--------------------------------------------------------------------------- 1055: 1056: BOOL NEAR ProcessTTYCharacter( HWND hWnd, BYTE bOut ) 1057: { 1058: NPTTYINFO npTTYInfo ; 1059: 1060: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 1061: return ( FALSE ) ; 1062: 1063: if (!CONNECTED( npTTYInfo )) 1064: return ( FALSE ) ; 1065: 1066: WriteCommByte( hWnd, bOut ) ; 1067: if (LOCALECHO( npTTYInfo )) 1068: WriteTTYBlock( hWnd, &bOut, 1 ) ; 1069: 1070: return ( TRUE ) ; 1071: 1072: } // end of ProcessTTYCharacter() 1073: 1074: //--------------------------------------------------------------------------- 1075: // BOOL NEAR OpenConnection( HWND hWnd ) 1076: // 1077: // Description: 1078: // Opens communication port specified in the TTYINFO struct. 1079: // It also sets the CommState and notifies the window via 1080: // the fConnected flag in the TTYINFO struct. 1081: // 1082: // Parameters: 1083: // HWND hWnd 1084: // handle to TTY window 1085: // 1086: // Win-32 Porting Issues: 1.1.1.3 ! root 1087: // - OpenComm() is not supported under Win-32. Use CreateFile() 1.1 root 1088: // and setup for OVERLAPPED_IO. 1089: // - Win-32 has specific communication timeout parameters. 1090: // - Created the secondary thread for event notification. 1091: // 1092: // History: Date Author Comment 1093: // 5/ 9/91 BryanW Wrote it. 1094: // 1095: //--------------------------------------------------------------------------- 1096: 1097: BOOL NEAR OpenConnection( HWND hWnd ) 1.1.1.3 ! root 1098: { ! 1099: char szPort[ 15 ], szTemp[ 10 ] ; 1.1 root 1100: BOOL fRetVal ; 1101: HCURSOR hOldCursor, hWaitCursor ; 1102: HMENU hMenu ; 1103: NPTTYINFO npTTYInfo ; 1104: 1105: #ifdef WIN32 1106: HANDLE hCommWatchThread ; 1107: DWORD dwThreadID ; 1108: COMMTIMEOUTS CommTimeOuts ; 1109: #endif 1110: 1111: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 1112: return ( FALSE ) ; 1113: 1114: // show the hourglass cursor 1115: hWaitCursor = LoadCursor( NULL, IDC_WAIT ) ; 1116: hOldCursor = SetCursor( hWaitCursor ) ; 1117: 1.1.1.3 ! root 1118: #ifdef WIN32 ! 1119: // HACK! This checks for the PORT number defined by ! 1120: // the combo box selection. If it is greater than the ! 1121: // maximum number of ports, assume TELNET. ! 1122: ! 1123: if (PORT( npTTYInfo ) > MAXPORTS) ! 1124: lstrcpy( szPort, "\\\\.\\TELNET" ) ; ! 1125: else ! 1126: { ! 1127: // load the COM prefix string and append port number ! 1128: ! 1129: LoadString( GETHINST( hWnd ), IDS_COMPREFIX, szTemp, sizeof( szTemp ) ) ; ! 1130: wsprintf( szPort, "%s%d", (LPSTR) szTemp, PORT( npTTYInfo ) ) ; ! 1131: } ! 1132: #else 1.1 root 1133: // load the COM prefix string and append port number 1134: 1135: LoadString( GETHINST( hWnd ), IDS_COMPREFIX, szTemp, sizeof( szTemp ) ) ; 1136: wsprintf( szPort, "%s%d", (LPSTR) szTemp, PORT( npTTYInfo ) ) ; 1.1.1.3 ! root 1137: #endif 1.1 root 1138: 1139: // open COMM device 1140: 1141: #ifdef WIN32 1142: if ((COMDEV( npTTYInfo ) = 1143: CreateFile( szPort, GENERIC_READ | GENERIC_WRITE, 1144: 0, // exclusive access 1145: NULL, // no security attrs 1146: OPEN_EXISTING, 1.1.1.3 ! root 1147: FILE_ATTRIBUTE_NORMAL | 1.1 root 1148: FILE_FLAG_OVERLAPPED, // overlapped I/O 1149: NULL )) == (HANDLE) -1 ) 1150: return ( FALSE ) ; 1151: else 1152: { 1.1.1.3 ! root 1153: // get any early notifications ! 1154: ! 1155: SetCommMask( COMDEV( npTTYInfo ), EV_RXCHAR ) ; ! 1156: ! 1157: // setup device buffers ! 1158: ! 1159: SetupComm( COMDEV( npTTYInfo ), 4096, 4096 ) ; ! 1160: 1.1 root 1161: // purge any information in the buffer 1162: 1.1.1.3 ! root 1163: // HACK! HACK! Not really needed... the buffers are allocated ! 1164: // and clear. If TELNET is active, the buffer will contain ! 1165: // immediate data. ! 1166: ! 1167: // PurgeComm( COMDEV( npTTYInfo ), PURGE_TXABORT | PURGE_RXABORT | ! 1168: // PURGE_TXCLEAR | PURGE_RXCLEAR ) ; 1.1 root 1169: 1170: // set up for overlapped non-blocking I/O 1171: 1172: CommTimeOuts.ReadIntervalTimeout = 0xFFFFFFFF ; 1173: CommTimeOuts.ReadTotalTimeoutMultiplier = 0 ; 1174: CommTimeOuts.ReadTotalTimeoutConstant = 0 ; 1175: CommTimeOuts.WriteTotalTimeoutMultiplier = 0 ; 1.1.1.3 ! root 1176: CommTimeOuts.WriteTotalTimeoutConstant = 5000 ; 1.1 root 1177: SetCommTimeouts( COMDEV( npTTYInfo ), &CommTimeOuts ) ; 1178: } 1179: #else 1180: if ((COMDEV( npTTYInfo ) = OpenComm( szPort, RXQUEUE, TXQUEUE )) < 0) 1181: return ( FALSE ) ; 1182: #endif 1183: 1184: fRetVal = SetupConnection( hWnd ) ; 1185: 1186: if (fRetVal) 1187: { 1188: CONNECTED( npTTYInfo ) = TRUE ; 1189: 1190: #ifdef WIN32 1191: // In the case of Win32, we create a secondary thread 1192: // to watch for an event. 1193: 1194: if (NULL == (hCommWatchThread = 1195: CreateThread( (LPSECURITY_ATTRIBUTES) NULL, 1196: 0, 1197: (LPTHREAD_START_ROUTINE) CommWatchProc, 1198: (LPVOID) npTTYInfo, 1.1.1.3 ! root 1199: 0, &dwThreadID ))) 1.1 root 1200: { 1201: CONNECTED( npTTYInfo ) = FALSE ; 1202: CloseHandle( COMDEV( npTTYInfo ) ) ; 1203: fRetVal = FALSE ; 1204: } 1205: else 1206: { 1207: THREADID( npTTYInfo ) = dwThreadID ; 1208: HTHREAD( npTTYInfo ) = hCommWatchThread ; 1209: 1.1.1.3 ! root 1210: // Adjust thread priority ! 1211: ! 1212: SetThreadPriority( hCommWatchThread, THREAD_PRIORITY_BELOW_NORMAL ) ; ! 1213: ResumeThread( hCommWatchThread ) ; ! 1214: 1.1 root 1215: // assert DTR 1216: 1217: EscapeCommFunction( COMDEV( npTTYInfo ), SETDTR ) ; 1218: 1219: SetTTYFocus( hWnd ) ; 1220: 1221: hMenu = GetMenu( hWnd ) ; 1222: EnableMenuItem( hMenu, IDM_DISCONNECT, 1223: MF_ENABLED | MF_BYCOMMAND ) ; 1224: EnableMenuItem( hMenu, IDM_CONNECT, 1225: MF_GRAYED | MF_DISABLED | MF_BYCOMMAND ) ; 1.1.1.3 ! root 1226: ! 1227: // kick TELNET into operation ! 1228: ! 1229: ProcessCOMMNotification( hWnd, (WPARAM) COMDEV( npTTYInfo ), ! 1230: MAKELONG( CN_EVENT, 0 ) ) ; ! 1231: 1.1 root 1232: } 1233: #else 1234: // Under Windows 3.1, we set up notifications from COMM.DRV 1235: 1236: if (!USECNRECEIVE( npTTYInfo )) 1237: { 1238: // In this case we really are only using the notifications 1239: // for the received characters - it could be expanded to 1240: // cover the changes in CD or other status lines. 1241: 1242: SetCommEventMask( COMDEV( npTTYInfo ), EV_RXCHAR ) ; 1243: 1244: // Enable notifications for events only. 1245: 1246: // NB: This method does not use the specific 1247: // in/out queue triggers. 1248: 1249: EnableCommNotification( COMDEV( npTTYInfo ), hWnd, -1, -1 ) ; 1250: } 1251: else 1252: { 1253: // Enable notification for CN_RECEIVE events. 1254: 1255: EnableCommNotification( COMDEV( npTTYInfo ), hWnd, MAXBLOCK, -1 ) ; 1256: } 1257: 1258: // assert DTR 1259: 1260: EscapeCommFunction( COMDEV( npTTYInfo ), SETDTR ) ; 1261: 1262: SetTTYFocus( hWnd ) ; 1263: 1264: hMenu = GetMenu( hWnd ) ; 1265: EnableMenuItem( hMenu, IDM_DISCONNECT, 1266: MF_ENABLED | MF_BYCOMMAND ) ; 1267: EnableMenuItem( hMenu, IDM_CONNECT, 1268: MF_GRAYED | MF_DISABLED | MF_BYCOMMAND ) ; 1269: #endif 1270: } 1271: else 1272: { 1273: CONNECTED( npTTYInfo ) = FALSE ; 1274: 1275: #ifdef WIN32 1276: CloseHandle( COMDEV( npTTYInfo ) ) ; 1277: #else 1278: CloseComm( COMDEV( npTTYInfo ) ) ; 1279: #endif 1280: } 1281: 1282: // restore cursor 1283: 1284: SetCursor( hOldCursor ) ; 1285: 1286: return ( fRetVal ) ; 1287: 1288: } // end of OpenConnection() 1289: 1290: //--------------------------------------------------------------------------- 1291: // BOOL NEAR SetupConnection( HWND hWnd ) 1292: // 1293: // Description: 1294: // This routines sets up the DCB based on settings in the 1295: // TTY info structure and performs a SetCommState(). 1296: // 1297: // Parameters: 1298: // HWND hWnd 1299: // handle to TTY window 1300: // 1301: // Win-32 Porting Issues: 1302: // - Win-32 requires a slightly different processing of the DCB. 1303: // Changes were made for configuration of the hardware handshaking 1304: // lines. 1305: // 1306: // History: Date Author Comment 1307: // 5/ 9/91 BryanW Wrote it. 1308: // 1309: //--------------------------------------------------------------------------- 1310: 1311: BOOL NEAR SetupConnection( HWND hWnd ) 1312: { 1313: BOOL fRetVal ; 1314: BYTE bSet ; 1315: DCB dcb ; 1316: NPTTYINFO npTTYInfo ; 1317: 1318: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 1319: return ( FALSE ) ; 1320: 1321: #ifdef WIN32 1322: dcb.DCBlength = sizeof( DCB ) ; 1323: #endif 1324: 1325: GetCommState( COMDEV( npTTYInfo ), &dcb ) ; 1326: 1327: dcb.BaudRate = BAUDRATE( npTTYInfo ) ; 1328: dcb.ByteSize = BYTESIZE( npTTYInfo ) ; 1329: dcb.Parity = PARITY( npTTYInfo ) ; 1330: dcb.StopBits = STOPBITS( npTTYInfo ) ; 1331: 1332: // setup hardware flow control 1333: 1334: bSet = (BYTE) ((FLOWCTRL( npTTYInfo ) & FC_DTRDSR) != 0) ; 1335: #ifdef WIN32 1336: dcb.fOutxDsrFlow = bSet ; 1337: if (bSet) 1338: dcb.fDtrControl = DTR_CONTROL_HANDSHAKE ; 1339: else 1340: dcb.fDtrControl = DTR_CONTROL_ENABLE ; 1341: #else 1342: dcb.fOutxDsrFlow = dcb.fDtrflow = bSet ; 1343: dcb.DsrTimeout = (bSet) ? 30 : 0 ; 1344: #endif 1345: 1346: bSet = (BYTE) ((FLOWCTRL( npTTYInfo ) & FC_RTSCTS) != 0) ; 1347: #ifdef WIN32 1348: dcb.fOutxCtsFlow = bSet ; 1349: if (bSet) 1350: dcb.fRtsControl = RTS_CONTROL_HANDSHAKE ; 1351: else 1352: dcb.fRtsControl = RTS_CONTROL_ENABLE ; 1353: #else 1354: dcb.fOutxCtsFlow = dcb.fRtsflow = bSet ; 1355: dcb.CtsTimeout = (bSet) ? 30 : 0 ; 1356: #endif 1357: 1358: // setup software flow control 1359: 1360: bSet = (BYTE) ((FLOWCTRL( npTTYInfo ) & FC_XONXOFF) != 0) ; 1361: 1362: dcb.fInX = dcb.fOutX = bSet ; 1363: dcb.XonChar = ASCII_XON ; 1364: dcb.XoffChar = ASCII_XOFF ; 1365: dcb.XonLim = 100 ; 1366: dcb.XoffLim = 100 ; 1367: 1368: // other various settings 1369: 1370: dcb.fBinary = TRUE ; 1371: dcb.fParity = TRUE ; 1372: 1373: #ifndef WIN32 1374: dcb.fRtsDisable = FALSE ; 1375: dcb.fDtrDisable = FALSE ; 1376: fRetVal = !(SetCommState( &dcb ) < 0) ; 1377: #else 1378: fRetVal = SetCommState( COMDEV( npTTYInfo ), &dcb ) ; 1379: #endif 1380: 1381: return ( fRetVal ) ; 1382: 1383: } // end of SetupConnection() 1384: 1385: //--------------------------------------------------------------------------- 1386: // BOOL NEAR CloseConnection( HWND hWnd ) 1387: // 1388: // Description: 1389: // Closes the connection to the port. Resets the connect flag 1390: // in the TTYINFO struct. 1391: // 1392: // Parameters: 1393: // HWND hWnd 1394: // handle to TTY window 1395: // 1396: // Win-32 Porting Issues: 1397: // - Needed to stop secondary thread. SetCommMask() will signal the 1398: // WaitCommEvent() event and the thread will halt when the 1399: // CONNECTED() flag is clear. 1400: // - Use new PurgeComm() API to clear communications driver before 1401: // closing device. 1402: // 1403: // History: Date Author Comment 1404: // 5/ 9/91 BryanW Wrote it. 1405: // 6/15/92 BryanW Ported to Win-32. 1406: // 1407: //--------------------------------------------------------------------------- 1408: 1409: BOOL NEAR CloseConnection( HWND hWnd ) 1410: { 1411: HMENU hMenu ; 1412: NPTTYINFO npTTYInfo ; 1413: 1414: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 1415: return ( FALSE ) ; 1416: 1417: // set connected flag to FALSE 1418: 1419: CONNECTED( npTTYInfo ) = FALSE ; 1420: 1421: #ifdef WIN32 1422: // disable event notification and wait for thread 1423: // to halt 1424: 1.1.1.3 ! root 1425: SetCommMask( COMDEV( npTTYInfo ), 0 ) ; 1.1 root 1426: 1427: // block until thread has been halted 1428: 1.1.1.3 ! root 1429: while (THREADID( npTTYInfo ) != 0) ; 1.1 root 1430: #else 1431: // Disable event notification. Using a NULL hWnd tells 1432: // the COMM.DRV to disable future notifications. 1433: 1434: EnableCommNotification( COMDEV( npTTYInfo ), NULL, -1, -1 ) ; 1435: #endif 1436: 1437: // kill the focus 1438: 1439: KillTTYFocus( hWnd ) ; 1440: 1.1.1.3 ! root 1441: #ifdef WIN32 1.1 root 1442: // drop DTR 1443: 1444: EscapeCommFunction( COMDEV( npTTYInfo ), CLRDTR ) ; 1445: 1446: // purge any outstanding reads/writes and close device handle 1447: 1448: PurgeComm( COMDEV( npTTYInfo ), PURGE_TXABORT | PURGE_RXABORT | 1449: PURGE_TXCLEAR | PURGE_RXCLEAR ) ; 1450: CloseHandle( COMDEV( npTTYInfo ) ) ; 1451: #else 1.1.1.3 ! root 1452: // drop DTR ! 1453: ! 1454: EscapeCommFunction( COMDEV( npTTYInfo ), CLRDTR ) ; ! 1455: 1.1 root 1456: // close comm connection 1457: 1458: CloseComm( COMDEV( npTTYInfo ) ) ; 1459: #endif 1460: 1461: // change the selectable items in the menu 1462: 1463: hMenu = GetMenu( hWnd ) ; 1464: EnableMenuItem( hMenu, IDM_DISCONNECT, 1465: MF_GRAYED | MF_DISABLED | MF_BYCOMMAND ) ; 1466: EnableMenuItem( hMenu, IDM_CONNECT, 1467: MF_ENABLED | MF_BYCOMMAND ) ; 1468: 1469: return ( TRUE ) ; 1470: 1471: } // end of CloseConnection() 1472: 1473: //--------------------------------------------------------------------------- 1474: // int NEAR ReadCommBlock( HWND hWnd, LPSTR lpszBlock, int nMaxLength ) 1475: // 1476: // Description: 1477: // Reads a block from the COM port and stuffs it into 1478: // the provided block. 1479: // 1480: // Parameters: 1481: // HWND hWnd 1482: // handle to TTY window 1483: // 1484: // LPSTR lpszBlock 1485: // block used for storage 1486: // 1487: // int nMaxLength 1488: // max length of block to read 1489: // 1490: // Win-32 Porting Issues: 1491: // - ReadComm() has been replaced by ReadFile() in Win-32. 1492: // - Overlapped I/O has been implemented. 1493: // 1494: // History: Date Author Comment 1495: // 5/10/91 BryanW Wrote it. 1496: // 1497: //--------------------------------------------------------------------------- 1498: 1499: int NEAR ReadCommBlock( HWND hWnd, LPSTR lpszBlock, int nMaxLength ) 1500: { 1501: #ifdef WIN32 1502: BOOL fReadStat ; 1503: COMSTAT ComStat ; 1.1.1.2 root 1504: DWORD dwErrorFlags, dwLength ; 1.1 root 1505: #else 1.1.1.2 root 1506: int nError, nLength ; 1.1 root 1507: #endif 1508: 1509: char szError[ 10 ] ; 1510: NPTTYINFO npTTYInfo ; 1511: 1512: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 1513: return ( FALSE ) ; 1514: 1515: #ifdef WIN32 1516: ClearCommError( COMDEV( npTTYInfo ), &dwErrorFlags, &ComStat ) ; 1517: if ((dwErrorFlags > 0) && DISPLAYERRORS( npTTYInfo )) 1518: { 1519: wsprintf( szError, "<CE-%u>", dwErrorFlags ) ; 1520: WriteTTYBlock( hWnd, szError, lstrlen( szError ) ) ; 1521: } 1.1.1.3 ! root 1522: 1.1.1.2 root 1523: dwLength = min( (DWORD) nMaxLength, ComStat.cbInQue ) ; 1.1.1.3 ! root 1524: 1.1.1.2 root 1525: if (dwLength > 0) 1.1 root 1526: { 1527: fReadStat = ReadFile( COMDEV( npTTYInfo ), lpszBlock, 1.1.1.2 root 1528: dwLength, &dwLength, &READ_OS( npTTYInfo ) ) ; 1.1 root 1529: if (!fReadStat) 1530: { 1531: if (GetLastError() == ERROR_IO_PENDING) 1532: { 1533: // wait for a second for this transmission to complete 1534: 1535: if (WaitForSingleObject( READ_OS( npTTYInfo ).hEvent, 1000 )) 1.1.1.2 root 1536: dwLength = 0 ; 1.1 root 1537: else 1538: { 1539: GetOverlappedResult( COMDEV( npTTYInfo ), 1540: &READ_OS( npTTYInfo ), 1.1.1.2 root 1541: &dwLength, FALSE ) ; 1542: READ_OS( npTTYInfo ).Offset += dwLength ; 1.1 root 1543: } 1544: } 1545: else 1546: // some other error occurred 1547: 1.1.1.2 root 1548: dwLength = 0 ; 1.1 root 1549: } 1550: } 1.1.1.3 ! root 1551: 1.1.1.2 root 1552: return ( dwLength ) ; 1.1 root 1553: #else 1554: nLength = ReadComm( COMDEV( npTTYInfo ), lpszBlock, nMaxLength ) ; 1555: 1556: if (nLength < 0) 1557: { 1558: nLength *= -1 ; 1559: while (nError = GetCommError( COMDEV( npTTYInfo ), NULL )) 1560: { 1561: if (DISPLAYERRORS( npTTYInfo )) 1562: { 1563: wsprintf( szError, "<CE-%d>", nError ) ; 1564: WriteTTYBlock( hWnd, szError, lstrlen( szError ) ) ; 1565: } 1566: } 1567: } 1.1.1.2 root 1568: return ( nLength ) ; 1.1 root 1569: #endif 1570: 1571: 1572: } // end of ReadCommBlock() 1573: 1574: //--------------------------------------------------------------------------- 1575: // BOOL NEAR WriteCommByte( HWND hWnd, BYTE bByte ) 1576: // 1577: // Description: 1578: // Writes a byte to the COM port specified in the associated 1579: // TTY info structure. 1580: // 1581: // Parameters: 1582: // HWND hWnd 1583: // handle to TTY window 1584: // 1585: // BYTE bByte 1586: // byte to write to port 1587: // 1588: // Win-32 Porting Issues: 1589: // - WriteComm() has been replaced by WriteFile() in Win-32. 1590: // - Overlapped I/O has been implemented. 1591: // 1592: // History: Date Author Comment 1593: // 5/10/91 BryanW Wrote it. 1594: // 1595: //--------------------------------------------------------------------------- 1596: 1597: BOOL NEAR WriteCommByte( HWND hWnd, BYTE bByte ) 1598: { 1599: #ifdef WIN32 1600: BOOL fWriteStat ; 1601: DWORD dwBytesWritten ; 1602: #endif 1603: NPTTYINFO npTTYInfo ; 1604: 1605: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 1606: return ( FALSE ) ; 1607: 1608: #ifdef WIN32 1609: fWriteStat = WriteFile( COMDEV( npTTYInfo ), (LPSTR) &bByte, 1, 1610: &dwBytesWritten, &WRITE_OS( npTTYInfo ) ) ; 1611: if (!fWriteStat && (GetLastError() == ERROR_IO_PENDING)) 1612: { 1613: // wait for a second for this transmission to complete 1614: 1615: if (WaitForSingleObject( WRITE_OS( npTTYInfo ).hEvent, 1000 )) 1616: dwBytesWritten = 0 ; 1617: else 1618: { 1619: GetOverlappedResult( COMDEV( npTTYInfo ), 1620: &WRITE_OS( npTTYInfo ), 1621: &dwBytesWritten, FALSE ) ; 1622: WRITE_OS( npTTYInfo ).Offset += dwBytesWritten ; 1623: } 1624: } 1625: #else 1626: WriteComm( COMDEV( npTTYInfo ), (LPSTR) &bByte, 1 ) ; 1627: #endif 1628: return ( TRUE ) ; 1629: 1630: } // end of WriteCommByte() 1631: 1632: //--------------------------------------------------------------------------- 1633: // BOOL NEAR WriteTTYBlock( HWND hWnd, LPSTR lpBlock, int nLength ) 1634: // 1635: // Description: 1636: // Writes block to TTY screen. Nothing fancy - just 1637: // straight TTY. 1638: // 1639: // Parameters: 1640: // HWND hWnd 1641: // handle to TTY window 1642: // 1643: // LPSTR lpBlock 1644: // far pointer to block of data 1645: // 1646: // int nLength 1647: // length of block 1648: // 1649: // History: Date Author Comment 1650: // 5/ 9/91 BryanW Wrote it. 1651: // 5/20/91 BryanW Modified... not character based, 1652: // block based now. It was processing 1653: // per char. 1654: // 1655: //--------------------------------------------------------------------------- 1656: 1657: BOOL NEAR WriteTTYBlock( HWND hWnd, LPSTR lpBlock, int nLength ) 1658: { 1659: int i ; 1660: NPTTYINFO npTTYInfo ; 1661: RECT rect ; 1662: 1663: if (NULL == (npTTYInfo = GETNPTTYINFO( hWnd ))) 1664: return ( FALSE ) ; 1665: 1666: for (i = 0 ; i < nLength; i++) 1667: { 1668: switch (lpBlock[ i ]) 1669: { 1670: case ASCII_BEL: 1671: // Bell 1672: MessageBeep( 0 ) ; 1673: break ; 1674: 1675: case ASCII_BS: 1676: // Backspace 1677: if (COLUMN( npTTYInfo ) > 0) 1678: COLUMN( npTTYInfo ) -- ; 1679: MoveTTYCursor( hWnd ) ; 1680: break ; 1681: 1682: case ASCII_CR: 1683: // Carriage return 1684: COLUMN( npTTYInfo ) = 0 ; 1685: MoveTTYCursor( hWnd ) ; 1686: if (!NEWLINE( npTTYInfo )) 1687: break; 1688: 1689: // fall through 1690: 1691: case ASCII_LF: 1692: // Line feed 1693: if (ROW( npTTYInfo )++ == MAXROWS - 1) 1694: { 1695: _fmemmove( (LPSTR) (SCREEN( npTTYInfo )), 1696: (LPSTR) (SCREEN( npTTYInfo ) + MAXCOLS), 1697: (MAXROWS - 1) * MAXCOLS ) ; 1698: _fmemset( (LPSTR) (SCREEN( npTTYInfo ) + (MAXROWS - 1) * MAXCOLS), 1699: ' ', MAXCOLS ) ; 1700: InvalidateRect( hWnd, NULL, FALSE ) ; 1701: ROW( npTTYInfo )-- ; 1702: } 1703: MoveTTYCursor( hWnd ) ; 1704: break ; 1705: 1706: default: 1707: *(SCREEN( npTTYInfo ) + ROW( npTTYInfo ) * MAXCOLS + 1708: COLUMN( npTTYInfo )) = lpBlock[ i ] ; 1709: rect.left = (COLUMN( npTTYInfo ) * XCHAR( npTTYInfo )) - 1710: XOFFSET( npTTYInfo ) ; 1711: rect.right = rect.left + XCHAR( npTTYInfo ) ; 1712: rect.top = (ROW( npTTYInfo ) * YCHAR( npTTYInfo )) - 1713: YOFFSET( npTTYInfo ) ; 1714: rect.bottom = rect.top + YCHAR( npTTYInfo ) ; 1715: InvalidateRect( hWnd, &rect, FALSE ) ; 1716: 1717: // Line wrap 1718: if (COLUMN( npTTYInfo ) < MAXCOLS - 1) 1719: COLUMN( npTTYInfo )++ ; 1720: else if (AUTOWRAP( npTTYInfo )) 1721: WriteTTYBlock( hWnd, "\r\n", 2 ) ; 1722: break; 1723: } 1724: } 1725: return ( TRUE ) ; 1726: 1727: } // end of WriteTTYBlock() 1728: 1729: //--------------------------------------------------------------------------- 1730: // VOID NEAR GoModalDialogBoxParam( HINSTANCE hInstance, 1731: // LPCSTR lpszTemplate, HWND hWnd, 1732: // DLGPROC lpDlgProc, LPARAM lParam ) 1733: // 1734: // Description: 1735: // It is a simple utility function that simply performs the 1736: // MPI and invokes the dialog box with a DWORD paramter. 1737: // 1738: // Parameters: 1739: // similar to that of DialogBoxParam() with the exception 1740: // that the lpDlgProc is not a procedure instance 1741: // 1742: // History: Date Author Comment 1743: // 5/10/91 BryanW Wrote it. 1744: // 1745: //--------------------------------------------------------------------------- 1746: 1747: VOID NEAR GoModalDialogBoxParam( HINSTANCE hInstance, LPCSTR lpszTemplate, 1748: HWND hWnd, DLGPROC lpDlgProc, LPARAM lParam ) 1749: { 1750: DLGPROC lpProcInstance ; 1751: 1752: lpProcInstance = (DLGPROC) MakeProcInstance( (FARPROC) lpDlgProc, 1753: hInstance ) ; 1754: DialogBoxParam( hInstance, lpszTemplate, hWnd, lpProcInstance, lParam ) ; 1755: FreeProcInstance( (FARPROC) lpProcInstance ) ; 1756: 1757: } // end of GoModalDialogBoxParam() 1758: 1759: //--------------------------------------------------------------------------- 1760: // BOOL FAR PASCAL AboutDlgProc( HWND hDlg, UINT uMsg, 1761: // WPARAM wParam, LPARAM lParam ) 1762: // 1763: // Description: 1764: // Simulates the Windows System Dialog Box. 1765: // 1766: // Parameters: 1767: // Same as standard dialog procedures. 1768: // 1769: // History: Date Author Comment 1770: // 10/19/91 BryanW Added this little extra. 1771: // 1772: //--------------------------------------------------------------------------- 1773: 1774: BOOL FAR PASCAL AboutDlgProc( HWND hDlg, UINT uMsg, 1775: WPARAM wParam, LPARAM lParam ) 1776: { 1777: switch (uMsg) 1778: { 1779: case WM_INITDIALOG: 1780: { 1781: #ifdef WIN32 1782: char szBuffer[ MAXLEN_TEMPSTR ], szTemp[ MAXLEN_TEMPSTR ]; 1783: WORD wRevision, wVersion ; 1784: #else 1785: int idModeString ; 1786: char szBuffer[ MAXLEN_TEMPSTR ], szTemp[ MAXLEN_TEMPSTR ] ; 1787: DWORD dwFreeMemory, dwWinFlags ; 1788: WORD wFreeResources, wRevision, wVersion ; 1789: #endif 1790: 1791: #ifdef ABOUTDLG_USEBITMAP 1792: // if we are using the bitmap, hide the icon 1793: 1794: ShowWindow( GetDlgItem( hDlg, IDD_ABOUTICON ), SW_HIDE ) ; 1795: #endif 1796: // sets up the version number for Windows 1797: 1798: wVersion = LOWORD( GetVersion() ) ; 1799: wRevision = HIBYTE( wVersion ) ; 1800: wVersion = LOBYTE( wVersion ) ; 1801: 1802: GetDlgItemText( hDlg, IDD_TITLELINE, szTemp, sizeof( szTemp ) ) ; 1803: wsprintf( szBuffer, szTemp, wVersion, wRevision ) ; 1804: SetDlgItemText( hDlg, IDD_TITLELINE, szBuffer ) ; 1805: 1806: // sets up version number for TTY 1807: 1808: GetDlgItemText( hDlg, IDD_VERSION, szTemp, sizeof( szTemp ) ) ; 1809: wsprintf( szBuffer, szTemp, VER_MAJOR, VER_MINOR, VER_BUILD ) ; 1810: SetDlgItemText( hDlg, IDD_VERSION, (LPSTR) szBuffer ) ; 1811: 1812: // get by-line 1813: 1814: LoadString( GETHINST( hDlg ), IDS_BYLINE, szBuffer, 1815: sizeof( szBuffer ) ) ; 1816: SetDlgItemText( hDlg, IDD_BYLINE, szBuffer ) ; 1817: 1818: #ifndef WIN32 1819: // set windows mode information 1820: 1821: dwWinFlags = GetWinFlags() ; 1822: if (dwWinFlags & WF_ENHANCED) 1823: idModeString = IDS_MODE_ENHANCED ; 1824: else if (dwWinFlags & WF_STANDARD) 1825: idModeString = IDS_MODE_STANDARD ; 1826: else if (dwWinFlags & WF_WLO) 1827: idModeString = IDS_MODE_WLO ; 1828: else 1829: idModeString = IDS_MODE_UNDEF ; 1830: 1831: LoadString( GETHINST( hDlg ), idModeString, szBuffer, 1832: sizeof( szBuffer ) ) ; 1833: SetDlgItemText( hDlg, IDD_WINDOWSMODE, szBuffer ) ; 1834: #else 1835: SetDlgItemText( hDlg, IDD_WINDOWSMODE, "NT Mode" ) ; 1836: #endif 1837: 1.1.1.2 root 1838: #ifndef WIN32 1.1 root 1839: // get free memory information 1840: 1841: dwFreeMemory = GetFreeSpace( 0 ) / 1024L ; 1842: GetDlgItemText( hDlg, IDD_FREEMEM, szTemp, sizeof( szTemp ) ) ; 1843: wsprintf( szBuffer, szTemp, dwFreeMemory ) ; 1844: SetDlgItemText( hDlg, IDD_FREEMEM, (LPSTR) szBuffer ) ; 1845: 1846: // get free resources information 1847: 1848: wFreeResources = GetFreeSystemResources( 0 ) ; 1849: GetDlgItemText( hDlg, IDD_RESOURCES, szTemp, sizeof( szTemp ) ) ; 1850: wsprintf( szBuffer, szTemp, wFreeResources ) ; 1851: SetDlgItemText( hDlg, IDD_RESOURCES, (LPSTR) szBuffer ) ; 1852: #endif 1853: } 1854: return ( TRUE ) ; 1855: 1856: #ifdef ABOUTDLG_USEBITMAP 1857: // used to paint the bitmap 1858: 1859: case WM_PAINT: 1860: { 1861: HBITMAP hBitMap ; 1862: HDC hDC, hMemDC ; 1863: PAINTSTRUCT ps ; 1864: 1865: // load bitmap and display it 1866: 1867: hDC = BeginPaint( hDlg, &ps ) ; 1868: if (NULL != (hMemDC = CreateCompatibleDC( hDC ))) 1869: { 1870: hBitMap = LoadBitmap( GETHINST( hDlg ), 1871: MAKEINTRESOURCE( TTYBITMAP ) ) ; 1872: hBitMap = SelectObject( hMemDC, hBitMap ) ; 1873: BitBlt( hDC, 10, 10, 64, 64, hMemDC, 0, 0, SRCCOPY ) ; 1874: DeleteObject( SelectObject( hMemDC, hBitMap ) ) ; 1875: DeleteDC( hMemDC ) ; 1876: } 1877: EndPaint( hDlg, &ps ) ; 1878: } 1879: break ; 1880: #endif 1881: 1882: case WM_COMMAND: 1883: if (LOWORD( wParam ) == IDD_OK) 1884: { 1885: EndDialog( hDlg, TRUE ) ; 1886: return ( TRUE ) ; 1887: } 1888: break; 1889: } 1890: return ( FALSE ) ; 1891: 1892: } // end of AboutDlgProc() 1893: 1894: //--------------------------------------------------------------------------- 1895: // VOID NEAR FillComboBox( HINSTANCE hInstance, HWND hCtrlWnd, int nIDString, 1896: // WORD NEAR *npTable, WORD wTableLen, 1897: // WORD wCurrentSetting ) 1898: // 1899: // Description: 1900: // Fills the given combo box with strings from the resource 1901: // table starting at nIDString. Associated items are 1902: // added from given table. The combo box is notified of 1903: // the current setting. 1904: // 1905: // Parameters: 1906: // HINSTANCE hInstance 1907: // handle to application instance 1908: // 1909: // HWND hCtrlWnd 1910: // handle to combo box control 1911: // 1912: // int nIDString 1913: // first resource string id 1914: // 1915: // DWORD NEAR *npTable 1916: // near point to table of associated values 1917: // 1918: // WORD wTableLen 1919: // length of table 1920: // 1921: // DWORD dwCurrentSetting 1922: // current setting (for combo box selection) 1923: // 1924: // History: Date Author Comment 1925: // 10/20/91 BryanW Pulled from the init procedure. 1926: // 1927: //--------------------------------------------------------------------------- 1928: 1929: VOID NEAR FillComboBox( HINSTANCE hInstance, HWND hCtrlWnd, int nIDString, 1930: DWORD NEAR *npTable, WORD wTableLen, 1931: DWORD dwCurrentSetting ) 1932: { 1933: char szBuffer[ MAXLEN_TEMPSTR ] ; 1934: WORD wCount, wPosition ; 1935: 1936: for (wCount = 0; wCount < wTableLen; wCount++) 1937: { 1938: // load the string from the string resources and 1939: // add it to the combo box 1940: 1941: LoadString( hInstance, nIDString + wCount, szBuffer, sizeof( szBuffer ) ) ; 1.1.1.3 ! root 1942: wPosition = LOWORD( SendMessage( hCtrlWnd, CB_ADDSTRING, 0, 1.1 root 1943: (LPARAM) (LPSTR) szBuffer ) ) ; 1944: 1945: // use item data to store the actual table value 1946: 1947: SendMessage( hCtrlWnd, CB_SETITEMDATA, (WPARAM) wPosition, 1948: (LPARAM) *(npTable + wCount) ) ; 1949: 1950: // if this is our current setting, select it 1951: 1952: if (*(npTable + wCount) == dwCurrentSetting) 1.1.1.3 ! root 1953: SendMessage( hCtrlWnd, CB_SETCURSEL, (WPARAM) wPosition, 0L ) ; 1.1 root 1954: } 1955: 1956: } // end of FillComboBox() 1957: 1958: //--------------------------------------------------------------------------- 1959: // BOOL NEAR SettingsDlgInit( HWND hDlg ) 1960: // 1961: // Description: 1962: // Puts current settings into dialog box (via CheckRadioButton() etc.) 1963: // 1964: // Parameters: 1965: // HWND hDlg 1966: // handle to dialog box 1967: // 1968: // Win-32 Porting Issues: 1969: // - Constants require DWORD arrays for baud rate table, etc. 1970: // - There is no "MAXCOM" function in Win-32. Number of COM ports 1971: // is assumed to be 4. 1972: // 1973: // History: Date Author Comment 1974: // 5/11/91 BryanW Wrote it. 1975: // 10/20/91 BryanW Dialog revision. 1976: // 10/24/91 BryanW Fixed bug with EscapeCommFunction(). 1977: // 6/15/92 BryanW Ported to Win-32. 1978: // 1979: //--------------------------------------------------------------------------- 1980: 1981: BOOL NEAR SettingsDlgInit( HWND hDlg ) 1982: { 1983: char szBuffer[ MAXLEN_TEMPSTR ], szTemp[ MAXLEN_TEMPSTR ] ; 1984: NPTTYINFO npTTYInfo ; 1985: WORD wCount, wMaxCOM, wPosition ; 1986: 1987: if (NULL == (npTTYInfo = (NPTTYINFO) GET_PROP( hDlg, ATOM_TTYINFO ))) 1988: return ( FALSE ) ; 1989: 1990: #ifdef WIN32 1.1.1.3 ! root 1991: wMaxCOM = MAXPORTS ; 1.1 root 1992: #else 1993: wMaxCOM = LOWORD( EscapeCommFunction( NULL, GETMAXCOM ) ) + 1 ; 1994: #endif 1995: 1996: // load the COM prefix from resources 1997: 1998: LoadString( GETHINST( hDlg ), IDS_COMPREFIX, szTemp, sizeof( szTemp ) ) ; 1999: 2000: // fill port combo box and make initial selection 2001: 2002: for (wCount = 0; wCount < wMaxCOM; wCount++) 2003: { 2004: wsprintf( szBuffer, "%s%d", (LPSTR) szTemp, wCount + 1 ) ; 1.1.1.3 ! root 2005: SendDlgItemMessage( hDlg, IDD_PORTCB, CB_ADDSTRING, 0, 1.1 root 2006: (LPARAM) (LPSTR) szBuffer ) ; 2007: } 1.1.1.3 ! root 2008: ! 2009: #ifdef WIN32 ! 2010: SendDlgItemMessage( hDlg, IDD_PORTCB, CB_ADDSTRING, 0, ! 2011: (LPARAM) (LPSTR) "TELNET" ) ; ! 2012: #endif 1.1 root 2013: SendDlgItemMessage( hDlg, IDD_PORTCB, CB_SETCURSEL, 1.1.1.3 ! root 2014: (WPARAM) (PORT( npTTYInfo ) - 1), 0L ) ; 1.1 root 2015: 2016: // disable COM port combo box if connection has already been 2017: // established (e.g. OpenComm() already successful) 2018: 2019: EnableWindow( GetDlgItem( hDlg, IDD_PORTCB ), !CONNECTED( npTTYInfo ) ) ; 2020: 2021: // fill baud combo box and make initial selection 2022: 2023: FillComboBox( GETHINST( hDlg ), GetDlgItem( hDlg, IDD_BAUDCB ), 2024: IDS_BAUD110, BaudTable, 2025: sizeof( BaudTable ) / sizeof( BaudTable[ 0 ] ), 2026: BAUDRATE( npTTYInfo ) ) ; 2027: 2028: // fill data bits combo box and make initial selection 2029: 2030: for (wCount = 5; wCount < 9; wCount++) 2031: { 2032: wsprintf( szBuffer, "%d", wCount ) ; 2033: wPosition = LOWORD( SendDlgItemMessage( hDlg, IDD_DATABITSCB, 1.1.1.3 ! root 2034: CB_ADDSTRING, 0, 1.1 root 2035: (LPARAM) (LPSTR) szBuffer ) ) ; 2036: 2037: // if current selection, tell the combo box 2038: 2039: if (wCount == BYTESIZE( npTTYInfo )) 2040: SendDlgItemMessage( hDlg, IDD_DATABITSCB, CB_SETCURSEL, 1.1.1.3 ! root 2041: (WPARAM) wPosition, 0L ) ; 1.1 root 2042: } 2043: 2044: // fill parity combo box and make initial selection 2045: 2046: FillComboBox( GETHINST( hDlg ), GetDlgItem( hDlg, IDD_PARITYCB ), 2047: IDS_PARITYNONE, ParityTable, 2048: sizeof( ParityTable ) / sizeof( ParityTable[ 0 ] ), 2049: PARITY( npTTYInfo ) ) ; 2050: 2051: // fill stop bits combo box and make initial selection 2052: 2053: FillComboBox( GETHINST( hDlg ), GetDlgItem( hDlg, IDD_STOPBITSCB ), 2054: IDS_ONESTOPBIT, StopBitsTable, 2055: sizeof( StopBitsTable ) / sizeof ( StopBitsTable ), 2056: STOPBITS( npTTYInfo ) ) ; 2057: 2058: // initalize the flow control settings 2059: 2060: CheckDlgButton( hDlg, IDD_DTRDSR, 2061: (FLOWCTRL( npTTYInfo ) & FC_DTRDSR) > 0 ) ; 2062: CheckDlgButton( hDlg, IDD_RTSCTS, 2063: (FLOWCTRL( npTTYInfo ) & FC_RTSCTS) > 0 ) ; 2064: CheckDlgButton( hDlg, IDD_XONXOFF, 2065: (FLOWCTRL( npTTYInfo ) & FC_XONXOFF) > 0 ) ; 2066: 2067: // other TTY settings 2068: 2069: CheckDlgButton( hDlg, IDD_AUTOWRAP, AUTOWRAP( npTTYInfo ) ) ; 2070: CheckDlgButton( hDlg, IDD_NEWLINE, NEWLINE( npTTYInfo ) ) ; 2071: CheckDlgButton( hDlg, IDD_LOCALECHO, LOCALECHO( npTTYInfo ) ) ; 2072: 2073: // control options 2074: 2075: #ifdef WIN32 2076: // "Use CN_RECEIVE" is not valid under Win-32 2077: 2078: EnableWindow( GetDlgItem( hDlg, IDD_USECNRECEIVE ), FALSE ) ; 2079: #else 2080: CheckDlgButton( hDlg, IDD_USECNRECEIVE, USECNRECEIVE( npTTYInfo ) ) ; 2081: 2082: // disable Use CN_RECEIVE option if connection has already been 2083: // established (e.g. OpenComm() already successful) 2084: 2085: EnableWindow( GetDlgItem( hDlg, IDD_USECNRECEIVE ), 2086: !CONNECTED( npTTYInfo ) ) ; 2087: #endif 2088: 2089: CheckDlgButton( hDlg, IDD_DISPLAYERRORS, DISPLAYERRORS( npTTYInfo ) ) ; 2090: 2091: return ( TRUE ) ; 2092: 2093: } // end of SettingsDlgInit() 2094: 2095: //--------------------------------------------------------------------------- 2096: // BOOL NEAR SelectTTYFont( HWND hDlg ) 2097: // 2098: // Description: 2099: // Selects the current font for the TTY screen. 2100: // Uses the Common Dialog ChooseFont() API. 2101: // 2102: // Parameters: 2103: // HWND hDlg 2104: // handle to settings dialog 2105: // 2106: // History: Date Author Comment 2107: // 10/20/91 BryanW Wrote it. 2108: // 2109: //--------------------------------------------------------------------------- 2110: 2111: BOOL NEAR SelectTTYFont( HWND hDlg ) 2112: { 2113: CHOOSEFONT cfTTYFont ; 2114: NPTTYINFO npTTYInfo ; 2115: 2116: if (NULL == (npTTYInfo = (NPTTYINFO) GET_PROP( hDlg, ATOM_TTYINFO ))) 2117: return ( FALSE ) ; 2118: 2119: cfTTYFont.lStructSize = sizeof( CHOOSEFONT ) ; 2120: cfTTYFont.hwndOwner = hDlg ; 2121: cfTTYFont.hDC = NULL ; 2122: cfTTYFont.rgbColors = FGCOLOR( npTTYInfo ) ; 2123: cfTTYFont.lpLogFont = &LFTTYFONT( npTTYInfo ) ; 2124: cfTTYFont.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | 2125: CF_EFFECTS | CF_INITTOLOGFONTSTRUCT ; 1.1.1.3 ! root 2126: cfTTYFont.lCustData = 0 ; 1.1 root 2127: cfTTYFont.lpfnHook = NULL ; 2128: cfTTYFont.lpTemplateName = NULL ; 2129: cfTTYFont.hInstance = GETHINST( hDlg ) ; 2130: 2131: if (ChooseFont( &cfTTYFont )) 2132: { 2133: FGCOLOR( npTTYInfo ) = cfTTYFont.rgbColors ; 2134: ResetTTYScreen( GetParent( hDlg ), npTTYInfo ) ; 2135: } 2136: 2137: return ( TRUE ) ; 2138: 2139: } // end of SelectTTYFont() 2140: 2141: //--------------------------------------------------------------------------- 2142: // BOOL NEAR SettingsDlgTerm( HWND hDlg ) 2143: // 2144: // Description: 2145: // Puts dialog contents into TTY info structure. 2146: // 2147: // Parameters: 2148: // HWND hDlg 2149: // handle to settings dialog 2150: // 2151: // Win-32 Porting Issues: 2152: // - Baud rate requires DWORD values. 2153: // 2154: // History: Date Author Comment 2155: // 5/11/91 BryanW Wrote it. 2156: // 6/15/92 BryanW Ported to Win-32. 2157: // 2158: //--------------------------------------------------------------------------- 2159: 2160: BOOL NEAR SettingsDlgTerm( HWND hDlg ) 2161: { 2162: NPTTYINFO npTTYInfo ; 2163: WORD wSelection ; 2164: 2165: if (NULL == (npTTYInfo = (NPTTYINFO) GET_PROP( hDlg, ATOM_TTYINFO ))) 2166: return ( FALSE ) ; 2167: 2168: // get port selection 2169: 2170: PORT( npTTYInfo ) = 2171: LOBYTE( LOWORD( SendDlgItemMessage( hDlg, IDD_PORTCB, 2172: CB_GETCURSEL, 1.1.1.3 ! root 2173: 0, 0L ) ) + 1 ) ; 1.1 root 2174: // get baud rate selection 2175: 2176: wSelection = 2177: LOWORD( SendDlgItemMessage( hDlg, IDD_BAUDCB, CB_GETCURSEL, 1.1.1.3 ! root 2178: 0, 0L ) ) ; 1.1 root 2179: #ifdef WIN32 2180: BAUDRATE( npTTYInfo ) = 2181: SendDlgItemMessage( hDlg, IDD_BAUDCB, CB_GETITEMDATA, 1.1.1.3 ! root 2182: (WPARAM) wSelection, 0L ) ; 1.1 root 2183: #else 2184: BAUDRATE( npTTYInfo ) = 2185: LOWORD( SendDlgItemMessage( hDlg, IDD_BAUDCB, CB_GETITEMDATA, 1.1.1.3 ! root 2186: (WPARAM) wSelection, 0L ) ) ; 1.1 root 2187: #endif 2188: 2189: // get data bits selection 2190: 2191: BYTESIZE( npTTYInfo ) = 2192: LOBYTE( LOWORD( SendDlgItemMessage( hDlg, IDD_DATABITSCB, 2193: CB_GETCURSEL, 1.1.1.3 ! root 2194: 0, 0L ) ) + 5 ) ; 1.1 root 2195: 2196: // get parity selection 2197: 2198: wSelection = 2199: LOWORD( SendDlgItemMessage( hDlg, IDD_PARITYCB, CB_GETCURSEL, 1.1.1.3 ! root 2200: 0, 0L ) ) ; 1.1 root 2201: PARITY( npTTYInfo ) = 2202: LOBYTE( LOWORD( SendDlgItemMessage( hDlg, IDD_PARITYCB, 2203: CB_GETITEMDATA, 2204: (WPARAM) wSelection, 1.1.1.3 ! root 2205: 0L ) ) ) ; 1.1 root 2206: 2207: // get stop bits selection 2208: 2209: wSelection = 2210: LOWORD( SendDlgItemMessage( hDlg, IDD_STOPBITSCB, CB_GETCURSEL, 1.1.1.3 ! root 2211: 0, 0L ) ) ; 1.1 root 2212: STOPBITS( npTTYInfo ) = 2213: LOBYTE( LOWORD( SendDlgItemMessage( hDlg, IDD_STOPBITSCB, 2214: CB_GETITEMDATA, 1.1.1.3 ! root 2215: (WPARAM) wSelection, 0L ) ) ) ; 1.1 root 2216: 2217: // get flow control settings 2218: 2219: FLOWCTRL( npTTYInfo ) = 0 ; 2220: if (IsDlgButtonChecked( hDlg, IDD_DTRDSR )) 2221: FLOWCTRL( npTTYInfo ) |= FC_DTRDSR ; 2222: if (IsDlgButtonChecked( hDlg, IDD_RTSCTS )) 2223: FLOWCTRL( npTTYInfo ) |= FC_RTSCTS ; 2224: if (IsDlgButtonChecked( hDlg, IDD_XONXOFF )) 2225: FLOWCTRL( npTTYInfo ) |= FC_XONXOFF ; 2226: 2227: // get other various settings 2228: 2229: AUTOWRAP( npTTYInfo ) = IsDlgButtonChecked( hDlg, IDD_AUTOWRAP ) ; 2230: NEWLINE( npTTYInfo ) = IsDlgButtonChecked( hDlg, IDD_NEWLINE ) ; 2231: LOCALECHO( npTTYInfo ) = IsDlgButtonChecked( hDlg, IDD_LOCALECHO ) ; 2232: 2233: // control options 2234: 2235: USECNRECEIVE( npTTYInfo ) = IsDlgButtonChecked( hDlg, IDD_USECNRECEIVE ) ; 2236: DISPLAYERRORS( npTTYInfo ) = IsDlgButtonChecked( hDlg, IDD_DISPLAYERRORS ) ; 2237: 2238: return ( TRUE ) ; 2239: 2240: } // end of SettingsDlgTerm() 2241: 2242: //--------------------------------------------------------------------------- 2243: // BOOL FAR PASCAL SettingsDlgProc( HWND hDlg, UINT uMsg, 2244: // WPARAM wParam, LPARAM lParam ) 2245: // 2246: // Description: 2247: // This handles all of the user preference settings for 2248: // the TTY. 2249: // 2250: // Parameters: 2251: // same as all dialog procedures 2252: // 2253: // Win-32 Porting Issues: 2254: // - npTTYInfo is a DWORD in Win-32. 2255: // 2256: // History: Date Author Comment 2257: // 5/10/91 BryanW Wrote it. 2258: // 10/20/91 BryanW Now uses window properties to 2259: // store TTYInfo handle. Also added 2260: // font selection. 2261: // 6/15/92 BryanW Ported to Win-32. 2262: // 2263: //--------------------------------------------------------------------------- 2264: 2265: BOOL FAR PASCAL SettingsDlgProc( HWND hDlg, UINT uMsg, 2266: WPARAM wParam, LPARAM lParam ) 2267: { 2268: switch (uMsg) 2269: { 2270: case WM_INITDIALOG: 2271: { 2272: NPTTYINFO npTTYInfo ; 2273: 2274: // get & save pointer to TTY info structure 2275: 2276: #ifdef WIN32 2277: npTTYInfo = (NPTTYINFO) lParam ; 2278: #else 2279: npTTYInfo = (NPTTYINFO) LOWORD( lParam ) ; 2280: #endif 2281: 2282: SET_PROP( hDlg, ATOM_TTYINFO, (HANDLE) npTTYInfo ) ; 2283: 2284: return ( SettingsDlgInit( hDlg ) ) ; 2285: } 2286: 2287: case WM_COMMAND: 2288: switch ( LOWORD( wParam )) 2289: { 2290: case IDD_FONT: 2291: return ( SelectTTYFont( hDlg ) ) ; 2292: 2293: case IDD_OK: 2294: // Copy stuff into structure 2295: SettingsDlgTerm( hDlg ) ; 2296: EndDialog( hDlg, TRUE ) ; 2297: return ( TRUE ) ; 2298: 2299: case IDD_CANCEL: 2300: // Just end 2301: EndDialog( hDlg, TRUE ) ; 2302: return ( TRUE ) ; 2303: } 2304: break; 2305: 2306: case WM_DESTROY: 2307: REMOVE_PROP( hDlg, ATOM_TTYINFO ) ; 2308: break ; 2309: } 2310: return ( FALSE ) ; 2311: 2312: } // end of SettingsDlgProc() 2313: 2314: #ifdef WIN32 2315: 2316: //************************************************************************ 2317: // DWORD FAR PASCAL CommWatchProc( LPSTR lpData ) 2318: // 2319: // Description: 2320: // A secondary thread that will watch for COMM events. 2321: // 2322: // Parameters: 2323: // LPSTR lpData 2324: // 32-bit pointer argument 2325: // 2326: // Win-32 Porting Issues: 2327: // - Added this thread to watch the communications device and 2328: // post notifications to the associated window. 2329: // 2330: // History: Date Author Comment 2331: // 12/31/91 BryanW Wrote it. 2332: // 6/12/92 BryanW CommWaitEvent() now uses 2333: // an overlapped structure. 2334: // 2335: //************************************************************************ 2336: 2337: DWORD FAR PASCAL CommWatchProc( LPSTR lpData ) 2338: { 1.1.1.2 root 2339: DWORD dwTransfer, dwEvtMask ; 1.1 root 2340: NPTTYINFO npTTYInfo = (NPTTYINFO) lpData ; 2341: OVERLAPPED os ; 2342: 2343: memset( &os, 0, sizeof( OVERLAPPED ) ) ; 2344: 2345: // create I/O event used for overlapped read 2346: 2347: os.hEvent = CreateEvent( NULL, // no security 2348: TRUE, // explicit reset req 2349: FALSE, // initial event reset 2350: NULL ) ; // no name 2351: if (os.hEvent == NULL) 2352: { 2353: MessageBox( NULL, "Failed to create event for thread!", "TTY Error!", 2354: MB_ICONEXCLAMATION | MB_OK ) ; 2355: return ( FALSE ) ; 2356: } 2357: 2358: if (!SetCommMask( COMDEV( npTTYInfo ), EV_RXCHAR )) 2359: return ( FALSE ) ; 2360: 2361: while ( CONNECTED( npTTYInfo ) ) 2362: { 1.1.1.3 ! root 2363: dwEvtMask = 0 ; 1.1 root 2364: 2365: if (!WaitCommEvent( COMDEV( npTTYInfo ), &dwEvtMask, &os )) 2366: { 2367: if (ERROR_IO_PENDING == GetLastError()) 2368: { 1.1.1.2 root 2369: GetOverlappedResult( COMDEV( npTTYInfo ), &os, &dwTransfer, TRUE ) ; 2370: os.Offset += dwTransfer ; 1.1 root 2371: } 2372: } 2373: 2374: if ((dwEvtMask & EV_RXCHAR) == EV_RXCHAR) 2375: { 2376: // wait for "posted notification" flag to clear 2377: 2378: WaitForSingleObject( POSTEVENT( npTTYInfo ), 0xFFFFFFFF ) ; 2379: 2380: // reset event 2381: 2382: ResetEvent( POSTEVENT( npTTYInfo ) ) ; 2383: 2384: // last message was processed, O.K. to post 2385: 2386: PostMessage( TERMWND( npTTYInfo ), WM_COMMNOTIFY, 2387: (WPARAM) COMDEV( npTTYInfo ), 2388: MAKELONG( CN_EVENT, 0 ) ) ; 2389: } 2390: } 2391: 2392: // get rid of event handle 2393: 2394: CloseHandle( os.hEvent ) ; 2395: 2396: // clear information in structure (kind of a "we're done flag") 2397: 1.1.1.3 ! root 2398: THREADID( npTTYInfo ) = 0 ; 1.1 root 2399: HTHREAD( npTTYInfo ) = NULL ; 2400: 2401: return( TRUE ) ; 2402: 2403: } // end of CommWatchProc() 2404: 2405: #endif 2406: 2407: //--------------------------------------------------------------------------- 2408: // End of File: tty.c 2409: //---------------------------------------------------------------------------
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.