Commit 261b3bdf2f58b3db861eff71d8967165ded73081

Authored by xiemeng
1 parent 107a69d6

new branch optekBlueTool

  1 +/*-----------------------------------------------------------------------------
  2 +
  3 + This is a part of the Microsoft Source Code Samples.
  4 + Copyright (C) 1995 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 + MODULE: About.c
  12 +
  13 + PURPOSE: Implement the About dialog box for the program.
  14 +
  15 + FUNCTIONS:
  16 + CmdAbout - Creates the About dialog in response to menu selection
  17 + AboutDlgProc - Processes messages for the About dialog
  18 + InitAboutDlg - Initialzes about dialog controls
  19 +
  20 +-----------------------------------------------------------------------------*/
  21 +
  22 +
  23 +#include <windows.h>
  24 +#include "mttty.h"
  25 +
  26 +/*
  27 + Prototypes for functions called only in this file
  28 +*/
  29 +BOOL CALLBACK AboutDlgProc( HWND, UINT, WPARAM, LPARAM );
  30 +UINT InitAboutDlg( HWND );
  31 +
  32 +/*-----------------------------------------------------------------------------
  33 +
  34 +FUNCTION: CmdAbout( HWND )
  35 +
  36 +PARAMETERS:
  37 + hwnd - Owner of the window
  38 +
  39 +PURPOSE: Creates the modal About dialog
  40 +
  41 +-----------------------------------------------------------------------------*/
  42 +BOOL CmdAbout(HWND hwnd)
  43 +{
  44 + DialogBox(ghInst, MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutDlgProc);
  45 + return 0;
  46 +}
  47 +
  48 +/*-----------------------------------------------------------------------------
  49 +
  50 +FUNCTION: InitAboutDlg( HWND )
  51 +
  52 +PURPOSE: Initializes the modal About dialog
  53 +
  54 +PARMATETERS:
  55 + hDlg - Dialog window handle
  56 +
  57 +COMMENTS: Sets the icon animation timer and the version info.
  58 +
  59 +HISTORY: Date: Author: Comment:
  60 + 10/27/95 AllenD Wrote it
  61 +
  62 +-----------------------------------------------------------------------------*/
  63 +UINT InitAboutDlg(HWND hDlg)
  64 +{
  65 + UINT uTimer;
  66 + char * szFormat = "Microsoft Windows %s\r\nVersion %d.%d\r\nBuild %d ";
  67 + char szVersion[256];
  68 +
  69 + /*
  70 + create timer and set initial icon id
  71 + */
  72 + uTimer = SetTimer(hDlg, 1, 100, NULL);
  73 + if (uTimer == 0)
  74 + ErrorReporter("SetTimer");
  75 + wsprintf(szVersion, szFormat,
  76 + gOSV.dwPlatformId == VER_PLATFORM_WIN32_NT ? "NT" : "95",
  77 + gOSV.dwMajorVersion,
  78 + gOSV.dwMinorVersion,
  79 + LOWORD( gOSV.dwBuildNumber ) );
  80 +
  81 + if (strlen(gOSV.szCSDVersion))
  82 + strcat(szVersion, gOSV.szCSDVersion);
  83 +
  84 + SetDlgItemText(hDlg, IDC_OSVERSIONINFO, szVersion);
  85 +
  86 + return uTimer;
  87 +}
  88 +
  89 +/*-----------------------------------------------------------------------------
  90 +
  91 +FUNCTION: AboutDlgProc(HWND, UINT, WPARAM, LPARAM)
  92 +
  93 +PURPOSE: Dialog procedure for the "About Box"
  94 +
  95 +PARAMETERS:
  96 + hdlg - dialog window handle
  97 + uMessage - window message
  98 + wparam - message parameter (depends on message value)
  99 + lparam - message prarmeter (depends on message value)
  100 +
  101 +HISTORY: Date: Author: Comment:
  102 + 10/27/95 AllenD Wrote it
  103 +
  104 +-----------------------------------------------------------------------------*/
  105 +BOOL CALLBACK AboutDlgProc(HWND hdlg, UINT uMessage, WPARAM wparam, LPARAM lparam)
  106 +{
  107 + static UINT uTimer;
  108 + static WORD wCurrentIconId;
  109 +
  110 + switch(uMessage)
  111 + {
  112 + case WM_INITDIALOG:
  113 + uTimer = InitAboutDlg(hdlg);
  114 + wCurrentIconId = IDI_APPICON;
  115 + break;
  116 +
  117 + case WM_TIMER:
  118 + /*
  119 + when timer goes off, then change to next icon
  120 + */
  121 + {
  122 + HICON hIcon;
  123 +
  124 + switch(wCurrentIconId)
  125 + {
  126 + case IDI_APPICON: wCurrentIconId = IDI_APPICON2; break;
  127 + case IDI_APPICON2: wCurrentIconId = IDI_APPICON3; break;
  128 + case IDI_APPICON3: wCurrentIconId = IDI_APPICON4; break;
  129 + case IDI_APPICON4: wCurrentIconId = IDI_APPICON; break;
  130 + }
  131 +
  132 + hIcon = LoadIcon(ghInst, MAKEINTRESOURCE(wCurrentIconId));
  133 + SendMessage(GetDlgItem(hdlg, IDC_PICTURE), STM_SETICON, (WPARAM) hIcon, 0);
  134 + }
  135 + break;
  136 +
  137 + case WM_COMMAND:
  138 + if (LOWORD(wparam) == IDOK) {
  139 + KillTimer(hdlg, uTimer);
  140 + EndDialog(hdlg, TRUE);
  141 + return TRUE;
  142 + }
  143 + break;
  144 + }
  145 +
  146 + return FALSE;
  147 +}
  148 +
... ...
  1 +MTTTY: Multi-threaded Terminal Sample (Win32)
  2 +
  3 +MTTTY illustrates overlapped serial communication
  4 +using multiple threads.
  5 +
  6 +MTTTY is a companion sample for the "Serial
  7 +Communication in Win32" technical article
  8 +in the Microsoft(R) Developer Network Library.
  9 +
  10 +MTTTY was built and tested under Microsoft Windows(TM)
  11 +95 and Microsoft Windows NT 3.51 using Microsoft
  12 +Visual C/C++ version 2.0 and the combined Win32 SDK
  13 +for Windows 95 and Windows NT.
  14 +
  15 +How it works:
  16 +
  17 +The program utilizes 3 threads. A main thread initializes the comm
  18 +port and maintains the user interface while two working threads
  19 +do all the serial communication work.
  20 +
  21 +A reader/status thread is created to handle port reading and to
  22 +monitor status events. The thread issues an overlapped read
  23 +operation and an overlapped status operation. When one of
  24 +these operation completes, it is handled and information is
  25 +imparted to the user. If a timeout occurs waiting for an operation
  26 +to complete, background work is performed.
  27 +
  28 +A writer thread is created to accept output requests and send them
  29 +out the comm port. The writer thread utilizes a work queue. Each
  30 +output request is placed on a linked list in a private heap and a
  31 +syncrhonization event is signaled to indicated new work. When the
  32 +writer thread is available to do work, it will retrieve the
  33 +output request and perform the output.
  34 +
  35 +Caution:
  36 +
  37 +This sample utilizes multiple threads only for the sake of simplicity
  38 +and performance. A more efficient method for this program might
  39 +be to have a single thread perform all i/o requests and then
  40 +wait on multiple handles for each operation to complete.
  41 +Creating multiple threads just for the sake of simplicity
  42 +in a full blown application may not be best implementation.
  43 +
  44 +I chose the model for reasons specific to file transfer. I wanted
  45 +reading and writing to be completely separate operations not dependant
  46 +on each other in any way.
  47 +
  48 +
  49 +KEYWORDS: MTTTY
... ...
1   -; CLW file contains information for the MFC ClassWizard
2   -
3   -[General Info]
4   -Version=1
5   -LastClass=CBlueFlashToolDlg
6   -LastTemplate=CDialog
7   -NewFileInclude1=#include "stdafx.h"
8   -NewFileInclude2=#include "BlueFlashTool.h"
9   -
10   -ClassCount=2
11   -Class1=CBlueFlashToolApp
12   -Class2=CBlueFlashToolDlg
13   -
14   -ResourceCount=4
15   -Resource2=IDR_MAINFRAME
16   -Resource3=IDD_BLUEFLASHTOOL_DIALOG
17   -Resource4=IDD_SYSTEM_CONFIG
18   -
19   -[CLS:CBlueFlashToolApp]
20   -Type=0
21   -HeaderFile=BlueFlashTool.h
22   -ImplementationFile=BlueFlashTool.cpp
23   -Filter=N
24   -
25   -[CLS:CBlueFlashToolDlg]
26   -Type=0
27   -HeaderFile=BlueFlashToolDlg.h
28   -ImplementationFile=BlueFlashToolDlg.cpp
29   -Filter=D
30   -BaseClass=CDialog
31   -VirtualFilter=dWC
32   -LastObject=IDC_MSCOMM0
33   -
34   -
35   -
36   -[DLG:IDD_BLUEFLASHTOOL_DIALOG]
37   -Type=1
38   -Class=CBlueFlashToolDlg
39   -ControlCount=94
40   -Control1=IDC_STATIC_GROUP01,button,1342177287
41   -Control2=IDC_CHECK_EAR01,button,1342242819
42   -Control3=IDC_CHECK_USB01,button,1342242819
43   -Control4=IDC_PROGRESS_EAR01,msctls_progress32,1350565889
44   -Control5=IDC_PROGRESS_USB01,msctls_progress32,1350565889
45   -Control6=IDC_BUTTON_START_EAR01,button,1342242816
46   -Control7=IDC_BUTTON_START_USB01,button,1342242816
47   -Control8=IDC_STATIC_GROUP2,button,1342177287
48   -Control9=IDC_CHECK_EAR2,button,1342242819
49   -Control10=IDC_CHECK_USB2,button,1342242819
50   -Control11=IDC_PROGRESS_EAR2,msctls_progress32,1350565889
51   -Control12=IDC_PROGRESS_USB2,msctls_progress32,1350565889
52   -Control13=IDC_BUTTON_START_EAR2,button,1342242816
53   -Control14=IDC_BUTTON_START_USB2,button,1342242816
54   -Control15=IDC_STATIC_GROUP3,button,1342177287
55   -Control16=IDC_CHECK_EAR3,button,1342242819
56   -Control17=IDC_CHECK_USB3,button,1342242819
57   -Control18=IDC_PROGRESS_EAR3,msctls_progress32,1350565889
58   -Control19=IDC_PROGRESS_USB3,msctls_progress32,1350565889
59   -Control20=IDC_BUTTON_START_EAR3,button,1342242816
60   -Control21=IDC_BUTTON_START_USB3,button,1342242816
61   -Control22=IDC_STATIC_GROUP4,button,1342177287
62   -Control23=IDC_CHECK_EAR4,button,1342242819
63   -Control24=IDC_CHECK_USB4,button,1342242819
64   -Control25=IDC_PROGRESS_EAR4,msctls_progress32,1350565889
65   -Control26=IDC_PROGRESS_USB4,msctls_progress32,1350565889
66   -Control27=IDC_BUTTON_START_EAR4,button,1342242816
67   -Control28=IDC_BUTTON_START_USB4,button,1342242816
68   -Control29=IDC_STATIC_GROUP5,button,1342177287
69   -Control30=IDC_CHECK_EAR5,button,1342242819
70   -Control31=IDC_CHECK_USB5,button,1342242819
71   -Control32=IDC_PROGRESS_EAR5,msctls_progress32,1350565889
72   -Control33=IDC_PROGRESS_USB5,msctls_progress32,1350565889
73   -Control34=IDC_BUTTON_START_EAR5,button,1342242816
74   -Control35=IDC_BUTTON_START_USB5,button,1342242816
75   -Control36=IDC_STATIC_GROUP6,button,1342177287
76   -Control37=IDC_CHECK_EAR6,button,1342242819
77   -Control38=IDC_CHECK_USB6,button,1342242819
78   -Control39=IDC_PROGRESS_EAR6,msctls_progress32,1350565889
79   -Control40=IDC_PROGRESS_USB6,msctls_progress32,1350565889
80   -Control41=IDC_BUTTON_START_EAR6,button,1342242816
81   -Control42=IDC_BUTTON_START_USB6,button,1342242816
82   -Control43=IDC_STATIC_GROUP7,button,1342177287
83   -Control44=IDC_CHECK_EAR7,button,1342242819
84   -Control45=IDC_CHECK_USB7,button,1342242819
85   -Control46=IDC_PROGRESS_EAR7,msctls_progress32,1350565889
86   -Control47=IDC_PROGRESS_USB7,msctls_progress32,1350565889
87   -Control48=IDC_BUTTON_START_EAR7,button,1342242816
88   -Control49=IDC_BUTTON_START_USB7,button,1342242816
89   -Control50=IDC_STATIC_GROUP8,button,1342177287
90   -Control51=IDC_CHECK_EAR8,button,1342242819
91   -Control52=IDC_CHECK_USB8,button,1342242819
92   -Control53=IDC_PROGRESS_EAR8,msctls_progress32,1350565889
93   -Control54=IDC_PROGRESS_USB8,msctls_progress32,1350565889
94   -Control55=IDC_BUTTON_START_EAR8,button,1342242816
95   -Control56=IDC_BUTTON_START_USB8,button,1342242816
96   -Control57=IDC_STATIC_GROUP9,button,1342177287
97   -Control58=IDC_CHECK_EAR9,button,1342242819
98   -Control59=IDC_CHECK_USB9,button,1342242819
99   -Control60=IDC_PROGRESS_EAR9,msctls_progress32,1350565889
100   -Control61=IDC_PROGRESS_USB9,msctls_progress32,1350565889
101   -Control62=IDC_BUTTON_START_EAR9,button,1342242816
102   -Control63=IDC_BUTTON_START_USB9,button,1342242816
103   -Control64=IDC_STATIC_GROUP10,button,1342177287
104   -Control65=IDC_CHECK_EAR10,button,1342242819
105   -Control66=IDC_CHECK_USB10,button,1342242819
106   -Control67=IDC_PROGRESS_EAR10,msctls_progress32,1350565889
107   -Control68=IDC_PROGRESS_USB10,msctls_progress32,1350565889
108   -Control69=IDC_BUTTON_START_EAR10,button,1342242816
109   -Control70=IDC_BUTTON_START_USB10,button,1342242816
110   -Control71=IDC_START_ALL,button,1342242816
111   -Control72=IDC_STOP_ALL,button,1342242816
112   -Control73=IDC_BUTTON_SETTING,button,1342242816
113   -Control74=IDC_MSCOMM0,{648A5600-2C6E-101B-82B6-000000000014},1342242816
114   -Control75=IDC_MSCOMM1,{648A5600-2C6E-101B-82B6-000000000014},1342242816
115   -Control76=IDC_MSCOMM2,{648A5600-2C6E-101B-82B6-000000000014},1342242816
116   -Control77=IDC_MSCOMM3,{648A5600-2C6E-101B-82B6-000000000014},1342242816
117   -Control78=IDC_MSCOMM4,{648A5600-2C6E-101B-82B6-000000000014},1342242816
118   -Control79=IDC_MSCOMM5,{648A5600-2C6E-101B-82B6-000000000014},1342242816
119   -Control80=IDC_MSCOMM6,{648A5600-2C6E-101B-82B6-000000000014},1342242816
120   -Control81=IDC_MSCOMM7,{648A5600-2C6E-101B-82B6-000000000014},1342242816
121   -Control82=IDC_MSCOMM8,{648A5600-2C6E-101B-82B6-000000000014},1342242816
122   -Control83=IDC_MSCOMM9,{648A5600-2C6E-101B-82B6-000000000014},1342242816
123   -Control84=IDC_MSCOMM10,{648A5600-2C6E-101B-82B6-000000000014},1342242816
124   -Control85=IDC_MSCOMM11,{648A5600-2C6E-101B-82B6-000000000014},1342242816
125   -Control86=IDC_MSCOMM12,{648A5600-2C6E-101B-82B6-000000000014},1342242816
126   -Control87=IDC_MSCOMM13,{648A5600-2C6E-101B-82B6-000000000014},1342242816
127   -Control88=IDC_MSCOMM14,{648A5600-2C6E-101B-82B6-000000000014},1342242816
128   -Control89=IDC_MSCOMM15,{648A5600-2C6E-101B-82B6-000000000014},1342242816
129   -Control90=IDC_MSCOMM16,{648A5600-2C6E-101B-82B6-000000000014},1342242816
130   -Control91=IDC_MSCOMM17,{648A5600-2C6E-101B-82B6-000000000014},1342242816
131   -Control92=IDC_MSCOMM18,{648A5600-2C6E-101B-82B6-000000000014},1342242816
132   -Control93=IDC_MSCOMM19,{648A5600-2C6E-101B-82B6-000000000014},1342242816
133   -Control94=IDC_MSCOMM20,{648A5600-2C6E-101B-82B6-000000000014},1342242816
134   -
135   -[DLG:IDD_SYSTEM_CONFIG]
136   -Type=1
137   -Class=?
138   -ControlCount=2
139   -Control1=IDOK,button,1342242817
140   -Control2=IDCANCEL,button,1342242816
141   -
1   -// BlueFlashTool.cpp : Defines the class behaviors for the application.
2   -//
3   -
4   -#include "stdafx.h"
5   -#include "BlueFlashTool.h"
6   -#include "BlueFlashToolDlg.h"
7   -
8   -#ifdef _DEBUG
9   -#define new DEBUG_NEW
10   -#undef THIS_FILE
11   -static char THIS_FILE[] = __FILE__;
12   -#endif
13   -
14   -/////////////////////////////////////////////////////////////////////////////
15   -// CBlueFlashToolApp
16   -
17   -BEGIN_MESSAGE_MAP(CBlueFlashToolApp, CWinApp)
18   - //{{AFX_MSG_MAP(CBlueFlashToolApp)
19   - // NOTE - the ClassWizard will add and remove mapping macros here.
20   - // DO NOT EDIT what you see in these blocks of generated code!
21   - //}}AFX_MSG
22   - ON_COMMAND(ID_HELP, CWinApp::OnHelp)
23   -END_MESSAGE_MAP()
24   -
25   -/////////////////////////////////////////////////////////////////////////////
26   -// CBlueFlashToolApp construction
27   -
28   -CBlueFlashToolApp::CBlueFlashToolApp()
29   -{
30   - // TODO: add construction code here,
31   - // Place all significant initialization in InitInstance
32   -}
33   -
34   -/////////////////////////////////////////////////////////////////////////////
35   -// The one and only CBlueFlashToolApp object
36   -
37   -CBlueFlashToolApp theApp;
38   -
39   -/////////////////////////////////////////////////////////////////////////////
40   -// CBlueFlashToolApp initialization
41   -
42   -BOOL CBlueFlashToolApp::InitInstance()
43   -{
44   - AfxEnableControlContainer();
45   -
46   - // Standard initialization
47   - // If you are not using these features and wish to reduce the size
48   - // of your final executable, you should remove from the following
49   - // the specific initialization routines you do not need.
50   -
51   -#ifdef _AFXDLL
52   - Enable3dControls(); // Call this when using MFC in a shared DLL
53   -#else
54   - Enable3dControlsStatic(); // Call this when linking to MFC statically
55   -#endif
56   -
57   - CBlueFlashToolDlg dlg;
58   - m_pMainWnd = &dlg;
59   - int nResponse = dlg.DoModal();
60   - if (nResponse == IDOK)
61   - {
62   - // TODO: Place code here to handle when the dialog is
63   - // dismissed with OK
64   - }
65   - else if (nResponse == IDCANCEL)
66   - {
67   - // TODO: Place code here to handle when the dialog is
68   - // dismissed with Cancel
69   - }
70   -
71   - // Since the dialog has been closed, return FALSE so that we exit the
72   - // application, rather than start the application's message pump.
73   - return FALSE;
74   -}
1   -// BlueFlashTool.h : main header file for the BLUEFLASHTOOL application
2   -//
3   -
4   -#if !defined(AFX_BLUEFLASHTOOL_H__4BF81738_BBD5_4BEA_BCA8_BB0255AFF8C2__INCLUDED_)
5   -#define AFX_BLUEFLASHTOOL_H__4BF81738_BBD5_4BEA_BCA8_BB0255AFF8C2__INCLUDED_
6   -
7   -#if _MSC_VER > 1000
8   -#pragma once
9   -#endif // _MSC_VER > 1000
10   -
11   -#ifndef __AFXWIN_H__
12   - #error include 'stdafx.h' before including this file for PCH
13   -#endif
14   -
15   -#include "resource.h" // main symbols
16   -
17   -/////////////////////////////////////////////////////////////////////////////
18   -// CBlueFlashToolApp:
19   -// See BlueFlashTool.cpp for the implementation of this class
20   -//
21   -
22   -class CBlueFlashToolApp : public CWinApp
23   -{
24   -public:
25   - CBlueFlashToolApp();
26   -
27   -// Overrides
28   - // ClassWizard generated virtual function overrides
29   - //{{AFX_VIRTUAL(CBlueFlashToolApp)
30   - public:
31   - virtual BOOL InitInstance();
32   - //}}AFX_VIRTUAL
33   -
34   -// Implementation
35   -
36   - //{{AFX_MSG(CBlueFlashToolApp)
37   - // NOTE - the ClassWizard will add and remove member functions here.
38   - // DO NOT EDIT what you see in these blocks of generated code !
39   - //}}AFX_MSG
40   - DECLARE_MESSAGE_MAP()
41   -};
42   -
43   -
44   -/////////////////////////////////////////////////////////////////////////////
45   -
46   -//{{AFX_INSERT_LOCATION}}
47   -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
48   -
49   -#endif // !defined(AFX_BLUEFLASHTOOL_H__4BF81738_BBD5_4BEA_BCA8_BB0255AFF8C2__INCLUDED_)
No preview for this file type
1   -<html>
2   -<body>
3   -<pre>
4   -<h1>Build Log</h1>
5   -<h3>
6   ---------------------Configuration: BlueFlashTool - Win32 Debug--------------------
7   -</h3>
8   -<h3>Command Lines</h3>
9   -Creating command line "rc.exe /l 0x804 /fo"Debug/BlueFlashTool.res" /d "_DEBUG" /d "_AFXDLL" "H:\BlueFlashTool\BlueFlashTool.rc""
10   -Creating temporary file "C:\Users\ADMINI~1\AppData\Local\Temp\RSPDF66.tmp" with contents
11   -[
12   -/nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Fp"Debug/BlueFlashTool.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
13   -"H:\BlueFlashTool\BlueFlashTool.cpp"
14   -"H:\BlueFlashTool\BlueFlashToolDlg.cpp"
15   -"H:\BlueFlashTool\mscomm.cpp"
16   -]
17   -Creating command line "cl.exe @C:\Users\ADMINI~1\AppData\Local\Temp\RSPDF66.tmp"
18   -Creating temporary file "C:\Users\ADMINI~1\AppData\Local\Temp\RSPDF76.tmp" with contents
19   -[
20   -/nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Fp"Debug/BlueFlashTool.pch" /Yc"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
21   -"H:\BlueFlashTool\StdAfx.cpp"
22   -]
23   -Creating command line "cl.exe @C:\Users\ADMINI~1\AppData\Local\Temp\RSPDF76.tmp"
24   -Creating temporary file "C:\Users\ADMINI~1\AppData\Local\Temp\RSPDF77.tmp" with contents
25   -[
26   -/nologo /subsystem:windows /incremental:yes /pdb:"Debug/BlueFlashTool.pdb" /debug /machine:I386 /out:"Debug/BlueFlashTool.exe" /pdbtype:sept
27   -.\Debug\BlueFlashTool.obj
28   -.\Debug\BlueFlashToolDlg.obj
29   -.\Debug\mscomm.obj
30   -.\Debug\StdAfx.obj
31   -.\Debug\BlueFlashTool.res
32   -]
33   -Creating command line "link.exe @C:\Users\ADMINI~1\AppData\Local\Temp\RSPDF77.tmp"
34   -<h3>Output Window</h3>
35   -Compiling resources...
36   -Compiling...
37   -StdAfx.cpp
38   -Compiling...
39   -BlueFlashTool.cpp
40   -BlueFlashToolDlg.cpp
41   -mscomm.cpp
42   -Generating Code...
43   -Linking...
44   -
45   -
46   -
47   -<h3>Results</h3>
48   -BlueFlashTool.exe - 0 error(s), 0 warning(s)
49   -</pre>
50   -</body>
51   -</html>
1   -//Microsoft Developer Studio generated resource script.
2   -//
3   -#include "resource.h"
4   -
5   -#define APSTUDIO_READONLY_SYMBOLS
6   -/////////////////////////////////////////////////////////////////////////////
7   -//
8   -// Generated from the TEXTINCLUDE 2 resource.
9   -//
10   -#include "afxres.h"
11   -
12   -/////////////////////////////////////////////////////////////////////////////
13   -#undef APSTUDIO_READONLY_SYMBOLS
14   -
15   -/////////////////////////////////////////////////////////////////////////////
16   -// Chinese (P.R.C.) resources
17   -
18   -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
19   -#ifdef _WIN32
20   -LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
21   -#pragma code_page(936)
22   -#endif //_WIN32
23   -
24   -#ifdef APSTUDIO_INVOKED
25   -/////////////////////////////////////////////////////////////////////////////
26   -//
27   -// TEXTINCLUDE
28   -//
29   -
30   -1 TEXTINCLUDE DISCARDABLE
31   -BEGIN
32   - "resource.h\0"
33   -END
34   -
35   -2 TEXTINCLUDE DISCARDABLE
36   -BEGIN
37   - "#include ""afxres.h""\r\n"
38   - "\0"
39   -END
40   -
41   -3 TEXTINCLUDE DISCARDABLE
42   -BEGIN
43   - "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
44   - "#define _AFX_NO_OLE_RESOURCES\r\n"
45   - "#define _AFX_NO_TRACKER_RESOURCES\r\n"
46   - "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
47   - "\r\n"
48   - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)\r\n"
49   - "#ifdef _WIN32\r\n"
50   - "LANGUAGE 4, 2\r\n"
51   - "#pragma code_page(936)\r\n"
52   - "#endif //_WIN32\r\n"
53   - "#include ""res\\BlueFlashTool.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
54   - "#include ""l.chs\\afxres.rc"" // Standard components\r\n"
55   - "#endif\r\n"
56   - "\0"
57   -END
58   -
59   -#endif // APSTUDIO_INVOKED
60   -
61   -
62   -/////////////////////////////////////////////////////////////////////////////
63   -//
64   -// Icon
65   -//
66   -
67   -// Icon with lowest ID value placed first to ensure application icon
68   -// remains consistent on all systems.
69   -IDR_MAINFRAME ICON DISCARDABLE "res\\BlueFlashTool.ico"
70   -
71   -/////////////////////////////////////////////////////////////////////////////
72   -//
73   -// Dialog
74   -//
75   -
76   -IDD_BLUEFLASHTOOL_DIALOG DIALOGEX 0, 0, 566, 367
77   -STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
78   -EXSTYLE WS_EX_APPWINDOW
79   -CAPTION "BlueFlashTool"
80   -FONT 9, "宋体", 0, 0, 0x1
81   -BEGIN
82   - GROUPBOX "SN:000000000000",IDC_STATIC_GROUP01,0,1,232,51
83   - CONTROL "耳机",IDC_CHECK_EAR01,"Button",BS_AUTOCHECKBOX |
84   - WS_TABSTOP,8,15,32,10
85   - CONTROL "发射器",IDC_CHECK_USB01,"Button",BS_AUTOCHECKBOX |
86   - WS_TABSTOP,8,34,40,10
87   - CONTROL "Progress1",IDC_PROGRESS_EAR01,"msctls_progress32",
88   - PBS_SMOOTH | WS_BORDER,57,15,102,14
89   - CONTROL "Progress1",IDC_PROGRESS_USB01,"msctls_progress32",
90   - PBS_SMOOTH | WS_BORDER,57,34,102,14
91   - PUSHBUTTON "开始",IDC_BUTTON_START_EAR01,169,15,50,14
92   - PUSHBUTTON "开始",IDC_BUTTON_START_USB01,169,34,50,14
93   - GROUPBOX "SN:000000000000",IDC_STATIC_GROUP2,0,60,232,51
94   - CONTROL "耳机",IDC_CHECK_EAR2,"Button",BS_AUTOCHECKBOX |
95   - WS_TABSTOP,8,74,32,10
96   - CONTROL "发射器",IDC_CHECK_USB2,"Button",BS_AUTOCHECKBOX |
97   - WS_TABSTOP,8,93,40,10
98   - CONTROL "Progress1",IDC_PROGRESS_EAR2,"msctls_progress32",
99   - PBS_SMOOTH | WS_BORDER,57,74,102,14
100   - CONTROL "Progress1",IDC_PROGRESS_USB2,"msctls_progress32",
101   - PBS_SMOOTH | WS_BORDER,57,93,102,14
102   - PUSHBUTTON "开始",IDC_BUTTON_START_EAR2,169,74,50,14
103   - PUSHBUTTON "开始",IDC_BUTTON_START_USB2,169,93,50,14
104   - GROUPBOX "SN:000000000000",IDC_STATIC_GROUP3,0,120,232,51
105   - CONTROL "耳机",IDC_CHECK_EAR3,"Button",BS_AUTOCHECKBOX |
106   - WS_TABSTOP,8,134,32,10
107   - CONTROL "发射器",IDC_CHECK_USB3,"Button",BS_AUTOCHECKBOX |
108   - WS_TABSTOP,8,153,40,10
109   - CONTROL "Progress1",IDC_PROGRESS_EAR3,"msctls_progress32",
110   - PBS_SMOOTH | WS_BORDER,57,134,102,14
111   - CONTROL "Progress1",IDC_PROGRESS_USB3,"msctls_progress32",
112   - PBS_SMOOTH | WS_BORDER,57,153,102,14
113   - PUSHBUTTON "开始",IDC_BUTTON_START_EAR3,169,134,50,14
114   - PUSHBUTTON "开始",IDC_BUTTON_START_USB3,169,153,50,14
115   - GROUPBOX "SN:000000000000",IDC_STATIC_GROUP4,0,180,232,51
116   - CONTROL "耳机",IDC_CHECK_EAR4,"Button",BS_AUTOCHECKBOX |
117   - WS_TABSTOP,8,194,32,10
118   - CONTROL "发射器",IDC_CHECK_USB4,"Button",BS_AUTOCHECKBOX |
119   - WS_TABSTOP,8,213,40,10
120   - CONTROL "Progress1",IDC_PROGRESS_EAR4,"msctls_progress32",
121   - PBS_SMOOTH | WS_BORDER,57,194,102,14
122   - CONTROL "Progress1",IDC_PROGRESS_USB4,"msctls_progress32",
123   - PBS_SMOOTH | WS_BORDER,57,213,102,14
124   - PUSHBUTTON "开始",IDC_BUTTON_START_EAR4,169,194,50,14
125   - PUSHBUTTON "开始",IDC_BUTTON_START_USB4,169,213,50,14
126   - GROUPBOX "SN:000000000000",IDC_STATIC_GROUP5,0,240,232,51
127   - CONTROL "耳机",IDC_CHECK_EAR5,"Button",BS_AUTOCHECKBOX |
128   - WS_TABSTOP,8,254,32,10
129   - CONTROL "发射器",IDC_CHECK_USB5,"Button",BS_AUTOCHECKBOX |
130   - WS_TABSTOP,8,273,40,10
131   - CONTROL "Progress1",IDC_PROGRESS_EAR5,"msctls_progress32",
132   - PBS_SMOOTH | WS_BORDER,57,254,102,14
133   - CONTROL "Progress1",IDC_PROGRESS_USB5,"msctls_progress32",
134   - PBS_SMOOTH | WS_BORDER,57,273,102,14
135   - PUSHBUTTON "开始",IDC_BUTTON_START_EAR5,169,254,50,14
136   - PUSHBUTTON "开始",IDC_BUTTON_START_USB5,169,273,50,14
137   - GROUPBOX "SN:000000000000",IDC_STATIC_GROUP6,245,0,232,51
138   - CONTROL "耳机",IDC_CHECK_EAR6,"Button",BS_AUTOCHECKBOX |
139   - WS_TABSTOP,253,14,32,10
140   - CONTROL "发射器",IDC_CHECK_USB6,"Button",BS_AUTOCHECKBOX |
141   - WS_TABSTOP,253,33,40,10
142   - CONTROL "Progress1",IDC_PROGRESS_EAR6,"msctls_progress32",
143   - PBS_SMOOTH | WS_BORDER,303,14,102,14
144   - CONTROL "Progress1",IDC_PROGRESS_USB6,"msctls_progress32",
145   - PBS_SMOOTH | WS_BORDER,303,33,102,14
146   - PUSHBUTTON "开始",IDC_BUTTON_START_EAR6,415,14,50,14
147   - PUSHBUTTON "开始",IDC_BUTTON_START_USB6,415,33,50,14
148   - GROUPBOX "SN:000000000000",IDC_STATIC_GROUP7,245,60,232,51
149   - CONTROL "耳机",IDC_CHECK_EAR7,"Button",BS_AUTOCHECKBOX |
150   - WS_TABSTOP,253,74,32,10
151   - CONTROL "发射器",IDC_CHECK_USB7,"Button",BS_AUTOCHECKBOX |
152   - WS_TABSTOP,253,93,40,10
153   - CONTROL "Progress1",IDC_PROGRESS_EAR7,"msctls_progress32",
154   - PBS_SMOOTH | WS_BORDER,303,74,102,14
155   - CONTROL "Progress1",IDC_PROGRESS_USB7,"msctls_progress32",
156   - PBS_SMOOTH | WS_BORDER,303,93,102,14
157   - PUSHBUTTON "开始",IDC_BUTTON_START_EAR7,415,74,50,14
158   - PUSHBUTTON "开始",IDC_BUTTON_START_USB7,415,93,50,14
159   - GROUPBOX "SN:000000000000",IDC_STATIC_GROUP8,245,120,232,51
160   - CONTROL "耳机",IDC_CHECK_EAR8,"Button",BS_AUTOCHECKBOX |
161   - WS_TABSTOP,253,134,32,10
162   - CONTROL "发射器",IDC_CHECK_USB8,"Button",BS_AUTOCHECKBOX |
163   - WS_TABSTOP,253,153,40,10
164   - CONTROL "Progress1",IDC_PROGRESS_EAR8,"msctls_progress32",
165   - PBS_SMOOTH | WS_BORDER,303,134,102,14
166   - CONTROL "Progress1",IDC_PROGRESS_USB8,"msctls_progress32",
167   - PBS_SMOOTH | WS_BORDER,303,153,102,14
168   - PUSHBUTTON "开始",IDC_BUTTON_START_EAR8,415,134,50,14
169   - PUSHBUTTON "开始",IDC_BUTTON_START_USB8,415,153,50,14
170   - GROUPBOX "SN:000000000000",IDC_STATIC_GROUP9,245,180,232,51
171   - CONTROL "耳机",IDC_CHECK_EAR9,"Button",BS_AUTOCHECKBOX |
172   - WS_TABSTOP,253,194,32,10
173   - CONTROL "发射器",IDC_CHECK_USB9,"Button",BS_AUTOCHECKBOX |
174   - WS_TABSTOP,253,213,40,10
175   - CONTROL "Progress1",IDC_PROGRESS_EAR9,"msctls_progress32",
176   - PBS_SMOOTH | WS_BORDER,303,194,102,14
177   - CONTROL "Progress1",IDC_PROGRESS_USB9,"msctls_progress32",
178   - PBS_SMOOTH | WS_BORDER,303,213,102,14
179   - PUSHBUTTON "开始",IDC_BUTTON_START_EAR9,415,194,50,14
180   - PUSHBUTTON "开始",IDC_BUTTON_START_USB9,415,213,50,14
181   - GROUPBOX "SN:000000000000",IDC_STATIC_GROUP10,245,240,232,51
182   - CONTROL "耳机",IDC_CHECK_EAR10,"Button",BS_AUTOCHECKBOX |
183   - WS_TABSTOP,253,254,32,10
184   - CONTROL "发射器",IDC_CHECK_USB10,"Button",BS_AUTOCHECKBOX |
185   - WS_TABSTOP,253,273,40,10
186   - CONTROL "Progress1",IDC_PROGRESS_EAR10,"msctls_progress32",
187   - PBS_SMOOTH | WS_BORDER,303,254,102,14
188   - CONTROL "Progress1",IDC_PROGRESS_USB10,"msctls_progress32",
189   - PBS_SMOOTH | WS_BORDER,303,273,102,14
190   - PUSHBUTTON "开始",IDC_BUTTON_START_EAR10,415,254,50,14
191   - PUSHBUTTON "开始",IDC_BUTTON_START_USB10,415,273,50,14
192   - PUSHBUTTON "全部开始",IDC_START_ALL,10,300,50,14
193   - PUSHBUTTON "全部停止",IDC_STOP_ALL,75,300,50,14
194   - PUSHBUTTON "参数设置",IDC_BUTTON_SETTING,425,300,50,14
195   - CONTROL "",IDC_MSCOMM0,"{648A5600-2C6E-101B-82B6-000000000014}",
196   - WS_TABSTOP,0,342,25,25
197   - CONTROL "",IDC_MSCOMM1,"{648A5600-2C6E-101B-82B6-000000000014}",
198   - WS_TABSTOP,26,342,25,25
199   - CONTROL "",IDC_MSCOMM2,"{648A5600-2C6E-101B-82B6-000000000014}",
200   - WS_TABSTOP,52,342,25,25
201   - CONTROL "",IDC_MSCOMM3,"{648A5600-2C6E-101B-82B6-000000000014}",
202   - WS_TABSTOP,78,342,25,25
203   - CONTROL "",IDC_MSCOMM4,"{648A5600-2C6E-101B-82B6-000000000014}",
204   - WS_TABSTOP,104,342,25,25
205   - CONTROL "",IDC_MSCOMM5,"{648A5600-2C6E-101B-82B6-000000000014}",
206   - WS_TABSTOP,130,342,25,25
207   - CONTROL "",IDC_MSCOMM6,"{648A5600-2C6E-101B-82B6-000000000014}",
208   - WS_TABSTOP,156,342,25,25
209   - CONTROL "",IDC_MSCOMM7,"{648A5600-2C6E-101B-82B6-000000000014}",
210   - WS_TABSTOP,182,342,25,25
211   - CONTROL "",IDC_MSCOMM8,"{648A5600-2C6E-101B-82B6-000000000014}",
212   - WS_TABSTOP,208,342,25,25
213   - CONTROL "",IDC_MSCOMM9,"{648A5600-2C6E-101B-82B6-000000000014}",
214   - WS_TABSTOP,234,342,25,25
215   - CONTROL "",IDC_MSCOMM10,"{648A5600-2C6E-101B-82B6-000000000014}",
216   - WS_TABSTOP,260,342,25,25
217   - CONTROL "",IDC_MSCOMM11,"{648A5600-2C6E-101B-82B6-000000000014}",
218   - WS_TABSTOP,286,342,25,25
219   - CONTROL "",IDC_MSCOMM12,"{648A5600-2C6E-101B-82B6-000000000014}",
220   - WS_TABSTOP,312,342,25,25
221   - CONTROL "",IDC_MSCOMM13,"{648A5600-2C6E-101B-82B6-000000000014}",
222   - WS_TABSTOP,338,342,25,25
223   - CONTROL "",IDC_MSCOMM14,"{648A5600-2C6E-101B-82B6-000000000014}",
224   - WS_TABSTOP,364,342,25,25
225   - CONTROL "",IDC_MSCOMM15,"{648A5600-2C6E-101B-82B6-000000000014}",
226   - WS_TABSTOP,390,342,25,25
227   - CONTROL "",IDC_MSCOMM16,"{648A5600-2C6E-101B-82B6-000000000014}",
228   - WS_TABSTOP,416,342,25,25
229   - CONTROL "",IDC_MSCOMM17,"{648A5600-2C6E-101B-82B6-000000000014}",
230   - WS_TABSTOP,442,342,25,25
231   - CONTROL "",IDC_MSCOMM18,"{648A5600-2C6E-101B-82B6-000000000014}",
232   - WS_TABSTOP,468,342,25,25
233   - CONTROL "",IDC_MSCOMM19,"{648A5600-2C6E-101B-82B6-000000000014}",
234   - WS_TABSTOP,494,342,25,25
235   - CONTROL "",IDC_MSCOMM20,"{648A5600-2C6E-101B-82B6-000000000014}",
236   - WS_TABSTOP,520,342,25,25
237   -END
238   -
239   -IDD_SYSTEM_CONFIG DIALOG DISCARDABLE 0, 0, 187, 96
240   -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
241   -CAPTION "Dialog"
242   -FONT 10, "System"
243   -BEGIN
244   - DEFPUSHBUTTON "OK",IDOK,130,7,50,14
245   - PUSHBUTTON "Cancel",IDCANCEL,130,24,50,14
246   -END
247   -
248   -
249   -#ifndef _MAC
250   -/////////////////////////////////////////////////////////////////////////////
251   -//
252   -// Version
253   -//
254   -
255   -VS_VERSION_INFO VERSIONINFO
256   - FILEVERSION 1,0,0,1
257   - PRODUCTVERSION 1,0,0,1
258   - FILEFLAGSMASK 0x3fL
259   -#ifdef _DEBUG
260   - FILEFLAGS 0x1L
261   -#else
262   - FILEFLAGS 0x0L
263   -#endif
264   - FILEOS 0x4L
265   - FILETYPE 0x1L
266   - FILESUBTYPE 0x0L
267   -BEGIN
268   - BLOCK "StringFileInfo"
269   - BEGIN
270   - BLOCK "080404B0"
271   - BEGIN
272   - VALUE "CompanyName", "\0"
273   - VALUE "FileDescription", "BlueFlashTool Microsoft 基础类应用程序\0"
274   - VALUE "FileVersion", "1, 0, 0, 1\0"
275   - VALUE "InternalName", "BlueFlashTool\0"
276   - VALUE "LegalCopyright", "版权所有 (C) 2021\0"
277   - VALUE "LegalTrademarks", "\0"
278   - VALUE "OriginalFilename", "BlueFlashTool.EXE\0"
279   - VALUE "ProductName", "BlueFlashTool 应用程序\0"
280   - VALUE "ProductVersion", "1, 0, 0, 1\0"
281   - END
282   - END
283   - BLOCK "VarFileInfo"
284   - BEGIN
285   - VALUE "Translation", 0x804, 1200
286   - END
287   -END
288   -
289   -#endif // !_MAC
290   -
291   -
292   -/////////////////////////////////////////////////////////////////////////////
293   -//
294   -// DESIGNINFO
295   -//
296   -
297   -#ifdef APSTUDIO_INVOKED
298   -GUIDELINES DESIGNINFO DISCARDABLE
299   -BEGIN
300   - IDD_BLUEFLASHTOOL_DIALOG, DIALOG
301   - BEGIN
302   - LEFTMARGIN, 7
303   - RIGHTMARGIN, 559
304   - TOPMARGIN, 7
305   - BOTTOMMARGIN, 360
306   - END
307   -
308   - IDD_SYSTEM_CONFIG, DIALOG
309   - BEGIN
310   - LEFTMARGIN, 7
311   - RIGHTMARGIN, 180
312   - TOPMARGIN, 7
313   - BOTTOMMARGIN, 89
314   - END
315   -END
316   -#endif // APSTUDIO_INVOKED
317   -
318   -
319   -/////////////////////////////////////////////////////////////////////////////
320   -//
321   -// Dialog Info
322   -//
323   -
324   -IDD_BLUEFLASHTOOL_DIALOG DLGINIT
325   -BEGIN
326   - IDC_MSCOMM0, 0x376, 102, 0
327   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
328   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
329   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
330   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
331   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
332   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
333   - IDC_MSCOMM1, 0x376, 102, 0
334   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
335   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
336   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
337   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
338   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
339   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
340   - IDC_MSCOMM2, 0x376, 102, 0
341   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
342   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
343   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
344   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
345   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
346   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
347   - IDC_MSCOMM3, 0x376, 102, 0
348   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
349   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
350   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
351   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
352   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
353   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
354   - IDC_MSCOMM4, 0x376, 102, 0
355   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
356   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
357   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
358   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
359   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
360   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
361   - IDC_MSCOMM5, 0x376, 102, 0
362   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
363   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
364   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
365   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
366   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
367   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
368   - IDC_MSCOMM6, 0x376, 102, 0
369   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
370   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
371   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
372   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
373   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
374   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
375   - IDC_MSCOMM7, 0x376, 102, 0
376   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
377   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
378   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
379   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
380   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
381   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
382   - IDC_MSCOMM8, 0x376, 102, 0
383   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
384   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
385   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
386   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
387   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
388   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
389   - IDC_MSCOMM9, 0x376, 102, 0
390   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
391   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
392   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
393   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
394   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
395   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
396   - IDC_MSCOMM10, 0x376, 102, 0
397   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
398   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
399   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
400   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
401   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
402   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
403   - IDC_MSCOMM11, 0x376, 102, 0
404   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
405   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
406   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
407   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
408   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
409   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
410   - IDC_MSCOMM12, 0x376, 102, 0
411   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
412   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
413   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
414   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
415   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
416   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
417   - IDC_MSCOMM13, 0x376, 102, 0
418   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
419   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
420   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
421   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
422   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
423   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
424   - IDC_MSCOMM14, 0x376, 102, 0
425   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
426   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
427   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
428   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
429   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
430   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
431   - IDC_MSCOMM15, 0x376, 102, 0
432   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
433   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
434   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
435   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
436   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
437   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
438   - IDC_MSCOMM16, 0x376, 102, 0
439   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
440   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
441   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
442   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
443   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
444   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
445   - IDC_MSCOMM17, 0x376, 102, 0
446   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
447   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
448   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
449   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
450   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
451   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
452   - IDC_MSCOMM18, 0x376, 102, 0
453   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
454   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
455   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
456   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
457   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
458   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
459   - IDC_MSCOMM19, 0x376, 102, 0
460   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
461   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
462   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
463   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
464   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
465   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
466   - IDC_MSCOMM20, 0x376, 102, 0
467   -0x0013, 0x0000, 0x0043, 0x006f, 0x0070, 0x0079, 0x0072, 0x0069, 0x0067,
468   -0x0068, 0x0074, 0x0020, 0x0028, 0x0063, 0x0029, 0x0020, 0x0031, 0x0039,
469   -0x0039, 0x0034, 0x0020, 0x4321, 0x1234, 0x0008, 0x0000, 0x03ed, 0x0000,
470   -0x03ed, 0x0000, 0x5601, 0x648a, 0x0000, 0x0006, 0x0000, 0x0001, 0x0400,
471   -0x0000, 0x0200, 0x0000, 0x2580, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000,
472   -0x0000, 0x0000, 0x003f, 0x0000, 0x0001, 0x0000,
473   - 0
474   -END
475   -
476   -#endif // Chinese (P.R.C.) resources
477   -/////////////////////////////////////////////////////////////////////////////
478   -
479   -
480   -
481   -#ifndef APSTUDIO_INVOKED
482   -/////////////////////////////////////////////////////////////////////////////
483   -//
484   -// Generated from the TEXTINCLUDE 3 resource.
485   -//
486   -#define _AFX_NO_SPLITTER_RESOURCES
487   -#define _AFX_NO_OLE_RESOURCES
488   -#define _AFX_NO_TRACKER_RESOURCES
489   -#define _AFX_NO_PROPERTY_RESOURCES
490   -
491   -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
492   -#ifdef _WIN32
493   -LANGUAGE 4, 2
494   -#pragma code_page(936)
495   -#endif //_WIN32
496   -#include "res\BlueFlashTool.rc2" // non-Microsoft Visual C++ edited resources
497   -#include "l.chs\afxres.rc" // Standard components
498   -#endif
499   -
500   -/////////////////////////////////////////////////////////////////////////////
501   -#endif // not APSTUDIO_INVOKED
502   -
1   -// BlueFlashToolDlg.cpp : implementation file
2   -//
3   -
4   -#include "stdafx.h"
5   -#include "BlueFlashTool.h"
6   -#include "BlueFlashToolDlg.h"
7   -
8   -#ifdef _DEBUG
9   -#define new DEBUG_NEW
10   -#undef THIS_FILE
11   -static char THIS_FILE[] = __FILE__;
12   -#endif
13   -
14   -/////////////////////////////////////////////////////////////////////////////
15   -// CBlueFlashToolDlg dialog
16   -
17   -CBlueFlashToolDlg::CBlueFlashToolDlg(CWnd* pParent /*=NULL*/)
18   - : CDialog(CBlueFlashToolDlg::IDD, pParent)
19   -{
20   - //{{AFX_DATA_INIT(CBlueFlashToolDlg)
21   - // NOTE: the ClassWizard will add member initialization here
22   - //}}AFX_DATA_INIT
23   - // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
24   - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
25   -}
26   -
27   -void CBlueFlashToolDlg::DoDataExchange(CDataExchange* pDX)
28   -{
29   - CDialog::DoDataExchange(pDX);
30   - //{{AFX_DATA_MAP(CBlueFlashToolDlg)
31   - DDX_Control(pDX, IDC_MSCOMM0, mycom);
32   - //}}AFX_DATA_MAP
33   -}
34   -
35   -BEGIN_MESSAGE_MAP(CBlueFlashToolDlg, CDialog)
36   - //{{AFX_MSG_MAP(CBlueFlashToolDlg)
37   - ON_WM_PAINT()
38   - ON_WM_QUERYDRAGICON()
39   - //}}AFX_MSG_MAP
40   -END_MESSAGE_MAP()
41   -
42   -/////////////////////////////////////////////////////////////////////////////
43   -// CBlueFlashToolDlg message handlers
44   -
45   -BOOL CBlueFlashToolDlg::OnInitDialog()
46   -{
47   - CDialog::OnInitDialog();
48   -
49   - // Set the icon for this dialog. The framework does this automatically
50   - // when the application's main window is not a dialog
51   - SetIcon(m_hIcon, TRUE); // Set big icon
52   - SetIcon(m_hIcon, FALSE); // Set small icon
53   -
54   - // TODO: Add extra initialization here
55   -
56   - return TRUE; // return TRUE unless you set the focus to a control
57   -}
58   -
59   -// If you add a minimize button to your dialog, you will need the code below
60   -// to draw the icon. For MFC applications using the document/view model,
61   -// this is automatically done for you by the framework.
62   -
63   -void CBlueFlashToolDlg::OnPaint()
64   -{
65   - if (IsIconic())
66   - {
67   - CPaintDC dc(this); // device context for painting
68   -
69   - SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
70   -
71   - // Center icon in client rectangle
72   - int cxIcon = GetSystemMetrics(SM_CXICON);
73   - int cyIcon = GetSystemMetrics(SM_CYICON);
74   - CRect rect;
75   - GetClientRect(&rect);
76   - int x = (rect.Width() - cxIcon + 1) / 2;
77   - int y = (rect.Height() - cyIcon + 1) / 2;
78   -
79   - // Draw the icon
80   - dc.DrawIcon(x, y, m_hIcon);
81   - }
82   - else
83   - {
84   - CDialog::OnPaint();
85   - }
86   -}
87   -
88   -// The system calls this to obtain the cursor to display while the user drags
89   -// the minimized window.
90   -HCURSOR CBlueFlashToolDlg::OnQueryDragIcon()
91   -{
92   - return (HCURSOR) m_hIcon;
93   -}
1   -// BlueFlashToolDlg.h : header file
2   -//
3   -//{{AFX_INCLUDES()
4   -#include "mscomm.h"
5   -//}}AFX_INCLUDES
6   -
7   -#if !defined(AFX_BLUEFLASHTOOLDLG_H__DE44DC07_CA43_417C_A12F_149A2C736BB5__INCLUDED_)
8   -#define AFX_BLUEFLASHTOOLDLG_H__DE44DC07_CA43_417C_A12F_149A2C736BB5__INCLUDED_
9   -
10   -#if _MSC_VER > 1000
11   -#pragma once
12   -#endif // _MSC_VER > 1000
13   -
14   -/////////////////////////////////////////////////////////////////////////////
15   -// CBlueFlashToolDlg dialog
16   -
17   -class CBlueFlashToolDlg : public CDialog
18   -{
19   -// Construction
20   -public:
21   - CBlueFlashToolDlg(CWnd* pParent = NULL); // standard constructor
22   -
23   -// Dialog Data
24   - //{{AFX_DATA(CBlueFlashToolDlg)
25   - enum { IDD = IDD_BLUEFLASHTOOL_DIALOG };
26   - CMSComm mycom;
27   - //}}AFX_DATA
28   -
29   - // ClassWizard generated virtual function overrides
30   - //{{AFX_VIRTUAL(CBlueFlashToolDlg)
31   - protected:
32   - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
33   - //}}AFX_VIRTUAL
34   -
35   -// Implementation
36   -protected:
37   - HICON m_hIcon;
38   -
39   - // Generated message map functions
40   - //{{AFX_MSG(CBlueFlashToolDlg)
41   - virtual BOOL OnInitDialog();
42   - afx_msg void OnPaint();
43   - afx_msg HCURSOR OnQueryDragIcon();
44   - //}}AFX_MSG
45   - DECLARE_MESSAGE_MAP()
46   -};
47   -
48   -//{{AFX_INSERT_LOCATION}}
49   -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
50   -
51   -#endif // !defined(AFX_BLUEFLASHTOOLDLG_H__DE44DC07_CA43_417C_A12F_149A2C736BB5__INCLUDED_)
  1 +
  2 +/*-----------------------------------------------------------------------------
  3 +
  4 + This is a part of the Microsoft Source Code Samples.
  5 + Copyright (C) 1995 Microsoft Corporation.
  6 + All rights reserved.
  7 + This source code is only intended as a supplement to
  8 + Microsoft Development Tools and/or WinHelp documentation.
  9 + See these sources for detailed information regarding the
  10 + Microsoft samples programs.
  11 +
  12 + MODULE: Error.c
  13 +
  14 + PURPOSE: Implement error handling functions
  15 + called to report errors.
  16 +
  17 + FUNCTIONS:
  18 + ErrorExtender - Calls FormatMessage to translate error code to
  19 + error text
  20 + ErrorReporter - Reports errors to user
  21 + ErrorHandler - Reports errors, then exits the process
  22 + ErrorInComm - Reports errors, closes comm connection, then exits
  23 +
  24 +-----------------------------------------------------------------------------*/
  25 +
  26 +#include <windows.h>
  27 +#include "mttty.h"
  28 +
  29 +/*
  30 + Prototypes of functions called only in this module
  31 +*/
  32 +DWORD ErrorExtender(DWORD, char **);
  33 +
  34 +
  35 +/*-----------------------------------------------------------------------------
  36 +
  37 +FUNCTION: ErrorExtender(DWORD, char **)
  38 +
  39 +PURPOSE: Translates error codes into error strings
  40 +
  41 +PARAMETERS:
  42 + dwError - error code to be translated
  43 + szBuffer - pointer to error string buffer
  44 +
  45 +COMMENTS: If code can't be translated, then a 1 byte NULL string
  46 + created. The buffer, whether created by FormatMessage, or
  47 + directly is supposed to be freed by the caller.
  48 +
  49 +HISTORY: Date: Author: Comment:
  50 + 10/27/95 AllenD Wrote it
  51 +
  52 +-----------------------------------------------------------------------------*/
  53 +DWORD ErrorExtender(DWORD dwError, char ** szBuffer)
  54 +{
  55 + DWORD dwRes = 0;
  56 +
  57 + dwRes = FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | 80 ,
  58 + NULL, dwError,
  59 + MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
  60 + (LPTSTR) szBuffer, 0, NULL);
  61 +
  62 + if (dwRes == 0) {
  63 + *szBuffer = LocalAlloc(LPTR, 1);
  64 + return 1;
  65 + }
  66 +
  67 + return dwRes;
  68 +}
  69 +
  70 +
  71 +/*-----------------------------------------------------------------------------
  72 +
  73 +FUNCTION: ErrorReporter(char *)
  74 +
  75 +PURPOSE: Report error to user
  76 +
  77 +PARAMETERS:
  78 + szMessage - Error message from app
  79 +
  80 +COMMENTS: Reports error string in console and in debugger
  81 +
  82 +HISTORY: Date: Author: Comment:
  83 + 10/27/95 AllenD Wrote it
  84 +
  85 +-----------------------------------------------------------------------------*/
  86 +void ErrorReporter(char * szMessage)
  87 +{
  88 + char * szFormat = "Error %d: %s.\n\r%s\r\n"; // format for wsprintf
  89 + char * szExtended; // error string translated from error code
  90 + char * szFinal; // final string to report
  91 + DWORD dwExtSize;
  92 + DWORD dwErr;
  93 +
  94 + dwErr = GetLastError();
  95 +
  96 + /*
  97 + Get error string from system
  98 + */
  99 + dwExtSize = ErrorExtender(dwErr, &szExtended);
  100 +
  101 + /*
  102 + allocate buffer for error string from system, passed in string
  103 + and extra stuff from the szFormat string
  104 + */
  105 + szFinal = LocalAlloc(LPTR, strlen(szMessage) + dwExtSize + 30);
  106 +
  107 + if (szFinal == NULL) // if no final buffer, then can't format error
  108 + MessageBox(ghwndMain, "Cannot properly report error.", "Fatal Error", MB_OK);
  109 + else {
  110 + wsprintf(szFinal, szFormat, dwErr, szMessage, szExtended);
  111 +
  112 + OutputDebugString(szFinal);
  113 +
  114 + if (DISPLAYERRORS(TTYInfo))
  115 + MessageBox(ghwndMain, szFinal, NULL, MB_OK);
  116 +
  117 + LocalFree(szFinal); // free final buffer
  118 + }
  119 +
  120 + /*
  121 + free extended string buffer
  122 + */
  123 + LocalFree(szExtended);
  124 +
  125 + return;
  126 +}
  127 +
  128 +
  129 +/*-----------------------------------------------------------------------------
  130 +
  131 +FUNCTION: ErrorHandler( char * )
  132 +
  133 +PURPOSE: Handle a fatal error (before comm port is opened)
  134 +
  135 +PARAMETERS:
  136 + szMessage - Error message from app
  137 +
  138 +HISTORY: Date: Author: Comment:
  139 + 10/27/95 AllenD Wrote it
  140 +
  141 +-----------------------------------------------------------------------------*/
  142 +void ErrorHandler(char * szMessage)
  143 +{
  144 + ErrorReporter(szMessage);
  145 + ExitProcess(0);
  146 +}
  147 +
  148 +
  149 +/*-----------------------------------------------------------------------------
  150 +
  151 +FUNCTION: ErrorInComm( char * )
  152 +
  153 +PURPOSE: Handle a fatal error after comm port is opened
  154 +
  155 +PARAMETERS:
  156 + szMessage - Error message from app
  157 +
  158 +HISTORY: Date: Author: Comment:
  159 + 10/27/95 AllenD Wrote it
  160 +
  161 +-----------------------------------------------------------------------------*/
  162 +void ErrorInComm(char * szMessage)
  163 +{
  164 + ErrorReporter(szMessage);
  165 + BreakDownCommPort();
  166 + ExitProcess(0);
  167 +}
... ...
  1 +/*-----------------------------------------------------------------------------
  2 +
  3 + This is a part of the Microsoft Source Code Samples.
  4 + Copyright (C) 1995 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 + MODULE: Init.c
  12 +
  13 + PURPOSE: Intializes global data and comm port connects.
  14 + Closes comm ports and cleans up global data.
  15 +
  16 + FUNCTIONS:
  17 + GlobalInitialize - Init global variables and system objects
  18 + GlobalCleanup - cleanup global variables and system objects
  19 + ClearTTYContents - Clears the tty buffer
  20 + InitNewFont - Creates a new font for the TTY child window
  21 + CreateTTYInfo - Creates the dynamic tty info structure controlling
  22 + behavior of tty
  23 + DestroyTTYInfo - deallocates tty info structure
  24 + StartThreads - Starts worker threads when a port is opened
  25 + SetupCommPort - Opens the port for the first time
  26 + WaitForThreads - Sets the thread exit event and wait for worker
  27 + threads to exit
  28 + BreakDownCommPort - Closes a connection to the comm port
  29 + DisconnectOK - Asks user if it is ok to disconnect
  30 +
  31 +-----------------------------------------------------------------------------*/
  32 +
  33 +#include <windows.h>
  34 +#include <commctrl.h>
  35 +#include "mttty.h"
  36 +
  37 +#pragma comment(lib,"comctl32.lib")
  38 +
  39 +/*
  40 + Prototypes for functions called only within this file
  41 +*/
  42 +void StartThreads( void );
  43 +DWORD WaitForThreads( DWORD );
  44 +
  45 +/*
  46 + TimeoutsDefault
  47 + We need ReadIntervalTimeout here to cause the read operations
  48 + that we do to actually timeout and become overlapped.
  49 + Specifying 1 here causes ReadFile to return very quickly
  50 + so that our reader thread will continue execution.
  51 +*/
  52 +COMMTIMEOUTS gTimeoutsDefault = { 0x01, 0, 0, 0, 0 };
  53 +
  54 +extern char szFileName[MAX_PATH];
  55 +
  56 +void oem_init(void)
  57 +{
  58 + memset(szFileName,0,sizeof(szFileName));
  59 +}
  60 +
  61 +
  62 +/*-----------------------------------------------------------------------------
  63 +
  64 +FUNCTION: GlobalInitialize
  65 +
  66 +PURPOSE: Intializes global variables before any windows are created
  67 +
  68 +COMMENTS: Partner to GlobalCleanup
  69 +
  70 +HISTORY: Date: Author: Comment:
  71 + 10/27/95 AllenD Wrote it
  72 +
  73 +-----------------------------------------------------------------------------*/
  74 +void GlobalInitialize()
  75 +{
  76 + int cyMenuHeight, cyCaptionHeight, cyFrameHeight;
  77 +
  78 + oem_init();
  79 + //
  80 + // critical sections in status reporting & node management
  81 + //
  82 + InitializeCriticalSection(&gStatusCritical);
  83 + InitializeCriticalSection(&gcsWriterHeap);
  84 + InitializeCriticalSection(&gcsDataHeap);
  85 +
  86 + //
  87 + // status message event
  88 + //
  89 + ghStatusMessageEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  90 + if (ghStatusMessageEvent == NULL)
  91 + ErrorReporter("CreateEvent (Status message event)");
  92 +
  93 + //
  94 + // thread exit event
  95 + //
  96 + ghThreadExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
  97 + if (ghThreadExitEvent == NULL)
  98 + ErrorReporter("CreateEvent (Thread exit event)");
  99 +
  100 + //
  101 + // used in file transfer status bar
  102 + //
  103 + InitCommonControls();
  104 +
  105 + //
  106 + // font for status reporting control
  107 + //
  108 + ghFontStatus = CreateStatusEditFont();
  109 +
  110 + //
  111 + // the following are used for sizing the tty window and dialog windows
  112 + //
  113 + gwBaseY = HIWORD(GetDialogBaseUnits());
  114 + cyMenuHeight = GetSystemMetrics(SM_CYMENU);
  115 + cyCaptionHeight = GetSystemMetrics(SM_CYCAPTION);
  116 + cyFrameHeight = GetSystemMetrics(SM_CYFRAME);
  117 + gcyMinimumWindowHeight = cyMenuHeight + \
  118 + 4 * cyCaptionHeight + \
  119 + 2 * cyFrameHeight +
  120 + (SETTINGSFACTOR + STATUSFACTOR) * gwBaseY ;
  121 + return ;
  122 +}
  123 +
  124 +
  125 +/*-----------------------------------------------------------------------------
  126 +
  127 +FUNCTION: GlobalCleanup
  128 +
  129 +PURPOSE: Cleans up any global variables
  130 +
  131 +COMMENTS: Partner to GlobalInitialize
  132 +
  133 +HISTORY: Date: Author: Comment:
  134 + 10/27/95 AllenD Wrote it
  135 +
  136 +-----------------------------------------------------------------------------*/
  137 +void GlobalCleanup()
  138 +{
  139 + DeleteCriticalSection(&gStatusCritical);
  140 + DeleteCriticalSection(&gcsWriterHeap);
  141 + DeleteCriticalSection(&gcsDataHeap);
  142 + DeleteObject(ghFontStatus);
  143 + CloseHandle(ghStatusMessageEvent);
  144 + CloseHandle(ghThreadExitEvent);
  145 + HeapDestroy(ghStatusMessageHeap);
  146 + return;
  147 +}
  148 +
  149 +
  150 +/*-----------------------------------------------------------------------------
  151 +
  152 +FUNCTION: ClearTTYContents
  153 +
  154 +PURPOSE: Clears the tty buffer
  155 +
  156 +RETURN: always TRUE
  157 +
  158 +HISTORY: Date: Author: Comment:
  159 + 10/27/95 AllenD Wrote it
  160 +
  161 +-----------------------------------------------------------------------------*/
  162 +BOOL ClearTTYContents()
  163 +{
  164 + FillMemory(SCREEN(TTYInfo), MAXCOLS*MAXROWS, ' ');
  165 + return TRUE;
  166 +}
  167 +
  168 +
  169 +/*-----------------------------------------------------------------------------
  170 +
  171 +FUNCTION: InitNewFont(LOGFONT, COLORREF)
  172 +
  173 +PURPOSE: Prepares a font for use in the TTY screen
  174 +
  175 +PARAMETERS:
  176 + LogFont - New logical font for tty screen
  177 + rgbColor - New color for TTY painting
  178 +
  179 +COMMENTS: Called when a new connection is made, or the TTY font
  180 + is changed by the user.
  181 +
  182 +HISTORY: Date: Author: Comment:
  183 + 10/27/95 AllenD Wrote it
  184 +
  185 +-----------------------------------------------------------------------------*/
  186 +void InitNewFont(LOGFONT LogFont, COLORREF rgbColor)
  187 +{
  188 + TEXTMETRIC tm;
  189 + HDC hDC;
  190 +
  191 + //
  192 + // if old one exists, then I should delete it
  193 + //
  194 + if (HTTYFONT(TTYInfo))
  195 + DeleteObject(HTTYFONT(TTYInfo));
  196 +
  197 + LFTTYFONT(TTYInfo) = LogFont;
  198 + HTTYFONT(TTYInfo) = CreateFontIndirect(&(LFTTYFONT(TTYInfo)));
  199 + FGCOLOR(TTYInfo) = rgbColor;
  200 +
  201 + hDC = GetDC( ghwndMain ) ;
  202 + SelectObject( hDC, HTTYFONT( TTYInfo ) ) ;
  203 + GetTextMetrics( hDC, &tm ) ;
  204 + ReleaseDC( ghwndMain, hDC ) ;
  205 +
  206 + //
  207 + // character width and height
  208 + //
  209 + XCHAR( TTYInfo ) = tm.tmAveCharWidth ;
  210 + YCHAR( TTYInfo ) = tm.tmHeight + tm.tmExternalLeading ;
  211 +
  212 + XOFFSET( TTYInfo ) = 0 ;
  213 + YOFFSET( TTYInfo ) = YCHAR(TTYInfo) * ROW(TTYInfo);
  214 +}
  215 +
  216 +extern DWORD BaudTable[];
  217 +/*-----------------------------------------------------------------------------
  218 +
  219 +FUNCTION: InitTTYInfo
  220 +
  221 +PURPOSE: Initializes TTY structure
  222 +
  223 +COMMENTS: This structure is a collection of TTY attributes
  224 + used by all parts of this program
  225 +
  226 +HISTORY: Date: Author: Comment:
  227 + 10/27/95 AllenD Wrote it
  228 + 2/14/96 AllenD Removed npTTYInfo
  229 +
  230 +-----------------------------------------------------------------------------*/
  231 +BOOL InitTTYInfo()
  232 +{
  233 + //
  234 + // initialize generial TTY info
  235 + //
  236 + COMDEV( TTYInfo ) = NULL ;
  237 + CONNECTED( TTYInfo ) = FALSE ;
  238 + LOCALECHO( TTYInfo ) = FALSE ;
  239 + CURSORSTATE( TTYInfo ) = CS_HIDE ;
  240 + PORT( TTYInfo ) = 1 ;
  241 + BAUDRATE( TTYInfo ) = BaudTable[2] ;
  242 + BYTESIZE( TTYInfo ) = 8 ;
  243 + PARITY( TTYInfo ) = NOPARITY ;
  244 + STOPBITS( TTYInfo ) = ONESTOPBIT ;
  245 + AUTOWRAP( TTYInfo ) = TRUE;
  246 + NEWLINE( TTYInfo ) = FALSE;
  247 + XSIZE( TTYInfo ) = 0 ;
  248 + YSIZE( TTYInfo ) = 0 ;
  249 + XSCROLL( TTYInfo ) = 0 ;
  250 + YSCROLL( TTYInfo ) = 0 ;
  251 + COLUMN( TTYInfo ) = 0 ;
  252 + ROW( TTYInfo ) = MAXROWS - 1 ;
  253 + DISPLAYERRORS( TTYInfo ) = TRUE ;
  254 +
  255 + //
  256 + // timeouts
  257 + //
  258 + TIMEOUTSNEW( TTYInfo ) = gTimeoutsDefault;
  259 +
  260 + //
  261 + // read state and status events
  262 + //
  263 + gdwReceiveState = RECEIVE_TTY;
  264 + EVENTFLAGS( TTYInfo ) = EVENTFLAGS_DEFAULT;
  265 + FLAGCHAR( TTYInfo ) = FLAGCHAR_DEFAULT;
  266 +
  267 + //
  268 + // Flow Control Settings
  269 + //
  270 + DTRCONTROL( TTYInfo ) = DTR_CONTROL_ENABLE;
  271 + RTSCONTROL( TTYInfo ) = RTS_CONTROL_ENABLE;
  272 + XONCHAR( TTYInfo ) = ASCII_XON;
  273 + XOFFCHAR( TTYInfo ) = ASCII_XOFF;
  274 + XONLIMIT( TTYInfo ) = 0;
  275 + XOFFLIMIT( TTYInfo ) = 0;
  276 + CTSOUTFLOW( TTYInfo ) = FALSE;
  277 + DSROUTFLOW( TTYInfo ) = FALSE;
  278 + DSRINFLOW( TTYInfo ) = FALSE;
  279 + XONXOFFOUTFLOW(TTYInfo) = FALSE;
  280 + XONXOFFINFLOW(TTYInfo) = FALSE;
  281 + TXAFTERXOFFSENT(TTYInfo) = FALSE;
  282 +
  283 + NOREADING(TTYInfo) = FALSE;
  284 + NOWRITING(TTYInfo) = FALSE;
  285 + NOEVENTS(TTYInfo) = FALSE;
  286 + NOSTATUS(TTYInfo) = FALSE;
  287 + SHOWTIMEOUTS(TTYInfo) = FALSE;
  288 +
  289 + //
  290 + // setup default font information
  291 + //
  292 + LFTTYFONT( TTYInfo ).lfHeight = 20 ;
  293 + LFTTYFONT( TTYInfo ).lfWidth = 0 ;
  294 + LFTTYFONT( TTYInfo ).lfEscapement = 0 ;
  295 + LFTTYFONT( TTYInfo ).lfOrientation = 0 ;
  296 + LFTTYFONT( TTYInfo ).lfWeight = 0 ;
  297 + LFTTYFONT( TTYInfo ).lfItalic = 0 ;
  298 + LFTTYFONT( TTYInfo ).lfUnderline = 0 ;
  299 + LFTTYFONT( TTYInfo ).lfStrikeOut = 0 ;
  300 + LFTTYFONT( TTYInfo ).lfCharSet = ANSI_CHARSET;//OEM_CHARSET ;
  301 + LFTTYFONT( TTYInfo ).lfOutPrecision = OUT_DEFAULT_PRECIS ;
  302 + LFTTYFONT( TTYInfo ).lfClipPrecision = CLIP_DEFAULT_PRECIS ;
  303 + LFTTYFONT( TTYInfo ).lfQuality = DEFAULT_QUALITY ;
  304 + LFTTYFONT( TTYInfo ).lfPitchAndFamily = FIXED_PITCH | FF_MODERN ;
  305 + strcpy( LFTTYFONT( TTYInfo ).lfFaceName, "FixedSys" ) ;
  306 +// strcpy( LFTTYFONT( TTYInfo ).lfFaceName, "Courier New" ) ;
  307 +
  308 + InitNewFont( LFTTYFONT(TTYInfo), RGB(0,0,0));
  309 +
  310 + ClearTTYContents();
  311 +
  312 + return ( TRUE ) ;
  313 +}
  314 +
  315 +/*-----------------------------------------------------------------------------
  316 +
  317 +FUNCTION: DestroyTTYInfo
  318 +
  319 +PURPOSE: Frees objects associated with the TTYInfo structure
  320 +
  321 +HISTORY: Date: Author: Comment:
  322 + 10/27/95 AllenD Wrote it
  323 + 2/14/96 AllenD Removed npTTYInfo
  324 +
  325 +-----------------------------------------------------------------------------*/
  326 +void DestroyTTYInfo()
  327 +{
  328 + DeleteObject(HTTYFONT(TTYInfo));
  329 +}
  330 +
  331 +/*-----------------------------------------------------------------------------
  332 +
  333 +FUNCTION: StartThreads
  334 +
  335 +PURPOSE: Creates the Reader/Status and Writer threads
  336 +
  337 +HISTORY: Date: Author: Comment:
  338 + 10/27/95 AllenD Wrote it
  339 +
  340 +-----------------------------------------------------------------------------*/
  341 +void StartThreads(void)
  342 +{
  343 + DWORD dwReadStatId;
  344 + DWORD dwWriterId;
  345 +
  346 + READSTATTHREAD(TTYInfo) =
  347 + CreateThread( NULL,
  348 + 0,
  349 + (LPTHREAD_START_ROUTINE) ReaderAndStatusProc,
  350 + (LPVOID) ghWndTTY,
  351 + 0,
  352 + &dwReadStatId);
  353 +
  354 + if (READSTATTHREAD(TTYInfo) == NULL)
  355 + ErrorInComm("CreateThread(Reader/Status)");
  356 +
  357 + WRITERTHREAD(TTYInfo) =
  358 + CreateThread( NULL,
  359 + 0,
  360 + (LPTHREAD_START_ROUTINE) WriterProc,
  361 + (LPVOID) NULL,
  362 + 0,
  363 + &dwWriterId );
  364 +
  365 + if (WRITERTHREAD(TTYInfo) == NULL)
  366 + ErrorInComm("CreateThread (Writer)");
  367 +
  368 + return;
  369 +}
  370 +
  371 +/*-----------------------------------------------------------------------------
  372 +
  373 +FUNCTION: SetupCommPort( void )
  374 +
  375 +PURPOSE: Setup Communication Port with our settings
  376 +
  377 +RETURN:
  378 + Handle of comm port is successful
  379 + NULL is error occurs
  380 +
  381 +HISTORY: Date: Author: Comment:
  382 + 10/27/95 AllenD Wrote it
  383 +
  384 +-----------------------------------------------------------------------------*/
  385 +HANDLE SetupCommPort()
  386 +{
  387 + //
  388 + // get tty settings from settings dialog
  389 + //
  390 + UpdateTTYInfo();
  391 +
  392 + //
  393 + // open communication port handle
  394 + //
  395 + COMDEV( TTYInfo ) = CreateFile( gszPort,
  396 + GENERIC_READ | GENERIC_WRITE,
  397 + 0,
  398 + 0,
  399 + OPEN_EXISTING,
  400 + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
  401 + 0);
  402 +
  403 + if (COMDEV(TTYInfo) == INVALID_HANDLE_VALUE) {
  404 + ErrorReporter("CreateFile");
  405 + return NULL;
  406 + }
  407 +
  408 + //
  409 + // Save original comm timeouts and set new ones
  410 + //
  411 + if (!GetCommTimeouts( COMDEV(TTYInfo), &(TIMEOUTSORIG(TTYInfo))))
  412 + ErrorReporter("GetCommTimeouts");
  413 +
  414 + //
  415 + // Set port state
  416 + //
  417 + UpdateConnection();
  418 +
  419 + //
  420 + // set comm buffer sizes
  421 + //
  422 + SetupComm(COMDEV(TTYInfo), MAX_READ_BUFFER, MAX_WRITE_BUFFER);
  423 +
  424 + //
  425 + // raise DTR
  426 + //
  427 + if (!EscapeCommFunction(COMDEV(TTYInfo), SETDTR))
  428 + ErrorReporter("EscapeCommFunction (SETDTR)");
  429 +
  430 + //
  431 + // start threads and set initial thread state to not done
  432 + //
  433 + StartThreads();
  434 +
  435 + //
  436 + // set overall connect flag
  437 + //
  438 + CONNECTED( TTYInfo ) = TRUE ;
  439 +
  440 + return COMDEV(TTYInfo);
  441 +}
  442 +
  443 +/*-----------------------------------------------------------------------------
  444 +
  445 +FUNCTION: WaitForThreads(DWORD)
  446 +
  447 +PURPOSE: Waits a specified time for the worker threads to exit
  448 +
  449 +PARAMETERS:
  450 + dwTimeout - milliseconds to wait until timeout
  451 +
  452 +RETURN:
  453 + WAIT_OBJECT_0 - successful wait, threads are not running
  454 + WAIT_TIMEOUT - at least one thread is still running
  455 + WAIT_FAILED - failure in WaitForMultipleObjects
  456 +
  457 +HISTORY: Date: Author: Comment:
  458 + 10/27/95 AllenD Wrote it
  459 +
  460 +----------------------------------------------------------------------------*/
  461 +DWORD WaitForThreads(DWORD dwTimeout)
  462 +{
  463 + HANDLE hThreads[2];
  464 + DWORD dwRes;
  465 +
  466 + hThreads[0] = READSTATTHREAD(TTYInfo);
  467 + hThreads[1] = WRITERTHREAD(TTYInfo);
  468 +
  469 + //
  470 + // set thread exit event here
  471 + //
  472 + SetEvent(ghThreadExitEvent);
  473 +
  474 + dwRes = WaitForMultipleObjects(2, hThreads, TRUE, dwTimeout);
  475 + switch(dwRes)
  476 + {
  477 + case WAIT_OBJECT_0:
  478 + case WAIT_OBJECT_0 + 1:
  479 + dwRes = WAIT_OBJECT_0;
  480 + break;
  481 +
  482 + case WAIT_TIMEOUT:
  483 +
  484 + if (WaitForSingleObject(READSTATTHREAD(TTYInfo), 0) == WAIT_TIMEOUT)
  485 + OutputDebugString("Reader/Status Thread didn't exit.\n\r");
  486 +
  487 + if (WaitForSingleObject(WRITERTHREAD(TTYInfo), 0) == WAIT_TIMEOUT)
  488 + OutputDebugString("Writer Thread didn't exit.\n\r");
  489 +
  490 + break;
  491 +
  492 + default:
  493 + ErrorReporter("WaitForMultipleObjects");
  494 + break;
  495 + }
  496 +
  497 + //
  498 + // reset thread exit event here
  499 + //
  500 + ResetEvent(ghThreadExitEvent);
  501 +
  502 + return dwRes;
  503 +}
  504 +
  505 +/*-----------------------------------------------------------------------------
  506 +
  507 +FUNCTION: BreakDownCommPort
  508 +
  509 +PURPOSE: Closes a connection to a comm port
  510 +
  511 +RETURN:
  512 + TRUE - successful breakdown of port
  513 + FALSE - port isn't connected
  514 +
  515 +COMMENTS: Waits for threads to exit,
  516 + clears DTR, restores comm port timeouts, purges any i/o
  517 + and closes all pertinent handles
  518 +
  519 +HISTORY: Date: Author: Comment:
  520 + 10/27/95 AllenD Wrote it
  521 +
  522 +-----------------------------------------------------------------------------*/
  523 +BOOL BreakDownCommPort()
  524 +{
  525 + if (!CONNECTED(TTYInfo))
  526 + return FALSE;
  527 +
  528 + CONNECTED( TTYInfo ) = FALSE;
  529 +
  530 + //
  531 + // wait for the threads for a small period
  532 + //
  533 + if (WaitForThreads(20000) != WAIT_OBJECT_0)
  534 + /*
  535 + if threads haven't exited, then they will
  536 + interfere with a new connection. I must abort
  537 + the entire program.
  538 + */
  539 + ErrorHandler("Error closing port.");
  540 +
  541 + //
  542 + // lower DTR
  543 + //
  544 + if (!EscapeCommFunction(COMDEV(TTYInfo), CLRDTR))
  545 + ErrorReporter("EscapeCommFunction(CLRDTR)");
  546 +
  547 + //
  548 + // restore original comm timeouts
  549 + //
  550 + if (!SetCommTimeouts(COMDEV(TTYInfo), &(TIMEOUTSORIG(TTYInfo))))
  551 + ErrorReporter("SetCommTimeouts (Restoration to original)");
  552 +
  553 + //
  554 + // Purge reads/writes, input buffer and output buffer
  555 + //
  556 + if (!PurgeComm(COMDEV(TTYInfo), PURGE_FLAGS))
  557 + ErrorReporter("PurgeComm");
  558 +
  559 + CloseHandle(COMDEV(TTYInfo));
  560 + CloseHandle(READSTATTHREAD(TTYInfo));
  561 + CloseHandle(WRITERTHREAD(TTYInfo));
  562 +
  563 + return TRUE;
  564 +}
  565 +
  566 +/*-----------------------------------------------------------------------------
  567 +
  568 +FUNCTION: DisconnectOK
  569 +
  570 +PURPOSE: Asks user if it is OK to disconnect
  571 +
  572 +RETURN:
  573 + TRUE - OK to disconnect
  574 + FALSE - Disconnect not OK
  575 +
  576 +HISTORY: Date: Author: Comment:
  577 + 10/27/95 AllenD Wrote it
  578 +
  579 +-----------------------------------------------------------------------------*/
  580 +BOOL DisconnectOK()
  581 +{
  582 + char gszPort_Temp[20] = { 0 };
  583 + if (!CONNECTED(TTYInfo))
  584 + return TRUE;
  585 +
  586 +
  587 + GetDlgItemText(ghWndToolbarDlg, IDC_PORTCOMBO, gszPort, sizeof(gszPort));
  588 +
  589 + if (gszPort[3] - '0' > 0 && gszPort[4] - '0' > 0)
  590 + {
  591 + wsprintf(gszPort_Temp, "%s%d", "COM", (gszPort[3] - '0') * 10 + (gszPort[4] - '0'));
  592 + memset(gszPort, 20, sizeof(char));
  593 + strcpy(gszPort, gszPort_Temp);
  594 + }
  595 +
  596 + return ((MessageBox(ghwndMain, "OK to Disconnect?", gszPort, MB_YESNO)) == IDYES);
  597 +}
... ...
  1 +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2 +# ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3 +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4 +# PARTICULAR PURPOSE.
  5 +#
  6 +# Copyright (C) 1993 - 1996 Microsoft Corporation. All Rights Reserved.
  7 +#
  8 +#
  9 +# Processor independent makefile
  10 +
  11 +# Nmake macros for building Windows 32-Bit apps
  12 +!include <win32.mak>
  13 +
  14 +PROJ = MTTTY
  15 +
  16 +all: $(PROJ).exe
  17 +
  18 +# Define project specific macros
  19 +PROJ_OBJS = about.obj error.obj \
  20 + init.obj mttty.obj \
  21 + reader.obj readstat.obj \
  22 + settings.obj status.obj \
  23 + transfer.obj writer.obj
  24 +STD_LIBS = libcmt.lib kernel32.lib \
  25 + user32.lib gdi32.lib \
  26 + comdlg32.lib
  27 +EXTRA_LIBS = winmm.lib comctl32.lib
  28 +GLOBAL_DEP = mttty.h ttyinfo.h
  29 +RC_DEP = resource.h mttty.ico \
  30 + mttty2.ico mttty3.ico \
  31 + mttty4.ico
  32 +
  33 +# Inference rule for updating the object files
  34 +.c.obj:
  35 + $(cc) $(cdebug) /MT $(cflags) $(cvars) $*.c
  36 +
  37 +# Build rule for resource file
  38 +$(PROJ).res: $(PROJ).rc $(RC_DEP)
  39 + $(rc) $(rcflags) $(rcvars) /fo $(PROJ).res $(PROJ).rc
  40 +
  41 +# Build rule for EXE
  42 +$(PROJ).EXE: $(PROJ_OBJS) $(PROJ).res
  43 + $(link) $(linkdebug) $(guilflags) \
  44 + $(PROJ_OBJS) $(PROJ).res $(STD_LIBS) $(EXTRA_LIBS) \
  45 + -out:$(PROJ).exe
  46 +
  47 +
  48 +# Rules for cleaning out those old files
  49 +clean:
  50 + del *.bak
  51 + del *.pdb
  52 + del *.obj
  53 + del *.res
  54 + del *.exp
  55 + del *.map
  56 + del *.sbr
  57 + del *.bsc
  58 +
... ...
  1 +/*-----------------------------------------------------------------------------
  2 + This is a part of the Microsoft Source Code Samples.
  3 + Copyright (C) 1995 Microsoft Corporation.
  4 + All rights reserved.
  5 + This source code is only intended as a supplement to
  6 + Microsoft Development Tools and/or WinHelp documentation.
  7 + See these sources for detailed information regarding the
  8 + Microsoft samples programs.
  9 +
  10 + MODULE: mttty.c
  11 +
  12 + PURPOSE: Program entry point and window management
  13 +
  14 + FUNCTIONS:
  15 + WinMain - Program entry point
  16 + VersionCheck - Checks OS version to make sure we can run
  17 + InitializeApp - Global program initialization and window class
  18 + creation
  19 + MTTTYWndProc - main window procedure
  20 + CmdDispatch - Carries out menu commands
  21 + OpenTTYChildWindow - Creates the tty child window
  22 + ScrollTTYVert - Scroll TTY window vertically
  23 + ScrollTTYHorz - Scrolls TTY window horizontally
  24 + PaintTTY - Paints the TTY window
  25 + MoveTTYCursor - moves the tty cursor
  26 + SetTTYFocus - responds to tty window getting focus
  27 + KillTTYFocus - responds to tty window losing focus
  28 + SizeTTY - responds to tty window size changes
  29 + TTYChildProc - window procedure for TTY child window
  30 +
  31 +-----------------------------------------------------------------------------*/
  32 +
  33 +#include <windows.h>
  34 +#include "mttty.h"
  35 +
  36 +/*
  37 + Prototypes for functions called only within this file
  38 +*/
  39 +BOOL InitializeApp( HINSTANCE, int);
  40 +int WINAPI MTTTYWndProc( HWND, UINT, WPARAM, LPARAM );
  41 +int WINAPI TTYChildProc( HWND, UINT, WPARAM, LPARAM );
  42 +void CmdDispatch( int, HWND, LPARAM );
  43 +void OpenTTYChildWindow( HWND );
  44 +BOOL ScrollTTYVert( HWND, WORD, WORD );
  45 +BOOL ScrollTTYHorz( HWND, WORD, WORD );
  46 +BOOL VersionCheck();
  47 +BOOL PaintTTY( HWND );
  48 +
  49 +char szFileName[MAX_PATH];
  50 +
  51 +/*-----------------------------------------------------------------------------
  52 +
  53 +FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  54 +
  55 +PURPOSE: Start application and process all window messages
  56 +
  57 +PARAMETERS:
  58 + hInstance - this apps hinstance
  59 + hPrevInstance - previous instance of this app - always NULL
  60 + lpCmdLine - command line parameters
  61 + nCmdShow - code for showing window
  62 +
  63 +RETURN:
  64 + 1 for success
  65 + 0 for failure to start app
  66 +
  67 +HISTORY: Date: Author: Comment:
  68 + 10/27/95 AllenD Wrote it
  69 +
  70 +/*-----------------------------------------------------------------------------*/
  71 +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
  72 +{
  73 + MSG msg;
  74 +
  75 + if (!VersionCheck()) {
  76 + MessageBox(NULL, "MTTTY can't run on this version of Windows.", NULL, MB_OK);
  77 + return 0;
  78 + }
  79 +
  80 + if (!InitializeApp(hInstance, nShowCmd)) {
  81 + MessageBox(NULL, "MTTTY couldn't start!", NULL, MB_OK);
  82 + return 0;
  83 + }
  84 +
  85 + while (GetMessage(&msg, NULL, 0, 0)) {
  86 + if (!TranslateAccelerator( ghwndMain, ghAccel, &msg )) {
  87 + TranslateMessage( &msg ) ;
  88 + DispatchMessage( &msg ) ;
  89 + }
  90 + }
  91 +
  92 + return 1;
  93 +}
  94 +
  95 +
  96 +/*-----------------------------------------------------------------------------
  97 +
  98 +FUNCTION: VersionCheck(void)
  99 +
  100 +PURPOSE: Verifies that the correct version of Windows is running
  101 +
  102 +RETURN:
  103 + TRUE - success version for running this app
  104 + FALSE - correct version not verified
  105 +
  106 +HISTORY: Date: Author: Comment:
  107 + 11/20/95 AllenD Wrote it
  108 +
  109 +-----------------------------------------------------------------------------*/
  110 +BOOL VersionCheck()
  111 +{
  112 + gOSV.dwOSVersionInfoSize = sizeof(gOSV);
  113 + if (!GetVersionEx(&gOSV))
  114 + return FALSE;
  115 +
  116 + if (gOSV.dwPlatformId == VER_PLATFORM_WIN32s)
  117 + return FALSE;
  118 +
  119 + return TRUE ;
  120 +}
  121 +
  122 +
  123 +/*-----------------------------------------------------------------------------
  124 +
  125 +FUNCTION: InitializeApp(HINSTANCE, int)
  126 +
  127 +PURPOSE: GlobalInitialize, Register window classes
  128 + and create main window
  129 +
  130 +PARAMETERS:
  131 + hInst - HINSTANCE of this app
  132 + nShowCmd - code for showing this window
  133 +
  134 +RETURN:
  135 + TRUE - successful inititialization of this app
  136 + FALSE - failure to init app
  137 +
  138 +HISTORY: Date: Author: Comment:
  139 + 10/27/95 AllenD Wrote it
  140 +
  141 +-----------------------------------------------------------------------------*/
  142 +BOOL InitializeApp(HINSTANCE hInst, int nShowCmd)
  143 +{
  144 + WNDCLASS wc = {0};
  145 +
  146 + GlobalInitialize(); // get all global variables initialized to defaults
  147 +
  148 + //
  149 + // setup program's main window class
  150 + //
  151 + wc.lpfnWndProc = (WNDPROC) MTTTYWndProc;
  152 + wc.hInstance = hInst;
  153 + wc.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_TITLE));
  154 + wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  155 + wc.lpszMenuName = MAKEINTRESOURCE(IDR_MTTTYMENU);
  156 + wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1) ;
  157 + wc.lpszClassName = "MTTTYClass";
  158 +
  159 + if (!RegisterClass(&wc)) {
  160 + GlobalCleanup();
  161 + return FALSE;
  162 + }
  163 +
  164 + //
  165 + // setup program's tty child window class
  166 + //
  167 + wc.lpfnWndProc = (WNDPROC) TTYChildProc;
  168 + wc.hInstance = hInst;
  169 + wc.hCursor = LoadCursor(NULL, IDC_IBEAM);
  170 + wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
  171 + wc.lpszClassName = "MTTTYChildClass";
  172 + wc.lpszMenuName = NULL;
  173 + wc.hIcon = NULL;
  174 +
  175 + if (!RegisterClass(&wc)) {
  176 + GlobalCleanup();
  177 + return FALSE;
  178 + }
  179 +
  180 + //
  181 + // create main window
  182 + //
  183 + ghwndMain = CreateWindow("MTTTYClass", "OPTEK",
  184 + WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
  185 + STARTXWINDOW, STARTYWINDOW,
  186 + MAXXWINDOW, MAXYWINDOW,
  187 + NULL, NULL, hInst, NULL);
  188 +
  189 + if (ghwndMain == NULL) {
  190 + GlobalCleanup();
  191 + return FALSE;
  192 + }
  193 +
  194 + ShowWindow( ghwndMain, nShowCmd ) ;
  195 + UpdateWindow( ghwndMain ) ;
  196 +
  197 + ghInst = hInst;
  198 + ghAccel = LoadAccelerators( hInst, MAKEINTRESOURCE( IDR_MTTTYACCELERATOR) ) ;
  199 +
  200 + return TRUE;
  201 +}
  202 +
  203 +
  204 +/*-----------------------------------------------------------------------------
  205 +
  206 +FUNCTION: MTTTYWndProc(HWND, UINT, WPARAM, LPARAM)
  207 +
  208 +PURPOSE: Window Procedure for main window
  209 +
  210 +PARAMETERS:
  211 + hwnd - window handle
  212 + message - window message
  213 + wParam - window message parameter (depends on message)
  214 + lParam - window message parameter (depends on message)
  215 +
  216 +RETURN:
  217 + If message is process, return value is 0
  218 + If message is not processed, then it is passed to DefWindowProc
  219 + and the return value from that function is returned
  220 +
  221 +HISTORY: Date: Author: Comment:
  222 + 10/27/95 AllenD Wrote it
  223 +
  224 +-----------------------------------------------------------------------------*/
  225 +int WINAPI MTTTYWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  226 +{
  227 + switch (message)
  228 + {
  229 + case WM_CREATE:
  230 + //
  231 + // since main window is created, I can now open all other windows
  232 + //
  233 + InitTTYInfo();
  234 + OpenTTYChildWindow(hwnd);
  235 + OpenSettingsToolbar(hwnd);
  236 + OpenStatusToolbar(hwnd);
  237 + ChangeConnection(hwnd, CONNECTED(TTYInfo));
  238 + break;
  239 +
  240 + case WM_DESTROY:
  241 + //
  242 + // since main windows is being destroyed, so same to other windows
  243 + //
  244 + DestroyTTYInfo();
  245 + DestroyWindow(ghWndToolbarDlg);
  246 + DestroyWindow(ghWndStatusDlg);
  247 + DestroyWindow(ghWndTTY);
  248 +
  249 + GlobalCleanup();
  250 + PostQuitMessage(0);
  251 + break;
  252 +
  253 + case WM_GETMINMAXINFO:
  254 + {
  255 + //
  256 + // make sure that main window doesn't get smaller than
  257 + // the minimum child windows.
  258 + //
  259 + LPMINMAXINFO lpTemp;
  260 + POINT ptTemp;
  261 +
  262 + lpTemp = (LPMINMAXINFO) lParam;
  263 +
  264 + ptTemp.x = (long) lpTemp->ptMinTrackSize.x;
  265 + ptTemp.y = (long) gcyMinimumWindowHeight;
  266 +
  267 + lpTemp->ptMinTrackSize = ptTemp;
  268 + }
  269 +
  270 + break;
  271 +
  272 + case WM_SIZE:
  273 + {
  274 + //
  275 + // main window size has changed,
  276 + // so I need to change the positions of child windows
  277 + //
  278 + WORD wTop;
  279 + WORD wHeight;
  280 + WORD wWidth = LOWORD(lParam);
  281 +
  282 + //
  283 + // put Settings window at top
  284 + //
  285 + wHeight = SETTINGSFACTOR*gwBaseY;
  286 + wTop = 0;
  287 + MoveWindow(ghWndToolbarDlg, 0,wTop, wWidth, wHeight, TRUE);
  288 +
  289 + //
  290 + // put Status window at bottom
  291 + //
  292 + wHeight = STATUSFACTOR*gwBaseY;
  293 + wTop = HIWORD(lParam) - wHeight;
  294 + MoveWindow(ghWndStatusDlg, 0, wTop, wWidth, wHeight, TRUE);
  295 +
  296 + //
  297 + // put TTTY window right in the middle
  298 + // height = whole window - height of two previous windows
  299 + //
  300 + wHeight = HIWORD(lParam) - ((STATUSFACTOR + SETTINGSFACTOR)*gwBaseY);
  301 + wTop = SETTINGSFACTOR*gwBaseY;
  302 + MoveWindow(ghWndTTY, 0, wTop, wWidth, wHeight, TRUE);
  303 + }
  304 +
  305 + break;
  306 +
  307 + case WM_COMMAND:
  308 + CmdDispatch(LOWORD(wParam), hwnd, lParam);
  309 + break;
  310 +
  311 + case WM_CHAR:
  312 + SetFocus(ghWndTTY);
  313 + SendMessage(ghWndTTY, WM_CHAR, wParam, lParam);
  314 + break;
  315 +
  316 + case WM_CLOSE:
  317 + /* if (DisconnectOK()) {
  318 + if (CONNECTED(TTYInfo)) {
  319 + if (TRANSFERRING(TTYInfo))
  320 + TransferFileTextEnd();
  321 + BreakDownCommPort();
  322 + }
  323 + DestroyWindow(hwnd);
  324 + }*/
  325 + if (CONNECTED(TTYInfo)) {
  326 + if (TRANSFERRING(TTYInfo))
  327 + TransferFileTextEnd();
  328 + BreakDownCommPort();
  329 + }
  330 + DestroyWindow(hwnd);
  331 + break;
  332 +
  333 + default:
  334 + return DefWindowProc(hwnd, message, wParam, lParam);
  335 + }
  336 +
  337 + return 0L;
  338 +}
  339 +
  340 +
  341 +/*-----------------------------------------------------------------------------
  342 +
  343 +FUNCTION: CmdDispatch(int, HWND)
  344 +
  345 +PURPOSE: Responds to menu selections
  346 +
  347 +PARAMETERS:
  348 + iMenuChoice - ID of menu choice (from resource file)
  349 + hwnd - window handle of menu owner
  350 +
  351 +HISTORY: Date: Author: Comment:
  352 + 10/27/95 AllenD Wrote it
  353 +
  354 +-----------------------------------------------------------------------------*/
  355 +void CmdDispatch(int iMenuChoice, HWND hwnd, LPARAM lParam)
  356 +{
  357 +
  358 + switch (iMenuChoice)
  359 + {
  360 + case ID_HELP_ABOUTMTTTY:
  361 + CmdAbout(hwnd);
  362 + break;
  363 +
  364 + case ID_TRANSFER_SENDFILETEXT:
  365 + {
  366 + char * szFilter = "bin Files\0*.bin\0";
  367 + OPENFILENAME ofn = {0};
  368 +
  369 + ofn.lStructSize = sizeof(OPENFILENAME);
  370 + ofn.hwndOwner = hwnd;
  371 + ofn.lpstrFilter = szFilter;
  372 + ofn.lpstrFile = szFileName;
  373 + ofn.nMaxFile = MAX_PATH;
  374 + ofn.lpstrTitle = "Select file";
  375 + ofn.Flags = OFN_FILEMUSTEXIST;
  376 +
  377 + if (!GetOpenFileName(&ofn))
  378 + break;
  379 +
  380 + UpdateStatus(szFileName);
  381 + //if (TRUE)
  382 + // TransferFileTextStart(szFileName);
  383 + }
  384 + break;
  385 +
  386 + case ID_TRANSFER_RECEIVEFILETEXT:
  387 + {
  388 + char * szFilter = "Text Files\0*.TXT\0";
  389 + OPENFILENAME ofn = {0};
  390 +
  391 + ofn.lStructSize = sizeof(OPENFILENAME);
  392 + ofn.hwndOwner = hwnd;
  393 + ofn.lpstrFilter = szFilter;
  394 + ofn.lpstrFile = szFileName;
  395 + ofn.nMaxFile = MAX_PATH;
  396 + ofn.lpstrTitle = "Receive File";
  397 + ofn.Flags = OFN_OVERWRITEPROMPT;
  398 +
  399 + if (!GetSaveFileName(&ofn))
  400 + break;
  401 +
  402 + ReceiveFileText(szFileName);
  403 + }
  404 + break;
  405 +
  406 + case ID_TRANSFER_ABORTSENDING:
  407 + // was abort sent from the abort button?
  408 + if (LOWORD(lParam) == IDC_ABORTBTN) {
  409 + // am I in a transfer repeat?
  410 + if (REPEATING(TTYInfo))
  411 + TransferRepeatDestroy();
  412 + // am I in a normal recieve state, then stop sending
  413 + else if (gdwReceiveState == RECEIVE_TTY)
  414 + TransferFileTextEnd();
  415 + // if I am not in a normal receive state, then stop capturing
  416 + else
  417 + gfAbortTransfer = TRUE;
  418 + }
  419 + else
  420 + // transfer abort was sent by transfer thread
  421 + TransferFileTextEnd();
  422 + break;
  423 +
  424 + case ID_TRANSFER_SENDREPEATEDLY:
  425 + {
  426 + DWORD dwFreq;
  427 + char * szFilter = "Text Files\0*.TXT\0";
  428 + OPENFILENAME ofn = {0};
  429 +
  430 + ofn.lStructSize = sizeof(OPENFILENAME);
  431 + ofn.hwndOwner = hwnd;
  432 + ofn.lpstrFilter = szFilter;
  433 + ofn.lpstrFile = szFileName;
  434 + ofn.nMaxFile = MAX_PATH;
  435 + ofn.lpstrTitle = "Send File Repeatedly";
  436 + ofn.Flags = OFN_FILEMUSTEXIST;
  437 +
  438 + if (!GetOpenFileName(&ofn))
  439 + break;
  440 +
  441 + dwFreq = GetAFrequency();
  442 +
  443 + TransferRepeatCreate(szFileName, dwFreq);
  444 + }
  445 + break;
  446 +
  447 + case ID_TRANSFER_ABORTREPEATEDSENDING:
  448 + TransferRepeatDestroy();
  449 + break;
  450 +
  451 + case ID_TTY_CLEAR:
  452 + ClearTTYContents();
  453 + InvalidateRect(ghWndTTY, NULL, TRUE);
  454 + break;
  455 +
  456 + // The following correspond to menu choices and buttons in the settings dlog
  457 + case IDC_FONTBTN:
  458 + case IDC_SENDBTN:
  459 + case IDC_COMMEVENTSBTN:
  460 + case IDC_FLOWCONTROLBTN:
  461 + case IDC_TIMEOUTSBTN:
  462 + SendMessage(ghWndToolbarDlg, WM_COMMAND, (WPARAM) iMenuChoice, (LPARAM) GetDlgItem(ghWndToolbarDlg, iMenuChoice));
  463 + break;
  464 +
  465 + case ID_FILE_CONNECT:
  466 + if (SetupCommPort() != NULL)
  467 + ChangeConnection(hwnd, CONNECTED(TTYInfo));
  468 + break;
  469 +
  470 + case ID_FILE_DISCONNECT:
  471 + if (BreakDownCommPort())
  472 + ChangeConnection(hwnd, CONNECTED(TTYInfo));
  473 + break;
  474 +
  475 + case ID_FILE_EXIT:
  476 + PostMessage(hwnd, WM_CLOSE, 0, 0);
  477 + break;
  478 + }
  479 + return;
  480 +}
  481 +
  482 +
  483 +/*-----------------------------------------------------------------------------
  484 +
  485 +FUNCTION: OpenTTYChildWindow(HWND)
  486 +
  487 +PURPOSE: Creates the TTY Child Window
  488 +
  489 +PARAMETERS:
  490 + hWnd - parent window handle of TTY child window
  491 +
  492 +COMMENTS: This window is actually the TTY Screen
  493 +
  494 +HISTORY: Date: Author: Comment:
  495 + 10/27/95 AllenD Wrote it
  496 +
  497 +/*-----------------------------------------------------------------------------*/
  498 +void OpenTTYChildWindow(HWND hWnd)
  499 +{
  500 + ghWndTTY = CreateWindow( "MTTTYChildClass", "TTY Window",
  501 + WS_CHILD | WS_VISIBLE | WS_VSCROLL,
  502 + 0,0,
  503 + 0,0,
  504 + hWnd, (HMENU)ID_TTYWINDOW, ghInst, NULL);
  505 + if (ghWndTTY == NULL)
  506 + ErrorReporter("Can't Create TTY Child Window");
  507 +
  508 + return;
  509 +}
  510 +
  511 +
  512 +//---------------------------------------------------------------------------
  513 +// BOOL NEAR ScrollTTYVert( HWND hWnd, WORD wScrollCmd, WORD wScrollPos )
  514 +//
  515 +// Description:
  516 +// Scrolls TTY window vertically.
  517 +//
  518 +// Parameters:
  519 +// HWND hWnd
  520 +// handle to TTY window
  521 +//
  522 +// WORD wScrollCmd
  523 +// type of scrolling we're doing
  524 +//
  525 +// WORD wScrollPos
  526 +// scroll position
  527 +//
  528 +// History: Date Author Comment
  529 +// 5/ 8/91 BryanW Wrote it.
  530 +// 10/27/95 AllenD Included it for MTTTY Sample.
  531 +//
  532 +//---------------------------------------------------------------------------
  533 +BOOL NEAR ScrollTTYVert( HWND hWnd, WORD wScrollCmd, WORD wScrollPos )
  534 +{
  535 + int nScrollAmt ;
  536 +
  537 + switch (wScrollCmd)
  538 + {
  539 + case SB_TOP:
  540 + nScrollAmt = -YOFFSET( TTYInfo ) ;
  541 + break ;
  542 +
  543 + case SB_BOTTOM:
  544 + nScrollAmt = YSCROLL( TTYInfo ) - YOFFSET( TTYInfo ) ;
  545 + break ;
  546 +
  547 + case SB_PAGEUP:
  548 + nScrollAmt = -YSIZE( TTYInfo ) ;
  549 + break ;
  550 +
  551 + case SB_PAGEDOWN:
  552 + nScrollAmt = YSIZE( TTYInfo ) ;
  553 + break ;
  554 +
  555 + case SB_LINEUP:
  556 + nScrollAmt = -YCHAR( TTYInfo ) ;
  557 + break ;
  558 +
  559 + case SB_LINEDOWN:
  560 + nScrollAmt = YCHAR( TTYInfo ) ;
  561 + break ;
  562 +
  563 + case SB_THUMBPOSITION:
  564 + nScrollAmt = wScrollPos - YOFFSET( TTYInfo ) ;
  565 + break ;
  566 +
  567 + default:
  568 + return ( FALSE ) ;
  569 + }
  570 +
  571 + if ((YOFFSET( TTYInfo ) + nScrollAmt) > YSCROLL( TTYInfo ))
  572 + nScrollAmt = YSCROLL( TTYInfo ) - YOFFSET( TTYInfo ) ;
  573 +
  574 + if ((YOFFSET( TTYInfo ) + nScrollAmt) < 0)
  575 + nScrollAmt = -YOFFSET( TTYInfo ) ;
  576 +
  577 +
  578 +
  579 + if (nScrollAmt != 0)
  580 + {
  581 + YOFFSET( TTYInfo ) = YOFFSET( TTYInfo ) + nScrollAmt ;
  582 +
  583 + SetScrollPos( hWnd, SB_VERT, YOFFSET( TTYInfo ), TRUE ) ;
  584 +
  585 + ScrollWindowEx( hWnd, 0, -nScrollAmt, NULL, NULL, NULL, NULL, SW_INVALIDATE | SW_ERASE) ;
  586 + }
  587 +
  588 +
  589 + return ( TRUE ) ;
  590 +
  591 +} // end of ScrollTTYVert()
  592 +
  593 +//---------------------------------------------------------------------------
  594 +// BOOL NEAR ScrollTTYHorz( HWND hWnd, WORD wScrollCmd, WORD wScrollPos )
  595 +//
  596 +// Description:
  597 +// Scrolls TTY window horizontally.
  598 +//
  599 +// Parameters:
  600 +// HWND hWnd
  601 +// handle to TTY window
  602 +//
  603 +// WORD wScrollCmd
  604 +// type of scrolling we're doing
  605 +//
  606 +// WORD wScrollPos
  607 +// scroll position
  608 +//
  609 +// History: Date Author Comment
  610 +// 5/ 8/91 BryanW Wrote it.
  611 +// 10/27/95 AllenD Included it for MTTTY Sample.
  612 +//
  613 +//---------------------------------------------------------------------------
  614 +BOOL NEAR ScrollTTYHorz( HWND hWnd, WORD wScrollCmd, WORD wScrollPos )
  615 +{
  616 + int nScrollAmt ;
  617 +
  618 + switch (wScrollCmd)
  619 + {
  620 + case SB_TOP:
  621 + nScrollAmt = -XOFFSET( TTYInfo ) ;
  622 + break ;
  623 +
  624 + case SB_BOTTOM:
  625 + nScrollAmt = XSCROLL( TTYInfo ) - XOFFSET( TTYInfo ) ;
  626 + break ;
  627 +
  628 + case SB_PAGEUP:
  629 + nScrollAmt = -XSIZE( TTYInfo ) ;
  630 + break ;
  631 +
  632 + case SB_PAGEDOWN:
  633 + nScrollAmt = XSIZE( TTYInfo ) ;
  634 + break ;
  635 +
  636 + case SB_LINEUP:
  637 + nScrollAmt = -XCHAR( TTYInfo ) ;
  638 + break ;
  639 +
  640 + case SB_LINEDOWN:
  641 + nScrollAmt = XCHAR( TTYInfo ) ;
  642 + break ;
  643 +
  644 + case SB_THUMBPOSITION:
  645 + nScrollAmt = wScrollPos - XOFFSET( TTYInfo ) ;
  646 + break ;
  647 +
  648 + default:
  649 + return ( FALSE ) ;
  650 + }
  651 + if ((XOFFSET( TTYInfo ) + nScrollAmt) > XSCROLL( TTYInfo ))
  652 + nScrollAmt = XSCROLL( TTYInfo ) - XOFFSET( TTYInfo ) ;
  653 + if ((XOFFSET( TTYInfo ) + nScrollAmt) < 0)
  654 + nScrollAmt = -XOFFSET( TTYInfo ) ;
  655 + ScrollWindowEx( hWnd, -nScrollAmt, 0, NULL, NULL, NULL, NULL, SW_INVALIDATE | SW_ERASE) ;
  656 + XOFFSET( TTYInfo ) = XOFFSET( TTYInfo ) + nScrollAmt ;
  657 + SetScrollPos( hWnd, SB_HORZ, XOFFSET( TTYInfo ), TRUE ) ;
  658 +
  659 + return ( TRUE ) ;
  660 +
  661 +} // end of ScrollTTYHorz()
  662 +
  663 +//---------------------------------------------------------------------------
  664 +// BOOL NEAR PaintTTY( HWND hWnd )
  665 +//
  666 +// Description:
  667 +// Paints the rectangle determined by the paint struct of
  668 +// the DC.
  669 +//
  670 +// Parameters:
  671 +// HWND hWnd
  672 +// handle to TTY window (as always)
  673 +//
  674 +// History: Date Author Comment
  675 +// 5/ 9/91 BryanW Wrote it.
  676 +// 10/22/91 BryanW Problem with background color
  677 +// and "off by one" fixed.
  678 +//
  679 +// 2/25/92 BryanW Off-by-one not quite fixed...
  680 +// also resolved min/max problem
  681 +// for windows extended beyond
  682 +// the "TTY display".
  683 +//
  684 +// 10/27/95 AllenD Included it for MTTTY Sample.
  685 +//
  686 +//---------------------------------------------------------------------------
  687 +BOOL NEAR PaintTTY( HWND hWnd )
  688 +{
  689 + PAINTSTRUCT ps ;
  690 + HFONT hOldFont ;
  691 + RECT rect ;
  692 + HDC hDC ;
  693 + int nRow, nCol, nEndRow, nEndCol;
  694 + int nCount, nHorzPos, nVertPos ;
  695 +
  696 + hDC = BeginPaint( hWnd, &ps ) ;
  697 + hOldFont = SelectObject( hDC, HTTYFONT( TTYInfo ) ) ;
  698 + SetTextColor( hDC, FGCOLOR( TTYInfo ) ) ;
  699 + SetBkColor( hDC, GetSysColor( COLOR_WINDOW ) ) ;
  700 + rect = ps.rcPaint ;
  701 + nRow =
  702 + min( MAXROWS - 1,
  703 + max( 0, (rect.top + YOFFSET( TTYInfo )) / YCHAR( TTYInfo ) ) ) ;
  704 + nEndRow =
  705 + min( MAXROWS - 1,
  706 + ((rect.bottom + YOFFSET( TTYInfo ) - 1) / YCHAR( TTYInfo ) ) ) ;
  707 + nCol =
  708 + min( MAXCOLS - 1,
  709 + max( 0, (rect.left + XOFFSET( TTYInfo )) / XCHAR( TTYInfo ) ) ) ;
  710 + nEndCol =
  711 + min( MAXCOLS - 1,
  712 + ((rect.right + XOFFSET( TTYInfo ) - 1) / XCHAR( TTYInfo ) ) ) ;
  713 + nCount = nEndCol - nCol + 1 ;
  714 + for (; nRow <= nEndRow; nRow++)
  715 + {
  716 + nVertPos = (nRow * YCHAR( TTYInfo )) - YOFFSET( TTYInfo ) ;
  717 + nHorzPos = (nCol * XCHAR( TTYInfo )) - XOFFSET( TTYInfo ) ;
  718 + rect.top = nVertPos ;
  719 + rect.bottom = nVertPos + YCHAR( TTYInfo ) ;
  720 + rect.left = nHorzPos ;
  721 + rect.right = nHorzPos + XCHAR( TTYInfo ) * nCount ;
  722 + SetBkMode( hDC, OPAQUE ) ;
  723 + ExtTextOut( hDC, nHorzPos, nVertPos, ETO_OPAQUE | ETO_CLIPPED, &rect,
  724 + (LPSTR)( SCREEN( TTYInfo ) + nRow * MAXCOLS + nCol ),
  725 + nCount, NULL ) ;
  726 + }
  727 + SelectObject( hDC, hOldFont ) ;
  728 + EndPaint( hWnd, &ps ) ;
  729 + MoveTTYCursor( hWnd ) ;
  730 + return ( TRUE ) ;
  731 +
  732 +} // end of PaintTTY()
  733 +
  734 +//---------------------------------------------------------------------------
  735 +// BOOL NEAR MoveTTYCursor( HWND hWnd )
  736 +//
  737 +// Description:
  738 +// Moves caret to current position.
  739 +//
  740 +// Parameters:
  741 +// HWND hWnd
  742 +// handle to TTY window
  743 +//
  744 +// History: Date Author Comment
  745 +// 5/ 9/91 BryanW Wrote it.
  746 +// 10/27/95 AllenD Included it for MTTTY Sample.
  747 +//
  748 +//---------------------------------------------------------------------------
  749 +BOOL NEAR MoveTTYCursor( HWND hWnd )
  750 +{
  751 + if (CONNECTED( TTYInfo ) && (CURSORSTATE( TTYInfo ) & CS_SHOW))
  752 + SetCaretPos( (COLUMN( TTYInfo ) * XCHAR( TTYInfo )) -
  753 + XOFFSET( TTYInfo ),
  754 + (ROW( TTYInfo ) * YCHAR( TTYInfo )) -
  755 + YOFFSET( TTYInfo ) ) ;
  756 +
  757 + return ( TRUE ) ;
  758 +
  759 +} // end of MoveTTYCursor()
  760 +
  761 +//---------------------------------------------------------------------------
  762 +// BOOL NEAR SetTTYFocus( HWND hWnd )
  763 +//
  764 +// Description:
  765 +// Sets the focus to the TTY window also creates caret.
  766 +//
  767 +// Parameters:
  768 +// HWND hWnd
  769 +// handle to TTY window
  770 +//
  771 +// History: Date Author Comment
  772 +// 5/ 9/91 BryanW Wrote it.
  773 +// 10/27/95 AllenD Included it for MTTTY Sample.
  774 +//
  775 +//---------------------------------------------------------------------------
  776 +BOOL NEAR SetTTYFocus( HWND hWnd )
  777 +{
  778 + if (CONNECTED(TTYInfo) && (CURSORSTATE( TTYInfo ) != CS_SHOW) )
  779 + {
  780 + CreateCaret( hWnd, NULL, XCHAR( TTYInfo ), YCHAR( TTYInfo ) ) ;
  781 + ShowCaret( hWnd ) ;
  782 + CURSORSTATE( TTYInfo ) = CS_SHOW ;
  783 + }
  784 +
  785 + MoveTTYCursor( hWnd ) ;
  786 + return ( TRUE ) ;
  787 +
  788 +} // end of SetTTYFocus()
  789 +
  790 +//---------------------------------------------------------------------------
  791 +// BOOL NEAR KillTTYFocus( HWND hWnd )
  792 +//
  793 +// Description:
  794 +// Kills TTY focus and destroys the caret.
  795 +//
  796 +// Parameters:
  797 +// HWND hWnd
  798 +// handle to TTY window
  799 +//
  800 +// History: Date Author Comment
  801 +// 5/ 9/91 BryanW Wrote it.
  802 +// 10/27/95 AllenD Included it for MTTTY Sample.
  803 +//
  804 +//---------------------------------------------------------------------------
  805 +BOOL NEAR KillTTYFocus( HWND hWnd )
  806 +{
  807 + if (CURSORSTATE( TTYInfo ) != CS_HIDE)
  808 + {
  809 + HideCaret( hWnd ) ;
  810 + DestroyCaret() ;
  811 + CURSORSTATE( TTYInfo ) = CS_HIDE ;
  812 + }
  813 + return ( TRUE ) ;
  814 +
  815 +} // end of KillTTYFocus()
  816 +
  817 +
  818 +//---------------------------------------------------------------------------
  819 +// BOOL NEAR SizeTTY( HWND hWnd, WORD wVertSize, WORD wHorzSize )
  820 +//
  821 +// Description:
  822 +// Sizes TTY and sets up scrolling regions.
  823 +//
  824 +// Parameters:
  825 +// HWND hWnd
  826 +// handle to TTY window
  827 +//
  828 +// WORD wVertSize
  829 +// new vertical size
  830 +//
  831 +// WORD wHorzSize
  832 +// new horizontal size
  833 +//
  834 +// History: Date Author Comment
  835 +// 5/ 8/ 91 BryanW Wrote it
  836 +// 10/27/95 AllenD Included it for MTTTY Sample.
  837 +//
  838 +//---------------------------------------------------------------------------
  839 +BOOL NEAR SizeTTY( HWND hWnd, WORD wWidth, WORD wHeight )
  840 +{
  841 + int nScrollAmt ;
  842 +
  843 + //
  844 + // adjust vert settings
  845 + //
  846 + YSIZE( TTYInfo ) = (int) wHeight ;
  847 + YSCROLL( TTYInfo ) = max( 0, (MAXROWS * YCHAR( TTYInfo )) -
  848 + YSIZE( TTYInfo ) ) ;
  849 + nScrollAmt = min( YSCROLL( TTYInfo ), YOFFSET( TTYInfo ) ) -
  850 + YOFFSET( TTYInfo ) ;
  851 + ScrollWindow( hWnd, 0, -nScrollAmt, NULL, NULL ) ;
  852 +
  853 + YOFFSET( TTYInfo ) = YOFFSET( TTYInfo ) + nScrollAmt ;
  854 + SetScrollPos( hWnd, SB_VERT, YOFFSET( TTYInfo ), FALSE ) ;
  855 + SetScrollRange( hWnd, SB_VERT, 0, YSCROLL( TTYInfo ), TRUE ) ;
  856 +
  857 + //
  858 + // adjust horz settings
  859 + //
  860 + XSIZE( TTYInfo ) = (int) wHeight ;
  861 + XSCROLL( TTYInfo ) = max( 0, (MAXCOLS * XCHAR( TTYInfo )) -
  862 + XSIZE( TTYInfo ) ) ;
  863 + nScrollAmt = min( XSCROLL( TTYInfo ), XOFFSET( TTYInfo )) -
  864 + XOFFSET( TTYInfo ) ;
  865 + ScrollWindow( hWnd, nScrollAmt, 0, NULL, NULL );
  866 + XOFFSET( TTYInfo ) = XOFFSET( TTYInfo ) + nScrollAmt ;
  867 + SetScrollRange( hWnd, SB_HORZ, 0, XSCROLL( TTYInfo ), FALSE ) ;
  868 + SetScrollPos( hWnd, SB_HORZ, XOFFSET( TTYInfo ), TRUE ) ;
  869 +
  870 + InvalidateRect( hWnd, NULL, FALSE ) ; // redraw entire window
  871 +
  872 + return ( TRUE ) ;
  873 +
  874 +} // end of SizeTTY()
  875 +
  876 +/*-----------------------------------------------------------------------------
  877 +
  878 +FUNCTION: TTYChildProc(HWND, UINT, WPARAM, LPARAM)
  879 +
  880 +PURPOSE: Window Procedure to process message for the TTY Child Window
  881 +
  882 +PARAMETERS:
  883 + hwnd - window handle
  884 + message - window message
  885 + wParam - window message parameter (depends on message)
  886 + lParam - window message parameter (depends on message)
  887 +
  888 +HISTORY: Date: Author: Comment:
  889 + 10/27/95 AllenD Wrote it
  890 +
  891 +-----------------------------------------------------------------------------*/
  892 +int WINAPI TTYChildProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
  893 +{
  894 + switch(uMessage)
  895 + {
  896 + case WM_VSCROLL:
  897 + ScrollTTYVert( hWnd, LOWORD( wParam ), HIWORD( wParam ) ) ;
  898 + break ;
  899 +
  900 + case WM_HSCROLL:
  901 + ScrollTTYHorz( hWnd, LOWORD( wParam ), HIWORD( wParam ) ) ;
  902 + break ;
  903 +
  904 + case WM_SIZE:
  905 + SizeTTY(hWnd, LOWORD(lParam), HIWORD(lParam));
  906 + break;
  907 +
  908 + case WM_PAINT:
  909 + PaintTTY(hWnd);
  910 + break;
  911 +
  912 + case WM_CHAR:
  913 + {
  914 + //
  915 + // keyboard activity in TTY Window
  916 + //
  917 + if (CONNECTED(TTYInfo)) {
  918 +
  919 + if (!WriterAddNewNode(WRITE_CHAR, 0, (char) wParam, NULL, NULL, NULL))
  920 + return FALSE;
  921 +
  922 + if (LOCALECHO(TTYInfo))
  923 + OutputABufferToWindow(ghWndTTY, (CHAR *) &wParam, 1);
  924 + }
  925 + }
  926 + break;
  927 +
  928 + case WM_SETFOCUS:
  929 + SetTTYFocus( ghWndTTY ) ;
  930 + break ;
  931 +
  932 + case WM_KILLFOCUS:
  933 + KillTTYFocus( ghWndTTY ) ;
  934 + break ;
  935 +
  936 + case WM_MOUSEACTIVATE:
  937 + /*
  938 + If mouse is clicked in me (the tty child window)
  939 + then I need to get the focus.
  940 + */
  941 + SetFocus(hWnd);
  942 + return MA_ACTIVATE;
  943 + break;
  944 +
  945 + default:
  946 + return DefWindowProc(hWnd, uMessage, wParam, lParam);
  947 + }
  948 + return 0L;
  949 +}
... ...
  1 +
  2 +/*-----------------------------------------------------------------------------
  3 + This is a part of the Microsoft Source Code Samples.
  4 + Copyright (C) 1995 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 + MODULE: MTTTY.h
  12 +
  13 + PURPOSE: Contains global definitions and variables
  14 +
  15 +-----------------------------------------------------------------------------*/
  16 +
  17 +//
  18 +// File: MTTTY.h
  19 +//
  20 +
  21 +#include "resource.h"
  22 +#include "ttyinfo.h"
  23 +
  24 +//
  25 +// GLOBAL DEFINES
  26 +//
  27 +#define TTY_BUFFER_SIZE MAXROWS * MAXCOLS
  28 +#define MAX_STATUS_BUFFER 20000
  29 +#define MAX_WRITE_BUFFER 1024
  30 +#define MAX_READ_BUFFER 2048
  31 +#define READ_TIMEOUT 500
  32 +#define STATUS_CHECK_TIMEOUT 500
  33 +#define WRITE_CHECK_TIMEOUT 500
  34 +#define PURGE_FLAGS PURGE_TXABORT | PURGE_TXCLEAR | PURGE_RXABORT | PURGE_RXCLEAR
  35 +#define EVENTFLAGS_DEFAULT EV_BREAK | EV_CTS | EV_DSR | EV_ERR | EV_RING | EV_RLSD
  36 +#define FLAGCHAR_DEFAULT '\n'
  37 +
  38 +//
  39 +// Write request types
  40 +//
  41 +#define WRITE_CHAR 0x01
  42 +#define WRITE_FILE 0x02
  43 +#define WRITE_FILESTART 0x03
  44 +#define WRITE_FILEEND 0x04
  45 +#define WRITE_ABORT 0x05
  46 +#define WRITE_BLOCK 0x06
  47 +
  48 +//
  49 +// Read states
  50 +//
  51 +#define RECEIVE_TTY 0x01
  52 +#define RECEIVE_CAPTURED 0x02
  53 +
  54 +//
  55 +// window coords
  56 +//
  57 +#define MAXXWINDOW 750
  58 +#define MAXYWINDOW 530
  59 +#define STARTXWINDOW 80
  60 +#define STARTYWINDOW 70
  61 +
  62 +#define SETTINGSFACTOR 5
  63 +#define STATUSFACTOR 5
  64 +
  65 +//
  66 +// window timer ids
  67 +//
  68 +#define TIMERID 1
  69 +
  70 +//
  71 +// GLOBAL VARIABLES
  72 +//
  73 +OSVERSIONINFO gOSV;
  74 +HINSTANCE ghInst;
  75 +HACCEL ghAccel;
  76 +HWND ghwndMain;
  77 +HWND ghWndToolbarDlg;
  78 +HWND ghWndStatusDlg;
  79 +HWND ghWndTTY;
  80 +HWND ghWndHidden;
  81 +
  82 +//
  83 +// COMMTIMEOUTS is init'd in Init.c
  84 +//
  85 +extern COMMTIMEOUTS gTimeoutsDefault;
  86 +
  87 +//
  88 +// Window placement variables
  89 +//
  90 +WORD gwBaseY;
  91 +LONG gcyMinimumWindowHeight;
  92 +
  93 +//
  94 +// Flags controlling thread actions
  95 +//
  96 +HANDLE ghThreadExitEvent;
  97 +BOOL gfAbortTransfer;
  98 +
  99 +//
  100 +// File transfer variables
  101 +//
  102 +DWORD gdwFileTransferLeft;
  103 +DWORD gdwReceiveState;
  104 +HANDLE ghFileCapture;
  105 +
  106 +//
  107 +// Status updating
  108 +//
  109 +CRITICAL_SECTION gStatusCritical;
  110 +HANDLE ghStatusMessageEvent;
  111 +HANDLE ghStatusMessageHeap;
  112 +HFONT ghFontStatus;
  113 +int gnStatusIndex;
  114 +
  115 +typedef struct STATUS_MESSAGE;
  116 +
  117 +struct STATUS_MESSAGE * glpStatusMessageHead;
  118 +struct STATUS_MESSAGE * glpStatusMessageTail;
  119 +
  120 +typedef struct STATUS_MESSAGE
  121 +{
  122 + struct STATUS_MESSAGE * lpNext; // pointer to next node
  123 + char chMessageStart; // variable length string start here
  124 +} STATUS_MESSAGE;
  125 +
  126 +
  127 +//
  128 +// Port name
  129 +//
  130 +char gszPort[20];
  131 +
  132 +//
  133 +// Writer heap variables
  134 +//
  135 +CRITICAL_SECTION gcsWriterHeap;
  136 +CRITICAL_SECTION gcsDataHeap;
  137 +HANDLE ghWriterHeap;
  138 +HANDLE ghWriterEvent;
  139 +HANDLE ghTransferCompleteEvent;
  140 +
  141 +//
  142 +// Write request data structure; look in Writer.c for more info
  143 +//
  144 +typedef struct WRITEREQUEST;
  145 +
  146 +struct WRITEREQUEST *gpWriterHead;
  147 +struct WRITEREQUEST *gpWriterTail;
  148 +
  149 +typedef struct WRITEREQUEST
  150 +{
  151 + DWORD dwWriteType; // char, file start, file abort, file packet
  152 + DWORD dwSize; // size of buffer
  153 + char ch; // ch to send
  154 + char * lpBuf; // address of buffer to send
  155 + HANDLE hHeap; // heap containing buffer
  156 + HWND hWndProgress; // status bar window handle
  157 + struct WRITEREQUEST *pNext; // next node in the list
  158 + struct WRITEREQUEST *pPrev; // prev node in the list
  159 +} WRITEREQUEST, *PWRITEREQUEST;
  160 +
  161 +
  162 +//
  163 +// Prototypes of functions called between source files
  164 +//
  165 +
  166 +//
  167 +// Error functions
  168 +//
  169 +void ErrorReporter( char * szMessage );
  170 +void ErrorHandler( char * szMessage );
  171 +void ErrorInComm( char * szMessage );
  172 +
  173 +//
  174 +// Initialization/deinitialization/settings functions
  175 +//
  176 +HANDLE SetupCommPort( void );
  177 +void ChangeConnection( HWND, BOOL );
  178 +BOOL BreakDownCommPort( void );
  179 +BOOL UpdateConnection( void );
  180 +void GlobalInitialize( void );
  181 +void DestroyTTYInfo( void );
  182 +void GlobalCleanup( void );
  183 +void UpdateTTYInfo( void );
  184 +BOOL DisconnectOK( void );
  185 +BOOL InitTTYInfo( void );
  186 +void InitNewFont( LOGFONT, COLORREF );
  187 +
  188 +//
  189 +// TTY functions
  190 +//
  191 +void OpenSettingsToolbar( HWND );
  192 +void OpenStatusToolbar( HWND );
  193 +BOOL CmdAbout( HWND );
  194 +
  195 +//
  196 +// TTY functions
  197 +//
  198 +BOOL MoveTTYCursor( HWND );
  199 +BOOL KillTTYFocus( HWND );
  200 +BOOL SetTTYFocus( HWND );
  201 +BOOL SizeTTY( HWND, WORD, WORD );
  202 +
  203 +//
  204 +// Thread procedures
  205 +//
  206 +DWORD WINAPI ReaderAndStatusProc( LPVOID );
  207 +DWORD WINAPI WriterProc( LPVOID );
  208 +
  209 +//
  210 +// File transfer functions
  211 +//
  212 +void CALLBACK TransferRepeatDo( UINT, UINT, DWORD, DWORD, DWORD );
  213 +void TransferRepeatCreate( LPCSTR, DWORD );
  214 +void TransferRepeatDestroy( void );
  215 +void TransferFileTextStart( LPCSTR );
  216 +void TransferFileTextEnd( void );
  217 +// void TransferFileText( LPCTSTR );
  218 +void ReceiveFileText( LPCTSTR );
  219 +DWORD GetAFrequency( void );
  220 +
  221 +//
  222 +// Buffer manipulation functions
  223 +//
  224 +void OutputABufferToWindow( HWND, char *, DWORD );
  225 +void OutputABuffer( HWND, char *, DWORD );
  226 +BOOL ClearTTYContents( void );
  227 +
  228 +//
  229 +// Status functions
  230 +//
  231 +HFONT CreateStatusEditFont( void );
  232 +void ReportStatusEvent( DWORD );
  233 +void CheckModemStatus( BOOL );
  234 +void ReportCommError( void );
  235 +void ReportComStat( COMSTAT );
  236 +void StatusMessage( void );
  237 +void UpdateStatus( char * );
  238 +void CheckComStat( BOOL );
  239 +
  240 +//
  241 +// Writer heap functions
  242 +//
  243 +BOOL WriterAddNewNode( DWORD, DWORD, char, char *, HANDLE, HWND );
  244 +BOOL WriterAddExistingNode( PWRITEREQUEST, DWORD, DWORD, char, char *, HANDLE, HWND );
  245 +BOOL WriterAddNewNodeTimeout( DWORD, DWORD, char, char *, HANDLE, HWND, DWORD );
  246 +BOOL WriterAddFirstNodeTimeout( DWORD, DWORD, char, char *, HANDLE, HWND, DWORD );
  247 +
... ...
No preview for this file type
  1 +# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00
  2 +# ** DO NOT EDIT **
  3 +
  4 +# TARGTYPE "Win32 (x86) Application" 0x0101
  5 +
  6 +!IF "$(CFG)" == ""
  7 +CFG=Win32 Debug
  8 +!MESSAGE No configuration specified. Defaulting to Win32 Debug.
  9 +!ENDIF
  10 +
  11 +!IF "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug"
  12 +!MESSAGE Invalid configuration "$(CFG)" specified.
  13 +!MESSAGE You can specify a configuration when running NMAKE on this makefile
  14 +!MESSAGE by defining the macro CFG on the command line. For example:
  15 +!MESSAGE
  16 +!MESSAGE NMAKE /f "MTTTY.mak" CFG="Win32 Debug"
  17 +!MESSAGE
  18 +!MESSAGE Possible choices for configuration are:
  19 +!MESSAGE
  20 +!MESSAGE "Win32 Release" (based on "Win32 (x86) Application")
  21 +!MESSAGE "Win32 Debug" (based on "Win32 (x86) Application")
  22 +!MESSAGE
  23 +!ERROR An invalid configuration is specified.
  24 +!ENDIF
  25 +
  26 +################################################################################
  27 +# Begin Project
  28 +# PROP Target_Last_Scanned "Win32 Debug"
  29 +MTL=MkTypLib.exe
  30 +CPP=cl.exe
  31 +RSC=rc.exe
  32 +
  33 +!IF "$(CFG)" == "Win32 Release"
  34 +
  35 +# PROP BASE Use_MFC 0
  36 +# PROP BASE Use_Debug_Libraries 0
  37 +# PROP BASE Output_Dir "WinRel"
  38 +# PROP BASE Intermediate_Dir "WinRel"
  39 +# PROP Use_MFC 0
  40 +# PROP Use_Debug_Libraries 0
  41 +# PROP Output_Dir "WinRel"
  42 +# PROP Intermediate_Dir "WinRel"
  43 +OUTDIR=.\WinRel
  44 +INTDIR=.\WinRel
  45 +
  46 +ALL : $(OUTDIR)/MTTTY.exe $(OUTDIR)/MTTTY.bsc
  47 +
  48 +$(OUTDIR) :
  49 + if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
  50 +
  51 +# ADD BASE MTL /nologo /D "NDEBUG" /win32
  52 +# ADD MTL /nologo /D "NDEBUG" /win32
  53 +MTL_PROJ=/nologo /D "NDEBUG" /win32
  54 +# ADD BASE CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR /c
  55 +# ADD CPP /nologo /MD /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR /c
  56 +CPP_PROJ=/nologo /MD /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
  57 + /FR$(INTDIR)/ /Fp$(OUTDIR)/"MTTTY.pch" /Fo$(INTDIR)/ /c
  58 +CPP_OBJS=.\WinRel/
  59 +# ADD BASE RSC /l 0x409 /d "NDEBUG"
  60 +# ADD RSC /l 0x409 /d "NDEBUG"
  61 +RSC_PROJ=/l 0x409 /fo$(INTDIR)/"MTTTY.res" /d "NDEBUG"
  62 +BSC32=bscmake.exe
  63 +# ADD BASE BSC32 /nologo
  64 +# ADD BSC32 /nologo
  65 +BSC32_FLAGS=/nologo /o$(OUTDIR)/"MTTTY.bsc"
  66 +BSC32_SBRS= \
  67 + $(INTDIR)/MTTTY.sbr \
  68 + $(INTDIR)/Status.sbr \
  69 + $(INTDIR)/Reader.sbr \
  70 + $(INTDIR)/Error.sbr \
  71 + $(INTDIR)/About.sbr \
  72 + $(INTDIR)/Settings.sbr \
  73 + $(INTDIR)/Init.sbr \
  74 + $(INTDIR)/Writer.sbr \
  75 + $(INTDIR)/Transfer.sbr \
  76 + $(INTDIR)/ReadStat.sbr
  77 +
  78 +$(OUTDIR)/MTTTY.bsc : $(OUTDIR) $(BSC32_SBRS)
  79 + $(BSC32) @<<
  80 + $(BSC32_FLAGS) $(BSC32_SBRS)
  81 +<<
  82 +
  83 +LINK32=link.exe
  84 +# ADD BASE LINK32 winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:windows /MACHINE:I386
  85 +# ADD LINK32 winmm.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:windows /MACHINE:I386
  86 +LINK32_FLAGS=winmm.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib\
  87 + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\
  88 + odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:windows /INCREMENTAL:no\
  89 + /PDB:$(OUTDIR)/"MTTTY.pdb" /MACHINE:I386 /OUT:$(OUTDIR)/"MTTTY.exe"
  90 +DEF_FILE=
  91 +LINK32_OBJS= \
  92 + $(INTDIR)/MTTTY.obj \
  93 + $(INTDIR)/Status.obj \
  94 + $(INTDIR)/Reader.obj \
  95 + $(INTDIR)/Error.obj \
  96 + $(INTDIR)/About.obj \
  97 + $(INTDIR)/MTTTY.res \
  98 + $(INTDIR)/Settings.obj \
  99 + $(INTDIR)/Init.obj \
  100 + $(INTDIR)/Writer.obj \
  101 + $(INTDIR)/Transfer.obj \
  102 + $(INTDIR)/ReadStat.obj
  103 +
  104 +$(OUTDIR)/MTTTY.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
  105 + $(LINK32) @<<
  106 + $(LINK32_FLAGS) $(LINK32_OBJS)
  107 +<<
  108 +
  109 +!ELSEIF "$(CFG)" == "Win32 Debug"
  110 +
  111 +# PROP BASE Use_MFC 0
  112 +# PROP BASE Use_Debug_Libraries 1
  113 +# PROP BASE Output_Dir "WinDebug"
  114 +# PROP BASE Intermediate_Dir "WinDebug"
  115 +# PROP Use_MFC 0
  116 +# PROP Use_Debug_Libraries 1
  117 +# PROP Output_Dir "WinDebug"
  118 +# PROP Intermediate_Dir "WinDebug"
  119 +OUTDIR=.\WinDebug
  120 +INTDIR=.\WinDebug
  121 +
  122 +ALL : $(OUTDIR)/MTTTY.exe $(OUTDIR)/MTTTY.bsc
  123 +
  124 +$(OUTDIR) :
  125 + if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
  126 +
  127 +# ADD BASE MTL /nologo /D "_DEBUG" /win32
  128 +# ADD MTL /nologo /D "_DEBUG" /win32
  129 +MTL_PROJ=/nologo /D "_DEBUG" /win32
  130 +# ADD BASE CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /c
  131 +# ADD CPP /nologo /MD /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /c
  132 +CPP_PROJ=/nologo /MD /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\
  133 + /FR$(INTDIR)/ /Fp$(OUTDIR)/"MTTTY.pch" /Fo$(INTDIR)/ /Fd$(OUTDIR)/"MTTTY.pdb"\
  134 + /c
  135 +CPP_OBJS=.\WinDebug/
  136 +# ADD BASE RSC /l 0x409 /d "_DEBUG"
  137 +# ADD RSC /l 0x409 /d "_DEBUG"
  138 +RSC_PROJ=/l 0x409 /fo$(INTDIR)/"MTTTY.res" /d "_DEBUG"
  139 +BSC32=bscmake.exe
  140 +# ADD BASE BSC32 /nologo
  141 +# ADD BSC32 /nologo
  142 +BSC32_FLAGS=/nologo /o$(OUTDIR)/"MTTTY.bsc"
  143 +BSC32_SBRS= \
  144 + $(INTDIR)/MTTTY.sbr \
  145 + $(INTDIR)/Status.sbr \
  146 + $(INTDIR)/Reader.sbr \
  147 + $(INTDIR)/Error.sbr \
  148 + $(INTDIR)/About.sbr \
  149 + $(INTDIR)/Settings.sbr \
  150 + $(INTDIR)/Init.sbr \
  151 + $(INTDIR)/Writer.sbr \
  152 + $(INTDIR)/Transfer.sbr \
  153 + $(INTDIR)/ReadStat.sbr
  154 +
  155 +$(OUTDIR)/MTTTY.bsc : $(OUTDIR) $(BSC32_SBRS)
  156 + $(BSC32) @<<
  157 + $(BSC32_FLAGS) $(BSC32_SBRS)
  158 +<<
  159 +
  160 +LINK32=link.exe
  161 +# ADD BASE LINK32 winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:windows /DEBUG /MACHINE:I386
  162 +# ADD LINK32 winmm.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:windows /DEBUG /MACHINE:I386
  163 +LINK32_FLAGS=winmm.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib\
  164 + comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\
  165 + odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:windows /INCREMENTAL:yes\
  166 + /PDB:$(OUTDIR)/"MTTTY.pdb" /DEBUG /MACHINE:I386 /OUT:$(OUTDIR)/"MTTTY.exe"
  167 +DEF_FILE=
  168 +LINK32_OBJS= \
  169 + $(INTDIR)/MTTTY.obj \
  170 + $(INTDIR)/Status.obj \
  171 + $(INTDIR)/Reader.obj \
  172 + $(INTDIR)/Error.obj \
  173 + $(INTDIR)/About.obj \
  174 + $(INTDIR)/MTTTY.res \
  175 + $(INTDIR)/Settings.obj \
  176 + $(INTDIR)/Init.obj \
  177 + $(INTDIR)/Writer.obj \
  178 + $(INTDIR)/Transfer.obj \
  179 + $(INTDIR)/ReadStat.obj
  180 +
  181 +$(OUTDIR)/MTTTY.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
  182 + $(LINK32) @<<
  183 + $(LINK32_FLAGS) $(LINK32_OBJS)
  184 +<<
  185 +
  186 +!ENDIF
  187 +
  188 +.c{$(CPP_OBJS)}.obj:
  189 + $(CPP) $(CPP_PROJ) $<
  190 +
  191 +.cpp{$(CPP_OBJS)}.obj:
  192 + $(CPP) $(CPP_PROJ) $<
  193 +
  194 +.cxx{$(CPP_OBJS)}.obj:
  195 + $(CPP) $(CPP_PROJ) $<
  196 +
  197 +################################################################################
  198 +# Begin Group "Source Files"
  199 +
  200 +################################################################################
  201 +# Begin Source File
  202 +
  203 +SOURCE=.\MTTTY.c
  204 +DEP_MTTTY=\
  205 + .\MTTTY.h\
  206 + .\TTYInfo.h
  207 +
  208 +$(INTDIR)/MTTTY.obj : $(SOURCE) $(DEP_MTTTY) $(INTDIR)
  209 +
  210 +# End Source File
  211 +################################################################################
  212 +# Begin Source File
  213 +
  214 +SOURCE=.\Status.c
  215 +DEP_STATU=\
  216 + .\MTTTY.h\
  217 + .\TTYInfo.h
  218 +
  219 +$(INTDIR)/Status.obj : $(SOURCE) $(DEP_STATU) $(INTDIR)
  220 +
  221 +# End Source File
  222 +################################################################################
  223 +# Begin Source File
  224 +
  225 +SOURCE=.\Reader.c
  226 +DEP_READE=\
  227 + .\MTTTY.h\
  228 + .\TTYInfo.h
  229 +
  230 +$(INTDIR)/Reader.obj : $(SOURCE) $(DEP_READE) $(INTDIR)
  231 +
  232 +# End Source File
  233 +################################################################################
  234 +# Begin Source File
  235 +
  236 +SOURCE=.\Error.c
  237 +DEP_ERROR=\
  238 + .\MTTTY.h\
  239 + .\TTYInfo.h
  240 +
  241 +$(INTDIR)/Error.obj : $(SOURCE) $(DEP_ERROR) $(INTDIR)
  242 +
  243 +# End Source File
  244 +################################################################################
  245 +# Begin Source File
  246 +
  247 +SOURCE=.\About.c
  248 +DEP_ABOUT=\
  249 + .\MTTTY.h\
  250 + .\TTYInfo.h
  251 +
  252 +$(INTDIR)/About.obj : $(SOURCE) $(DEP_ABOUT) $(INTDIR)
  253 +
  254 +# End Source File
  255 +################################################################################
  256 +# Begin Source File
  257 +
  258 +SOURCE=.\MTTTY.RC
  259 +DEP_MTTTY_=\
  260 + .\MTTTY.ICO\
  261 + .\MTTTY2.ICO\
  262 + .\MTTTY3.ICO\
  263 + .\MTTTY4.ICO
  264 +
  265 +$(INTDIR)/MTTTY.res : $(SOURCE) $(DEP_MTTTY_) $(INTDIR)
  266 + $(RSC) $(RSC_PROJ) $(SOURCE)
  267 +
  268 +# End Source File
  269 +################################################################################
  270 +# Begin Source File
  271 +
  272 +SOURCE=.\Settings.c
  273 +DEP_SETTI=\
  274 + .\MTTTY.h\
  275 + .\TTYInfo.h
  276 +
  277 +$(INTDIR)/Settings.obj : $(SOURCE) $(DEP_SETTI) $(INTDIR)
  278 +
  279 +# End Source File
  280 +################################################################################
  281 +# Begin Source File
  282 +
  283 +SOURCE=.\Init.c
  284 +DEP_INIT_=\
  285 + .\MTTTY.h\
  286 + .\TTYInfo.h
  287 +
  288 +$(INTDIR)/Init.obj : $(SOURCE) $(DEP_INIT_) $(INTDIR)
  289 +
  290 +# End Source File
  291 +################################################################################
  292 +# Begin Source File
  293 +
  294 +SOURCE=.\Writer.c
  295 +DEP_WRITE=\
  296 + .\MTTTY.h\
  297 + .\TTYInfo.h
  298 +
  299 +$(INTDIR)/Writer.obj : $(SOURCE) $(DEP_WRITE) $(INTDIR)
  300 +
  301 +# End Source File
  302 +################################################################################
  303 +# Begin Source File
  304 +
  305 +SOURCE=.\Transfer.c
  306 +DEP_TRANS=\
  307 + .\MTTTY.h\
  308 + .\TTYInfo.h
  309 +
  310 +$(INTDIR)/Transfer.obj : $(SOURCE) $(DEP_TRANS) $(INTDIR)
  311 +
  312 +# End Source File
  313 +################################################################################
  314 +# Begin Source File
  315 +
  316 +SOURCE=.\ReadStat.c
  317 +DEP_READS=\
  318 + .\MTTTY.h\
  319 + .\TTYInfo.h
  320 +
  321 +$(INTDIR)/ReadStat.obj : $(SOURCE) $(DEP_READS) $(INTDIR)
  322 +
  323 +# End Source File
  324 +# End Group
  325 +# End Project
  326 +################################################################################
... ...
  1 +// Microsoft Visual C++ generated resource script.
  2 +//
  3 +#include "resource.h"
  4 +
  5 +#define APSTUDIO_READONLY_SYMBOLS
  6 +/////////////////////////////////////////////////////////////////////////////
  7 +//
  8 +// Generated from the TEXTINCLUDE 2 resource.
  9 +//
  10 +#include <Windows.h>
  11 +/////////////////////////////////////////////////////////////////////////////
  12 +#undef APSTUDIO_READONLY_SYMBOLS
  13 +
  14 +/////////////////////////////////////////////////////////////////////////////
  15 +// Ó¢Óï(ÃÀ¹ú) resources
  16 +
  17 +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
  18 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
  19 +#pragma code_page(1252)
  20 +
  21 +/////////////////////////////////////////////////////////////////////////////
  22 +//
  23 +// Accelerator
  24 +//
  25 +
  26 +IDR_MTTTYACCELERATOR ACCELERATORS
  27 +BEGIN
  28 + VK_F5, ID_TRANSFER_SENDFILETEXT, VIRTKEY, NOINVERT
  29 + VK_F5, ID_TRANSFER_ABORTREPEATEDSENDING, VIRTKEY, ALT, NOINVERT
  30 + VK_F5, ID_TRANSFER_ABORTSENDING, VIRTKEY, SHIFT, NOINVERT
  31 + VK_F3, ID_FILE_EXIT, VIRTKEY, NOINVERT ///ASCII, ALT, NOINVERT
  32 + VK_F4, ID_FILE_CONNECT, VIRTKEY, NOINVERT
  33 +END
  34 +
  35 +
  36 +/////////////////////////////////////////////////////////////////////////////
  37 +//
  38 +// Dialog
  39 +//
  40 +
  41 +IDD_ABOUT DIALOG 0, 0, 149, 159
  42 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
  43 +CAPTION "About MTTTY"
  44 +FONT 8, "MS Sans Serif"
  45 +BEGIN
  46 + DEFPUSHBUTTON "Close",IDOK,49,137,50,14
  47 + ICON IDI_APPICON,IDC_PICTURE,9,12,18,20
  48 + LTEXT "Microsoft Corporation",IDC_STATIC,36,15,86,12
  49 + LTEXT "Multi-threaded TTY Sample",IDC_STATIC,36,31,91,12
  50 + LTEXT "Version 4.00",IDC_STATIC,36,47,51,12
  51 + LTEXT "Copyright (c) 1995",IDC_STATIC,36,63,72,12
  52 + EDITTEXT IDC_OSVERSIONINFO,36,81,104,46,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY
  53 +END
  54 +
  55 +IDD_TOOLBARSETTINGS DIALOGEX 0, 0, 414, 132
  56 +STYLE DS_ABSALIGN | DS_SETFONT | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER
  57 +FONT 14, "Arial Narrow", 400, 0, 0x0
  58 +BEGIN
  59 + COMBOBOX IDC_PORTCOMBO,2,13,48,51,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
  60 + LTEXT "Baud",IDC_STATIC,54,2,17,8
  61 + COMBOBOX IDC_BAUDCOMBO,67,12,48,64,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
  62 + COMBOBOX IDC_PARITYCOMBO,3,87,48,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
  63 + COMBOBOX IDC_DATABITSCOMBO,57,87,48,48,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
  64 + COMBOBOX IDC_STOPBITSCOMBO,110,87,48,39,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
  65 + LTEXT "Port",IDC_STATIC,2,2,17,8
  66 + LTEXT "Parity",IDC_STATIC,5,71,20,8
  67 + LTEXT "Data Bits",IDC_STATIC,59,71,31,9
  68 + LTEXT "Stop Bits",IDC_STATIC,112,71,43,10
  69 + CONTROL "Local Echo",IDC_LOCALECHOCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,275,79,49,10
  70 + CONTROL "Display Errors",IDC_DISPLAYERRORSCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,275,89,57,10
  71 + PUSHBUTTON "Font...",IDC_FONTBTN,3,107,33,14
  72 + PUSHBUTTON "Comm Events...",IDC_COMMEVENTSBTN,41,107,61,14
  73 + CONTROL "CR => CR/LF",IDC_LFBTN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,275,99,56,10
  74 + CONTROL "Autowrap",IDC_AUTOWRAPCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,275,109,43,10
  75 + PUSHBUTTON "Flow Control...",IDC_FLOWCONTROLBTN,105,107,59,14
  76 + PUSHBUTTON "Timeouts...",IDC_TIMEOUTSBTN,169,107,49,14
  77 + CONTROL "No Reading",IDC_NOREADINGCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,341,79,53,10
  78 + CONTROL "No Writing",IDC_NOWRITINGCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,341,89,58,10
  79 + CONTROL "No Status",IDC_NOSTATUSCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,341,109,54,10
  80 + CONTROL "No Events",IDC_NOEVENTSCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,341,99,68,10
  81 + PUSHBUTTON "Send",IDC_SENDBTN,137,11,50,14
  82 +END
  83 +
  84 +IDD_STATUSDIALOG DIALOGEX 0, 0, 459, 156
  85 +STYLE DS_ABSALIGN | DS_SETFONT | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER
  86 +FONT 8, "MS Sans Serif", 0, 0, 0x0
  87 +BEGIN
  88 + PUSHBUTTON "",IDC_ABORTBTN,4,13,44,27,NOT WS_VISIBLE
  89 + CONTROL "Generic1",IDC_TRANSFERPROGRESS,"msctls_progress32",PBS_SMOOTH | NOT WS_VISIBLE | WS_BORDER,56,12,192,29
  90 + GROUPBOX "Modem Status",IDC_MODEMSTATUSGRP,4,70,153,25
  91 + CONTROL "CTS",IDC_STATCTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,79,26,10
  92 + CONTROL "DSR",IDC_STATDSR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,79,29,10
  93 + CONTROL "RING",IDC_STATRING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,70,79,30,10
  94 + CONTROL "RLSD (CD)",IDC_STATRLSD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,105,79,48,10
  95 + GROUPBOX "Comm Status",IDC_STATIC,157,76,162,80
  96 + CONTROL "CTS Hold",IDC_CTSHOLDCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,95,50,10
  97 + CONTROL "DSR Hold",IDC_DSRHOLDCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,107,50,10
  98 + CONTROL "RLSD Hold",IDC_RLSDHOLDCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,146,50,10
  99 + CONTROL "XOFF Hold",IDC_XOFFHOLDCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,214,95,48,10
  100 + CONTROL "XOFF Sent",IDC_XOFFSENTCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,214,107,48,10
  101 + CONTROL "EOF Sent",IDC_EOFSENTCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,211,146,47,10
  102 + CONTROL "TX Char",IDC_TXIMCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,265,95,42,10
  103 + LTEXT "TX Chars:",IDC_STATIC,265,108,34,8
  104 + EDITTEXT IDC_TXCHAREDIT,302,105,19,12,ES_AUTOHSCROLL | ES_READONLY
  105 + LTEXT "RX Chars:",IDC_STATIC,262,146,34,8
  106 + EDITTEXT IDC_RXCHAREDIT,298,144,19,12,ES_AUTOHSCROLL | ES_READONLY
  107 + EDITTEXT IDC_STATUSEDIT,260,3,193,44,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL
  108 +END
  109 +
  110 +IDD_COMMEVENTSDLG DIALOG 0, 0, 226, 113
  111 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
  112 +CAPTION "Select Comm Events"
  113 +FONT 8, "MS Sans Serif"
  114 +BEGIN
  115 + DEFPUSHBUTTON "OK",IDOK,164,8,50,14
  116 + PUSHBUTTON "Cancel",IDCANCEL,164,26,50,14
  117 + PUSHBUTTON "&Defaults",IDC_DEFAULTSBTN,164,44,50,14
  118 + CONTROL "Errors",IDC_EVERRBTN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,10,40,10
  119 + CONTROL "Break",IDC_EVBREAKBTN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,74,10,40,10
  120 + CONTROL "CTS Changes",IDC_EVCTSBTN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,22,60,10
  121 + CONTROL "Ring Indicator",IDC_EVRINGBTN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,74,22,65,10
  122 + CONTROL "DSR Changes",IDC_EVDSRBTN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,34,60,10
  123 + CONTROL "RLSD (CD) Changes",IDC_EVRLSDBTN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,74,34,80,10
  124 + CONTROL "Transmit Buffer Empty",IDC_EVTXEMPTYBTN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,46,89,10
  125 + CONTROL "Character Reception",IDC_EVRXCHARBTN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,58,85,10
  126 + CONTROL "Flag Character Reception",IDC_EVRXFLAGBTN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,70,99,10
  127 + EDITTEXT IDC_FLAGEDIT,19,95,25,12,ES_UPPERCASE | ES_AUTOHSCROLL
  128 + EDITTEXT IDC_FLAGCHAR,49,95,14,12,ES_AUTOHSCROLL | ES_READONLY
  129 + LTEXT "Flag Char Value:",IDC_STATIC,10,85,65,8
  130 + LTEXT "0x",IDC_STATIC,10,99,9,8
  131 +END
  132 +
  133 +IDD_FLOWCONTROLDLG DIALOG 0, 0, 210, 208
  134 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
  135 +CAPTION "Flow Control Settings"
  136 +FONT 8, "MS Sans Serif"
  137 +BEGIN
  138 + DEFPUSHBUTTON "OK",IDOK,153,8,50,14
  139 + PUSHBUTTON "Cancel",IDCANCEL,153,26,50,14
  140 + PUSHBUTTON "&Rts/Cts",IDC_RTSCTSBTN,153,44,50,14
  141 + PUSHBUTTON "&Xoff/Xon",IDC_XOFFXONBTN,153,80,50,14
  142 + PUSHBUTTON "&None",IDC_NONEBTN,153,98,50,14
  143 + CONTROL "CTS Output Control",IDC_CTSOUTCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,20,84,10
  144 + CONTROL "DSR Output Control",IDC_DSROUTCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,32,84,10
  145 + CONTROL "DSR Sensitivity (Input Control)",IDC_DSRINCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,44,113,10
  146 + LTEXT "DTR Control:",IDC_STATIC,16,60,45,9
  147 + LTEXT "RTS Control:",IDC_STATIC,76,60,45,9
  148 + COMBOBOX IDC_DTRCONTROLCOMBO,16,68,52,48,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
  149 + COMBOBOX IDC_RTSCONTROLCOMBO,76,68,52,49,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
  150 + CONTROL "XON/XOFF Output Control",IDC_XONXOFFOUTCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,111,102,10
  151 + CONTROL "XON/XOFF Input Control",IDC_XONXOFFINCHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,123,102,10
  152 + EDITTEXT IDC_XONLIMITEDIT,15,158,40,12,ES_AUTOHSCROLL
  153 + EDITTEXT IDC_XOFFLIMITEDIT,79,158,40,12,ES_AUTOHSCROLL
  154 + EDITTEXT IDC_XONCHAREDIT,27,182,24,12,ES_AUTOHSCROLL
  155 + EDITTEXT IDC_XOFFCHAREDIT,91,182,24,12,ES_AUTOHSCROLL
  156 + LTEXT "XON Limit:",IDC_STATIC,15,150,39,8
  157 + LTEXT "XOFF Limit:",IDC_STATIC,79,150,39,8
  158 + LTEXT "Ox",IDC_STATIC,15,185,9,8
  159 + LTEXT "Ox",IDC_STATIC,79,185,9,8
  160 + LTEXT "XON Char:",IDC_STATIC,15,174,39,8
  161 + LTEXT "XOFF Char:",IDC_STATIC,79,174,39,8
  162 + GROUPBOX "Hardware Control Settings",IDC_STATIC,8,8,128,80
  163 + GROUPBOX "Software Control Settings",IDC_STATIC,8,96,136,105
  164 + EDITTEXT IDC_XONCHARDISP,55,182,15,12,ES_AUTOHSCROLL | WS_DISABLED
  165 + EDITTEXT IDC_XOFFCHARDISP,119,182,15,12,ES_AUTOHSCROLL | WS_DISABLED
  166 + CONTROL "Continue sending after XOFF sent",IDC_TXAFTERXOFFSENTCHK,
  167 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,135,122,10
  168 + PUSHBUTTON "&Dtr/Dsr",IDC_DTRDSRBTN,153,62,50,14
  169 +END
  170 +
  171 +IDD_TIMEOUTSDLG DIALOG 0, 0, 231, 158
  172 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
  173 +CAPTION "Timeouts"
  174 +FONT 8, "MS Sans Serif"
  175 +BEGIN
  176 + DEFPUSHBUTTON "OK",IDOK,172,6,50,14
  177 + PUSHBUTTON "Cancel",IDCANCEL,172,24,50,14
  178 + PUSHBUTTON "&Defaults",IDC_DEFAULTSBTN,171,42,50,14
  179 + EDITTEXT IDC_READINTERVALEDIT,114,19,40,14,ES_AUTOHSCROLL
  180 + EDITTEXT IDC_READMULTIPLIEREDIT,114,37,40,14,ES_AUTOHSCROLL
  181 + EDITTEXT IDC_READCONSTANTEDIT,113,55,40,14,ES_AUTOHSCROLL
  182 + EDITTEXT IDC_WRITEMULTIPLIEREDIT,113,95,40,14,ES_AUTOHSCROLL
  183 + EDITTEXT IDC_WRITECONSTANTEDIT,113,113,40,14,ES_AUTOHSCROLL
  184 + LTEXT "Read Interval Timeout:",IDC_STATIC,14,22,76,8
  185 + LTEXT "Read Total Timeout Multipler:",IDC_STATIC,14,40,98,8
  186 + LTEXT "Read Total Timeout Constant:",IDC_STATIC,13,58,99,8
  187 + LTEXT "Write Total Timeout Multiplier:",IDC_STATIC,13,99,99,8
  188 + LTEXT "Write Total Timeout Constant:",IDC_STATIC,13,115,99,8
  189 + GROUPBOX "Read Timeouts",IDC_STATIC,7,7,155,69
  190 + GROUPBOX "Write Timeouts",IDC_STATIC,7,84,155,50
  191 + CONTROL "Display Timeout Status Messages",IDC_DISPLAYTIMEOUTS,
  192 + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,20,140,122,10
  193 +END
  194 +
  195 +IDD_GETADWORD DIALOG 0, 0, 183, 68
  196 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
  197 +CAPTION "Please Enter A Number"
  198 +FONT 8, "MS Sans Serif"
  199 +BEGIN
  200 + EDITTEXT IDC_DWORDEDIT,25,45,52,14,ES_AUTOHSCROLL
  201 + DEFPUSHBUTTON "OK",IDOK,125,10,50,14
  202 + PUSHBUTTON "Cancel",IDCANCEL,125,30,50,14
  203 + LTEXT "Please enter a frequency in milliseconds for the repeated transfer:",IDC_DWORDSTATIC,10,10,94,25
  204 +END
  205 +
  206 +
  207 +/////////////////////////////////////////////////////////////////////////////
  208 +//
  209 +// Icon
  210 +//
  211 +
  212 +// Icon with lowest ID value placed first to ensure application icon
  213 +// remains consistent on all systems.
  214 +IDI_APPICON ICON "MTTTY.ICO"
  215 +
  216 +IDI_APPICON2 ICON "MTTTY2.ICO"
  217 +
  218 +IDI_APPICON3 ICON "MTTTY3.ICO"
  219 +
  220 +IDI_APPICON4 ICON "MTTTY4.ICO"
  221 +
  222 +IDI_TITLE ICON "Optek_Logo_ICO_32 X 32.ico"
  223 +/////////////////////////////////////////////////////////////////////////////
  224 +//
  225 +// Menu
  226 +//
  227 +
  228 +IDR_MTTTYMENU MENU
  229 +BEGIN
  230 + POPUP "&File"
  231 + BEGIN
  232 + MENUITEM "Connect", ID_FILE_CONNECT
  233 + MENUITEM "Disconnect", ID_FILE_DISCONNECT
  234 + MENUITEM SEPARATOR
  235 + MENUITEM "E&xit\tF3", ID_FILE_EXIT
  236 + END
  237 + POPUP "&TTY"
  238 + BEGIN
  239 + MENUITEM "&Clear", ID_TTY_CLEAR
  240 + MENUITEM "&Set Font...", IDC_FONTBTN
  241 + MENUITEM "Comm &Events...", IDC_COMMEVENTSBTN
  242 + MENUITEM "&Flow Control...", IDC_FLOWCONTROLBTN
  243 + MENUITEM "&Timeouts...", IDC_TIMEOUTSBTN
  244 + END
  245 + POPUP "T&ransfer"
  246 + BEGIN
  247 + MENUITEM "&Select file\tF5", ID_TRANSFER_SENDFILETEXT
  248 + MENUITEM "&Receive File (Text)...", ID_TRANSFER_RECEIVEFILETEXT
  249 + MENUITEM "&Abort Sending\tShift+F5", ID_TRANSFER_ABORTSENDING, GRAYED
  250 + MENUITEM SEPARATOR
  251 + MENUITEM "S&end Repeatedly...", ID_TRANSFER_SENDREPEATEDLY
  252 + MENUITEM "A&bort Repeated Sending\tAlt+F5", ID_TRANSFER_ABORTREPEATEDSENDING
  253 + END
  254 + POPUP "&Help"
  255 + BEGIN
  256 + MENUITEM "&About MTTTY", ID_HELP_ABOUTMTTTY
  257 + END
  258 +END
  259 +
  260 +
  261 +#ifdef APSTUDIO_INVOKED
  262 +/////////////////////////////////////////////////////////////////////////////
  263 +//
  264 +// TEXTINCLUDE
  265 +//
  266 +
  267 +1 TEXTINCLUDE
  268 +BEGIN
  269 + "resource.h\0"
  270 +END
  271 +
  272 +2 TEXTINCLUDE
  273 +BEGIN
  274 + "#include <Windows.h>\0"
  275 +END
  276 +
  277 +3 TEXTINCLUDE
  278 +BEGIN
  279 + "\r\n"
  280 + "\0"
  281 +END
  282 +
  283 +#endif // APSTUDIO_INVOKED
  284 +
  285 +
  286 +/////////////////////////////////////////////////////////////////////////////
  287 +//
  288 +// Version
  289 +//
  290 +
  291 +VS_VERSION_INFO VERSIONINFO
  292 + FILEVERSION 4,0,0,0
  293 + PRODUCTVERSION 4,0,0,0
  294 + FILEFLAGSMASK 0x3fL
  295 +#ifdef _DEBUG
  296 + FILEFLAGS 0x1L
  297 +#else
  298 + FILEFLAGS 0x0L
  299 +#endif
  300 + FILEOS 0x4L
  301 + FILETYPE 0x1L
  302 + FILESUBTYPE 0x0L
  303 +BEGIN
  304 + BLOCK "StringFileInfo"
  305 + BEGIN
  306 + BLOCK "040904b0"
  307 + BEGIN
  308 + VALUE "Comments", "Multi-threaded TTY Sample for the Win32 SDK.\r\nDemonstrates serial communiction using multiple threads."
  309 + VALUE "CompanyName", "Microsoft Corporation"
  310 + VALUE "FileDescription", "Multi-threaded TTY Sample for Win32"
  311 + VALUE "FileVersion", "4, 0, 0, 0"
  312 + VALUE "InternalName", "MTTTY"
  313 + VALUE "LegalCopyright", "Copyright ?1995"
  314 + VALUE "OriginalFilename", "MTTTY.exe"
  315 + VALUE "ProductName", "Microsoft MTTTY Sample"
  316 + VALUE "ProductVersion", "4, 0, 0, 0"
  317 + END
  318 + END
  319 + BLOCK "VarFileInfo"
  320 + BEGIN
  321 + VALUE "Translation", 0x409, 1200
  322 + END
  323 +END
  324 +
  325 +
  326 +/////////////////////////////////////////////////////////////////////////////
  327 +//
  328 +// DESIGNINFO
  329 +//
  330 +
  331 +#ifdef APSTUDIO_INVOKED
  332 +GUIDELINES DESIGNINFO
  333 +BEGIN
  334 + IDD_ABOUT, DIALOG
  335 + BEGIN
  336 + END
  337 +
  338 + IDD_TOOLBARSETTINGS, DIALOG
  339 + BEGIN
  340 + BOTTOMMARGIN, 48
  341 + END
  342 +
  343 + IDD_STATUSDIALOG, DIALOG
  344 + BEGIN
  345 + TOPMARGIN, 1
  346 + END
  347 +
  348 + IDD_COMMEVENTSDLG, DIALOG
  349 + BEGIN
  350 + END
  351 +
  352 + IDD_FLOWCONTROLDLG, DIALOG
  353 + BEGIN
  354 + END
  355 +
  356 + IDD_TIMEOUTSDLG, DIALOG
  357 + BEGIN
  358 + END
  359 +
  360 + IDD_GETADWORD, DIALOG
  361 + BEGIN
  362 + LEFTMARGIN, 7
  363 + RIGHTMARGIN, 176
  364 + TOPMARGIN, 7
  365 + BOTTOMMARGIN, 61
  366 + END
  367 +END
  368 +#endif // APSTUDIO_INVOKED
  369 +
  370 +
  371 +/////////////////////////////////////////////////////////////////////////////
  372 +//
  373 +// AFX_DIALOG_LAYOUT
  374 +//
  375 +
  376 +IDD_STATUSDIALOG AFX_DIALOG_LAYOUT
  377 +BEGIN
  378 + 0,
  379 + 0, 0, 0, 0,
  380 + 0, 0, 0, 0,
  381 + 0, 0, 0, 0,
  382 + 0, 0, 0, 0,
  383 + 0, 0, 0, 0,
  384 + 0, 0, 0, 0,
  385 + 0, 0, 0, 0,
  386 + 0, 0, 0, 0,
  387 + 0, 0, 0, 0,
  388 + 0, 0, 0, 0,
  389 + 0, 0, 0, 0,
  390 + 0, 0, 0, 0,
  391 + 0, 0, 0, 0,
  392 + 0, 0, 0, 0,
  393 + 0, 0, 0, 0,
  394 + 0, 0, 0, 0,
  395 + 0, 0, 0, 0,
  396 + 0, 0, 0, 0,
  397 + 0, 0, 0, 0,
  398 + 0, 0, 100, 100
  399 +END
  400 +
  401 +IDD_TOOLBARSETTINGS AFX_DIALOG_LAYOUT
  402 +BEGIN
  403 + 0
  404 +END
  405 +
  406 +#endif // Ó¢Óï(ÃÀ¹ú) resources
  407 +/////////////////////////////////////////////////////////////////////////////
  408 +
  409 +
  410 +
  411 +#ifndef APSTUDIO_INVOKED
  412 +/////////////////////////////////////////////////////////////////////////////
  413 +//
  414 +// Generated from the TEXTINCLUDE 3 resource.
  415 +//
  416 +
  417 +
  418 +/////////////////////////////////////////////////////////////////////////////
  419 +#endif // not APSTUDIO_INVOKED
  420 +
... ...
No preview for this file type
No preview for this file type
No preview for this file type
1   -# Microsoft Developer Studio Project File - Name="BlueFlashTool" - Package Owner=<4>
  1 +# Microsoft Developer Studio Project File - Name="MyMTTTY" - Package Owner=<4>
2 2 # Microsoft Developer Studio Generated Build File, Format Version 6.00
3 3 # ** DO NOT EDIT **
4 4
5 5 # TARGTYPE "Win32 (x86) Application" 0x0101
6 6
7   -CFG=BlueFlashTool - Win32 Debug
  7 +CFG=MyMTTTY - Win32 Debug
8 8 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
9 9 !MESSAGE use the Export Makefile command and run
10 10 !MESSAGE
11   -!MESSAGE NMAKE /f "BlueFlashTool.mak".
  11 +!MESSAGE NMAKE /f "MyMTTTY.mak".
12 12 !MESSAGE
13 13 !MESSAGE You can specify a configuration when running NMAKE
14 14 !MESSAGE by defining the macro CFG on the command line. For example:
15 15 !MESSAGE
16   -!MESSAGE NMAKE /f "BlueFlashTool.mak" CFG="BlueFlashTool - Win32 Debug"
  16 +!MESSAGE NMAKE /f "MyMTTTY.mak" CFG="MyMTTTY - Win32 Debug"
17 17 !MESSAGE
18 18 !MESSAGE Possible choices for configuration are:
19 19 !MESSAGE
20   -!MESSAGE "BlueFlashTool - Win32 Release" (based on "Win32 (x86) Application")
21   -!MESSAGE "BlueFlashTool - Win32 Debug" (based on "Win32 (x86) Application")
  20 +!MESSAGE "MyMTTTY - Win32 Release" (based on "Win32 (x86) Application")
  21 +!MESSAGE "MyMTTTY - Win32 Debug" (based on "Win32 (x86) Application")
22 22 !MESSAGE
23 23
24 24 # Begin Project
... ... @@ -29,109 +29,124 @@ CPP=cl.exe
29 29 MTL=midl.exe
30 30 RSC=rc.exe
31 31
32   -!IF "$(CFG)" == "BlueFlashTool - Win32 Release"
  32 +!IF "$(CFG)" == "MyMTTTY - Win32 Release"
33 33
34   -# PROP BASE Use_MFC 6
  34 +# PROP BASE Use_MFC 0
35 35 # PROP BASE Use_Debug_Libraries 0
36 36 # PROP BASE Output_Dir "Release"
37 37 # PROP BASE Intermediate_Dir "Release"
38 38 # PROP BASE Target_Dir ""
39   -# PROP Use_MFC 6
  39 +# PROP Use_MFC 0
40 40 # PROP Use_Debug_Libraries 0
41 41 # PROP Output_Dir "Release"
42 42 # PROP Intermediate_Dir "Release"
43 43 # PROP Target_Dir ""
44   -# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
45   -# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /c
  44 +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
  45 +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
46 46 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
47 47 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48   -# ADD BASE RSC /l 0x804 /d "NDEBUG" /d "_AFXDLL"
49   -# ADD RSC /l 0x804 /d "NDEBUG" /d "_AFXDLL"
  48 +# ADD BASE RSC /l 0x804 /d "NDEBUG"
  49 +# ADD RSC /l 0x804 /d "NDEBUG"
50 50 BSC32=bscmake.exe
51 51 # ADD BASE BSC32 /nologo
52 52 # ADD BSC32 /nologo
53 53 LINK32=link.exe
54   -# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
55   -# ADD LINK32 /nologo /subsystem:windows /machine:I386
  54 +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
  55 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
56 56
57   -!ELSEIF "$(CFG)" == "BlueFlashTool - Win32 Debug"
  57 +!ELSEIF "$(CFG)" == "MyMTTTY - Win32 Debug"
58 58
59   -# PROP BASE Use_MFC 6
  59 +# PROP BASE Use_MFC 0
60 60 # PROP BASE Use_Debug_Libraries 1
61 61 # PROP BASE Output_Dir "Debug"
62 62 # PROP BASE Intermediate_Dir "Debug"
63 63 # PROP BASE Target_Dir ""
64   -# PROP Use_MFC 6
  64 +# PROP Use_MFC 0
65 65 # PROP Use_Debug_Libraries 1
66 66 # PROP Output_Dir "Debug"
67 67 # PROP Intermediate_Dir "Debug"
68 68 # PROP Target_Dir ""
69   -# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
70   -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
  69 +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
  70 +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
71 71 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
72 72 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
73   -# ADD BASE RSC /l 0x804 /d "_DEBUG" /d "_AFXDLL"
74   -# ADD RSC /l 0x804 /d "_DEBUG" /d "_AFXDLL"
  73 +# ADD BASE RSC /l 0x804 /d "_DEBUG"
  74 +# ADD RSC /l 0x804 /d "_DEBUG"
75 75 BSC32=bscmake.exe
76 76 # ADD BASE BSC32 /nologo
77 77 # ADD BSC32 /nologo
78 78 LINK32=link.exe
79   -# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
80   -# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
  79 +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
  80 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
81 81
82 82 !ENDIF
83 83
84 84 # Begin Target
85 85
86   -# Name "BlueFlashTool - Win32 Release"
87   -# Name "BlueFlashTool - Win32 Debug"
  86 +# Name "MyMTTTY - Win32 Release"
  87 +# Name "MyMTTTY - Win32 Debug"
88 88 # Begin Group "Source Files"
89 89
90 90 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
91 91 # Begin Source File
92 92
93   -SOURCE=.\BlueFlashTool.cpp
  93 +SOURCE=.\ABOUT.C
94 94 # End Source File
95 95 # Begin Source File
96 96
97   -SOURCE=.\BlueFlashTool.rc
  97 +SOURCE=.\ERROR.C
98 98 # End Source File
99 99 # Begin Source File
100 100
101   -SOURCE=.\BlueFlashToolDlg.cpp
  101 +SOURCE=.\INIT.C
102 102 # End Source File
103 103 # Begin Source File
104 104
105   -SOURCE=.\mscomm.cpp
  105 +SOURCE=.\MTTTY.C
106 106 # End Source File
107 107 # Begin Source File
108 108
109   -SOURCE=.\StdAfx.cpp
110   -# ADD CPP /Yc"stdafx.h"
  109 +SOURCE=.\MTTTY.RC
111 110 # End Source File
112   -# End Group
113   -# Begin Group "Header Files"
  111 +# Begin Source File
114 112
115   -# PROP Default_Filter "h;hpp;hxx;hm;inl"
  113 +SOURCE=.\READER.C
  114 +# End Source File
116 115 # Begin Source File
117 116
118   -SOURCE=.\BlueFlashTool.h
  117 +SOURCE=.\READSTAT.C
119 118 # End Source File
120 119 # Begin Source File
121 120
122   -SOURCE=.\BlueFlashToolDlg.h
  121 +SOURCE=.\SETTINGS.C
123 122 # End Source File
124 123 # Begin Source File
125 124
126   -SOURCE=.\mscomm.h
  125 +SOURCE=.\STATUS.C
127 126 # End Source File
128 127 # Begin Source File
129 128
130   -SOURCE=.\Resource.h
  129 +SOURCE=.\TRANSFER.C
131 130 # End Source File
132 131 # Begin Source File
133 132
134   -SOURCE=.\StdAfx.h
  133 +SOURCE=.\WRITER.C
  134 +# End Source File
  135 +# End Group
  136 +# Begin Group "Header Files"
  137 +
  138 +# PROP Default_Filter "h;hpp;hxx;hm;inl"
  139 +# Begin Source File
  140 +
  141 +SOURCE=.\MTTTY.H
  142 +# End Source File
  143 +# Begin Source File
  144 +
  145 +SOURCE=.\RESOURCE.H
  146 +# End Source File
  147 +# Begin Source File
  148 +
  149 +SOURCE=.\TTYINFO.H
135 150 # End Source File
136 151 # End Group
137 152 # Begin Group "Resource Files"
... ... @@ -139,25 +154,20 @@ SOURCE=.\StdAfx.h
139 154 # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
140 155 # Begin Source File
141 156
142   -SOURCE=.\res\BlueFlashTool.ico
  157 +SOURCE=.\MTTTY.ICO
143 158 # End Source File
144 159 # Begin Source File
145 160
146   -SOURCE=.\res\BlueFlashTool.rc2
  161 +SOURCE=.\MTTTY2.ICO
147 162 # End Source File
148   -# End Group
149 163 # Begin Source File
150 164
151   -SOURCE=.\ReadMe.txt
  165 +SOURCE=.\MTTTY3.ICO
152 166 # End Source File
  167 +# Begin Source File
  168 +
  169 +SOURCE=.\MTTTY4.ICO
  170 +# End Source File
  171 +# End Group
153 172 # End Target
154 173 # End Project
155   -# Section BlueFlashTool : {648A5600-2C6E-101B-82B6-000000000014}
156   -# 2:21:DefaultSinkHeaderFile:mscomm.h
157   -# 2:16:DefaultSinkClass:CMSComm
158   -# End Section
159   -# Section BlueFlashTool : {E6E17E90-DF38-11CF-8E74-00A0C90F26F8}
160   -# 2:5:Class:CMSComm
161   -# 2:10:HeaderFile:mscomm.h
162   -# 2:8:ImplFile:mscomm.cpp
163   -# End Section
... ...
... ... @@ -3,7 +3,7 @@ Microsoft Developer Studio Workspace File, Format Version 6.00
3 3
4 4 ###############################################################################
5 5
6   -Project: "BlueFlashTool"=.\BlueFlashTool.dsp - Package Owner=<4>
  6 +Project: "MyMTTTY"=.\MyMTTTY.dsp - Package Owner=<4>
7 7
8 8 Package=<5>
9 9 {{{
... ... @@ -23,7 +23,6 @@ Package=<5>
23 23
24 24 Package=<3>
25 25 {{{
26   - {648A5600-2C6E-101B-82B6-000000000014}
27 26 }}}
28 27
29 28 ###############################################################################
... ...
  1 +
  2 +Microsoft Visual Studio Solution File, Format Version 10.00
  3 +# Visual Studio 2008
  4 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyMTTTY", "MyMTTTY.vcproj", "{DB698040-BB0E-4432-BEF5-5101ED44C10B}"
  5 +EndProject
  6 +Global
  7 + GlobalSection(SolutionConfigurationPlatforms) = preSolution
  8 + Debug|Win32 = Debug|Win32
  9 + Release|Win32 = Release|Win32
  10 + EndGlobalSection
  11 + GlobalSection(ProjectConfigurationPlatforms) = postSolution
  12 + {DB698040-BB0E-4432-BEF5-5101ED44C10B}.Debug|Win32.ActiveCfg = Debug|Win32
  13 + {DB698040-BB0E-4432-BEF5-5101ED44C10B}.Debug|Win32.Build.0 = Debug|Win32
  14 + {DB698040-BB0E-4432-BEF5-5101ED44C10B}.Release|Win32.ActiveCfg = Release|Win32
  15 + {DB698040-BB0E-4432-BEF5-5101ED44C10B}.Release|Win32.Build.0 = Release|Win32
  16 + EndGlobalSection
  17 + GlobalSection(SolutionProperties) = preSolution
  18 + HideSolutionNode = FALSE
  19 + EndGlobalSection
  20 +EndGlobal
... ...
  1 +<?xml version="1.0" encoding="gb2312"?>
  2 +<VisualStudioProject
  3 + ProjectType="Visual C++"
  4 + Version="9.00"
  5 + Name="MyMTTTY"
  6 + ProjectGUID="{DB698040-BB0E-4432-BEF5-5101ED44C10B}"
  7 + TargetFrameworkVersion="0"
  8 + >
  9 + <Platforms>
  10 + <Platform
  11 + Name="Win32"
  12 + />
  13 + </Platforms>
  14 + <ToolFiles>
  15 + </ToolFiles>
  16 + <Configurations>
  17 + <Configuration
  18 + Name="Release|Win32"
  19 + OutputDirectory=".\Release"
  20 + IntermediateDirectory=".\Release"
  21 + ConfigurationType="1"
  22 + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
  23 + UseOfMFC="0"
  24 + ATLMinimizesCRunTimeLibraryUsage="false"
  25 + CharacterSet="2"
  26 + >
  27 + <Tool
  28 + Name="VCPreBuildEventTool"
  29 + />
  30 + <Tool
  31 + Name="VCCustomBuildTool"
  32 + />
  33 + <Tool
  34 + Name="VCXMLDataGeneratorTool"
  35 + />
  36 + <Tool
  37 + Name="VCWebServiceProxyGeneratorTool"
  38 + />
  39 + <Tool
  40 + Name="VCMIDLTool"
  41 + PreprocessorDefinitions="NDEBUG"
  42 + MkTypLibCompatible="true"
  43 + SuppressStartupBanner="true"
  44 + TargetEnvironment="1"
  45 + TypeLibraryName=".\Release/MyMTTTY.tlb"
  46 + HeaderFileName=""
  47 + />
  48 + <Tool
  49 + Name="VCCLCompilerTool"
  50 + Optimization="2"
  51 + InlineFunctionExpansion="1"
  52 + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
  53 + StringPooling="true"
  54 + RuntimeLibrary="0"
  55 + EnableFunctionLevelLinking="true"
  56 + PrecompiledHeaderFile=".\Release/MyMTTTY.pch"
  57 + AssemblerListingLocation=".\Release/"
  58 + ObjectFile=".\Release/"
  59 + ProgramDataBaseFileName=".\Release/"
  60 + WarningLevel="3"
  61 + SuppressStartupBanner="true"
  62 + />
  63 + <Tool
  64 + Name="VCManagedResourceCompilerTool"
  65 + />
  66 + <Tool
  67 + Name="VCResourceCompilerTool"
  68 + PreprocessorDefinitions="NDEBUG"
  69 + Culture="2052"
  70 + />
  71 + <Tool
  72 + Name="VCPreLinkEventTool"
  73 + />
  74 + <Tool
  75 + Name="VCLinkerTool"
  76 + OutputFile=".\Release/MyMTTTY.exe"
  77 + LinkIncremental="1"
  78 + SuppressStartupBanner="true"
  79 + ProgramDatabaseFile=".\Release/MyMTTTY.pdb"
  80 + SubSystem="2"
  81 + RandomizedBaseAddress="1"
  82 + DataExecutionPrevention="0"
  83 + TargetMachine="1"
  84 + />
  85 + <Tool
  86 + Name="VCALinkTool"
  87 + />
  88 + <Tool
  89 + Name="VCManifestTool"
  90 + />
  91 + <Tool
  92 + Name="VCXDCMakeTool"
  93 + />
  94 + <Tool
  95 + Name="VCBscMakeTool"
  96 + SuppressStartupBanner="true"
  97 + OutputFile=".\Release/MyMTTTY.bsc"
  98 + />
  99 + <Tool
  100 + Name="VCFxCopTool"
  101 + />
  102 + <Tool
  103 + Name="VCAppVerifierTool"
  104 + />
  105 + <Tool
  106 + Name="VCPostBuildEventTool"
  107 + />
  108 + </Configuration>
  109 + <Configuration
  110 + Name="Debug|Win32"
  111 + OutputDirectory=".\Debug"
  112 + IntermediateDirectory=".\Debug"
  113 + ConfigurationType="1"
  114 + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
  115 + UseOfMFC="0"
  116 + ATLMinimizesCRunTimeLibraryUsage="false"
  117 + CharacterSet="2"
  118 + >
  119 + <Tool
  120 + Name="VCPreBuildEventTool"
  121 + />
  122 + <Tool
  123 + Name="VCCustomBuildTool"
  124 + />
  125 + <Tool
  126 + Name="VCXMLDataGeneratorTool"
  127 + />
  128 + <Tool
  129 + Name="VCWebServiceProxyGeneratorTool"
  130 + />
  131 + <Tool
  132 + Name="VCMIDLTool"
  133 + PreprocessorDefinitions="_DEBUG"
  134 + MkTypLibCompatible="true"
  135 + SuppressStartupBanner="true"
  136 + TargetEnvironment="1"
  137 + TypeLibraryName=".\Debug/MyMTTTY.tlb"
  138 + HeaderFileName=""
  139 + />
  140 + <Tool
  141 + Name="VCCLCompilerTool"
  142 + Optimization="0"
  143 + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
  144 + MinimalRebuild="true"
  145 + BasicRuntimeChecks="3"
  146 + RuntimeLibrary="1"
  147 + PrecompiledHeaderFile=".\Debug/MyMTTTY.pch"
  148 + AssemblerListingLocation=".\Debug/"
  149 + ObjectFile=".\Debug/"
  150 + ProgramDataBaseFileName=".\Debug/"
  151 + WarningLevel="3"
  152 + SuppressStartupBanner="true"
  153 + DebugInformationFormat="4"
  154 + />
  155 + <Tool
  156 + Name="VCManagedResourceCompilerTool"
  157 + />
  158 + <Tool
  159 + Name="VCResourceCompilerTool"
  160 + PreprocessorDefinitions="_DEBUG"
  161 + Culture="2052"
  162 + />
  163 + <Tool
  164 + Name="VCPreLinkEventTool"
  165 + />
  166 + <Tool
  167 + Name="VCLinkerTool"
  168 + OutputFile=".\Debug/MyMTTTY.exe"
  169 + LinkIncremental="2"
  170 + SuppressStartupBanner="true"
  171 + GenerateDebugInformation="true"
  172 + ProgramDatabaseFile=".\Debug/MyMTTTY.pdb"
  173 + SubSystem="2"
  174 + RandomizedBaseAddress="1"
  175 + DataExecutionPrevention="0"
  176 + TargetMachine="1"
  177 + />
  178 + <Tool
  179 + Name="VCALinkTool"
  180 + />
  181 + <Tool
  182 + Name="VCManifestTool"
  183 + />
  184 + <Tool
  185 + Name="VCXDCMakeTool"
  186 + />
  187 + <Tool
  188 + Name="VCBscMakeTool"
  189 + SuppressStartupBanner="true"
  190 + OutputFile=".\Debug/MyMTTTY.bsc"
  191 + />
  192 + <Tool
  193 + Name="VCFxCopTool"
  194 + />
  195 + <Tool
  196 + Name="VCAppVerifierTool"
  197 + />
  198 + <Tool
  199 + Name="VCPostBuildEventTool"
  200 + />
  201 + </Configuration>
  202 + </Configurations>
  203 + <References>
  204 + </References>
  205 + <Files>
  206 + <Filter
  207 + Name="Source Files"
  208 + Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
  209 + >
  210 + <File
  211 + RelativePath="ABOUT.C"
  212 + >
  213 + <FileConfiguration
  214 + Name="Release|Win32"
  215 + >
  216 + <Tool
  217 + Name="VCCLCompilerTool"
  218 + PreprocessorDefinitions=""
  219 + />
  220 + </FileConfiguration>
  221 + <FileConfiguration
  222 + Name="Debug|Win32"
  223 + >
  224 + <Tool
  225 + Name="VCCLCompilerTool"
  226 + PreprocessorDefinitions=""
  227 + />
  228 + </FileConfiguration>
  229 + </File>
  230 + <File
  231 + RelativePath="ERROR.C"
  232 + >
  233 + <FileConfiguration
  234 + Name="Release|Win32"
  235 + >
  236 + <Tool
  237 + Name="VCCLCompilerTool"
  238 + PreprocessorDefinitions=""
  239 + />
  240 + </FileConfiguration>
  241 + <FileConfiguration
  242 + Name="Debug|Win32"
  243 + >
  244 + <Tool
  245 + Name="VCCLCompilerTool"
  246 + PreprocessorDefinitions=""
  247 + />
  248 + </FileConfiguration>
  249 + </File>
  250 + <File
  251 + RelativePath="INIT.C"
  252 + >
  253 + <FileConfiguration
  254 + Name="Release|Win32"
  255 + >
  256 + <Tool
  257 + Name="VCCLCompilerTool"
  258 + PreprocessorDefinitions=""
  259 + />
  260 + </FileConfiguration>
  261 + <FileConfiguration
  262 + Name="Debug|Win32"
  263 + >
  264 + <Tool
  265 + Name="VCCLCompilerTool"
  266 + PreprocessorDefinitions=""
  267 + />
  268 + </FileConfiguration>
  269 + </File>
  270 + <File
  271 + RelativePath="MTTTY.C"
  272 + >
  273 + <FileConfiguration
  274 + Name="Release|Win32"
  275 + >
  276 + <Tool
  277 + Name="VCCLCompilerTool"
  278 + PreprocessorDefinitions=""
  279 + />
  280 + </FileConfiguration>
  281 + <FileConfiguration
  282 + Name="Debug|Win32"
  283 + >
  284 + <Tool
  285 + Name="VCCLCompilerTool"
  286 + PreprocessorDefinitions=""
  287 + />
  288 + </FileConfiguration>
  289 + </File>
  290 + <File
  291 + RelativePath="MTTTY.RC"
  292 + >
  293 + <FileConfiguration
  294 + Name="Release|Win32"
  295 + >
  296 + <Tool
  297 + Name="VCResourceCompilerTool"
  298 + PreprocessorDefinitions=""
  299 + />
  300 + </FileConfiguration>
  301 + <FileConfiguration
  302 + Name="Debug|Win32"
  303 + >
  304 + <Tool
  305 + Name="VCResourceCompilerTool"
  306 + PreprocessorDefinitions=""
  307 + />
  308 + </FileConfiguration>
  309 + </File>
  310 + <File
  311 + RelativePath="READER.C"
  312 + >
  313 + <FileConfiguration
  314 + Name="Release|Win32"
  315 + >
  316 + <Tool
  317 + Name="VCCLCompilerTool"
  318 + PreprocessorDefinitions=""
  319 + />
  320 + </FileConfiguration>
  321 + <FileConfiguration
  322 + Name="Debug|Win32"
  323 + >
  324 + <Tool
  325 + Name="VCCLCompilerTool"
  326 + PreprocessorDefinitions=""
  327 + />
  328 + </FileConfiguration>
  329 + </File>
  330 + <File
  331 + RelativePath="READSTAT.C"
  332 + >
  333 + <FileConfiguration
  334 + Name="Release|Win32"
  335 + >
  336 + <Tool
  337 + Name="VCCLCompilerTool"
  338 + PreprocessorDefinitions=""
  339 + />
  340 + </FileConfiguration>
  341 + <FileConfiguration
  342 + Name="Debug|Win32"
  343 + >
  344 + <Tool
  345 + Name="VCCLCompilerTool"
  346 + PreprocessorDefinitions=""
  347 + />
  348 + </FileConfiguration>
  349 + </File>
  350 + <File
  351 + RelativePath="SETTINGS.C"
  352 + >
  353 + <FileConfiguration
  354 + Name="Release|Win32"
  355 + >
  356 + <Tool
  357 + Name="VCCLCompilerTool"
  358 + PreprocessorDefinitions=""
  359 + />
  360 + </FileConfiguration>
  361 + <FileConfiguration
  362 + Name="Debug|Win32"
  363 + >
  364 + <Tool
  365 + Name="VCCLCompilerTool"
  366 + PreprocessorDefinitions=""
  367 + />
  368 + </FileConfiguration>
  369 + </File>
  370 + <File
  371 + RelativePath="STATUS.C"
  372 + >
  373 + <FileConfiguration
  374 + Name="Release|Win32"
  375 + >
  376 + <Tool
  377 + Name="VCCLCompilerTool"
  378 + PreprocessorDefinitions=""
  379 + />
  380 + </FileConfiguration>
  381 + <FileConfiguration
  382 + Name="Debug|Win32"
  383 + >
  384 + <Tool
  385 + Name="VCCLCompilerTool"
  386 + PreprocessorDefinitions=""
  387 + />
  388 + </FileConfiguration>
  389 + </File>
  390 + <File
  391 + RelativePath="TRANSFER.C"
  392 + >
  393 + <FileConfiguration
  394 + Name="Release|Win32"
  395 + >
  396 + <Tool
  397 + Name="VCCLCompilerTool"
  398 + PreprocessorDefinitions=""
  399 + />
  400 + </FileConfiguration>
  401 + <FileConfiguration
  402 + Name="Debug|Win32"
  403 + >
  404 + <Tool
  405 + Name="VCCLCompilerTool"
  406 + PreprocessorDefinitions=""
  407 + />
  408 + </FileConfiguration>
  409 + </File>
  410 + <File
  411 + RelativePath="WRITER.C"
  412 + >
  413 + <FileConfiguration
  414 + Name="Release|Win32"
  415 + >
  416 + <Tool
  417 + Name="VCCLCompilerTool"
  418 + PreprocessorDefinitions=""
  419 + />
  420 + </FileConfiguration>
  421 + <FileConfiguration
  422 + Name="Debug|Win32"
  423 + >
  424 + <Tool
  425 + Name="VCCLCompilerTool"
  426 + PreprocessorDefinitions=""
  427 + />
  428 + </FileConfiguration>
  429 + </File>
  430 + </Filter>
  431 + <Filter
  432 + Name="Header Files"
  433 + Filter="h;hpp;hxx;hm;inl"
  434 + >
  435 + <File
  436 + RelativePath="MTTTY.H"
  437 + >
  438 + </File>
  439 + <File
  440 + RelativePath="RESOURCE.H"
  441 + >
  442 + </File>
  443 + <File
  444 + RelativePath="TTYINFO.H"
  445 + >
  446 + </File>
  447 + </Filter>
  448 + <Filter
  449 + Name="Resource Files"
  450 + Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
  451 + >
  452 + <File
  453 + RelativePath="MTTTY.ICO"
  454 + >
  455 + </File>
  456 + <File
  457 + RelativePath="MTTTY2.ICO"
  458 + >
  459 + </File>
  460 + <File
  461 + RelativePath="MTTTY3.ICO"
  462 + >
  463 + </File>
  464 + <File
  465 + RelativePath="MTTTY4.ICO"
  466 + >
  467 + </File>
  468 + </Filter>
  469 + </Files>
  470 + <Globals>
  471 + </Globals>
  472 +</VisualStudioProject>
... ...
No preview for this file type
  1 +/*-----------------------------------------------------------------------------
  2 +
  3 + This is a part of the Microsoft Source Code Samples.
  4 + Copyright (C) 1995 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 + MODULE: Reader.c
  12 +
  13 + PURPOSE: Read from comm port
  14 +
  15 + FUNCTIONS:
  16 + OutputABufferToWindow - process incoming data destined for tty window
  17 + OutputABufferToFile - process incoming data destined for a file
  18 + OutputABuffer - called when data is read from port
  19 +
  20 +-----------------------------------------------------------------------------*/
  21 +
  22 +#include <windows.h>
  23 +#include <commctrl.h>
  24 +
  25 +#include "MTTTY.h"
  26 +
  27 +/*
  28 + Prototypes for functions call only within this file
  29 +*/
  30 +void OutputABufferToFile( HANDLE, char *, DWORD );
  31 +
  32 +
  33 +/*-----------------------------------------------------------------------------
  34 +
  35 +FUNCTION: OutputABufferToWindow(HWND, char *, DWORD)
  36 +
  37 +PURPOSE: Updates TTY Buffer with characters just received.
  38 +
  39 +PARAMETERS:
  40 + hTTY - handle to the TTY child window
  41 + lpBuf - address of data buffer
  42 + dwBufLen - size of data buffer
  43 +
  44 +HISTORY: Date Author Comment
  45 + 5/ 8/91 BryanW Wrote it
  46 + 10/27/95 AllenD Modified for MTTTY Sample
  47 +
  48 +-----------------------------------------------------------------------------*/
  49 +void OutputABufferToWindow(HWND hTTY, char * lpBuf, DWORD dwBufLen)
  50 +{
  51 + RECT rect;
  52 +
  53 + /*
  54 + update screen buffer with new buffer
  55 + need to do a character by character check
  56 + for special characters
  57 + */
  58 + int i;
  59 +
  60 + for ( i = 0 ; i < (int) dwBufLen; i++) {
  61 + switch (lpBuf[ i ]) {
  62 + case ASCII_BEL: // BELL CHAR
  63 + MessageBeep( 0 ) ;
  64 + break ;
  65 +
  66 + case ASCII_BS: // Backspace CHAR
  67 + if (COLUMN( TTYInfo ) > 0)
  68 + COLUMN( TTYInfo ) -- ;
  69 + break ;
  70 +
  71 + case ASCII_CR: // Carriage Return
  72 + COLUMN( TTYInfo ) = 0 ;
  73 + if (!NEWLINE( TTYInfo ))
  74 + break;
  75 +
  76 + //
  77 + // FALL THROUGH
  78 + //
  79 +
  80 + case ASCII_LF: // Line Feed
  81 + if (ROW( TTYInfo )++ == MAXROWS - 1)
  82 + {
  83 + MoveMemory( (LPSTR) (SCREEN( TTYInfo )),
  84 + (LPSTR) (SCREEN( TTYInfo ) + MAXCOLS),
  85 + (MAXROWS - 1) * MAXCOLS ) ;
  86 + FillMemory((LPSTR) (SCREEN( TTYInfo ) + (MAXROWS - 1) * MAXCOLS),
  87 + MAXCOLS, ' ' ) ;
  88 + InvalidateRect( hTTY, NULL, FALSE ) ;
  89 + ROW( TTYInfo )-- ;
  90 + }
  91 + break ;
  92 +
  93 + default: // standard character
  94 + SCREENCHAR(TTYInfo, COLUMN(TTYInfo), ROW(TTYInfo)) = lpBuf[ i ];
  95 +
  96 + rect.left = (COLUMN( TTYInfo ) * XCHAR( TTYInfo )) -
  97 + XOFFSET( TTYInfo ) ;
  98 + rect.right = rect.left + XCHAR( TTYInfo ) ;
  99 + rect.top = (ROW( TTYInfo ) * YCHAR( TTYInfo )) -
  100 + YOFFSET( TTYInfo ) ;
  101 + rect.bottom = rect.top + YCHAR( TTYInfo ) ;
  102 + InvalidateRect( hTTY, &rect, FALSE ) ;
  103 +
  104 + //
  105 + // Line wrap
  106 + //
  107 + if (COLUMN( TTYInfo ) < MAXCOLS-1 )
  108 + COLUMN( TTYInfo )++ ;
  109 + else if (AUTOWRAP( TTYInfo ))
  110 + OutputABufferToWindow(hTTY, "\r\n", 2 ) ;
  111 +
  112 + break;
  113 + }
  114 + }
  115 +
  116 + MoveTTYCursor(hTTY);
  117 + return;
  118 +}
  119 +
  120 +/*-----------------------------------------------------------------------------
  121 +
  122 +FUNCTION: OutputABufferToFile(HANDLE, char *, DWORD)
  123 +
  124 +PURPOSE: Output a rec'd buffer to a file
  125 +
  126 +PARAMETERS:
  127 + hFile - handle of file save data into
  128 + lpBuf - address of data buffer
  129 + dwBufLen - size of data buffer
  130 +
  131 +HISTORY: Date: Author: Comment:
  132 + 10/27/95 AllenD Wrote it
  133 +
  134 +-----------------------------------------------------------------------------*/
  135 +void OutputABufferToFile(HANDLE hFile, char * lpBuf, DWORD dwBufLen)
  136 +{
  137 + DWORD dwWritten;
  138 +
  139 + //
  140 + // place buffer into file, report any errors
  141 + //
  142 + if (!WriteFile(hFile, lpBuf, dwBufLen, &dwWritten, NULL))
  143 + ErrorReporter("WriteFile in file capture");
  144 +
  145 + if (dwBufLen != dwWritten)
  146 + ErrorReporter("WriteFile");
  147 +
  148 + //
  149 + // update transfer progress bar
  150 + //
  151 + PostMessage(GetDlgItem(ghWndStatusDlg, IDC_TRANSFERPROGRESS), PBM_STEPIT, 0, 0);
  152 +
  153 + return;
  154 +}
  155 +
  156 +/*-----------------------------------------------------------------------------
  157 +
  158 +FUNCTION: OutputABuffer(HWND, char *, DWORD)
  159 +
  160 +PURPOSE: Send a rec'd buffer to the approprate location
  161 +
  162 +PARAMETERS:
  163 + hTTY - handle to the TTY child window
  164 + lpBuf - address of data buffer
  165 + dwBufLen - size of data buffer
  166 +
  167 +COMMENTS: If buffer is 0 length, then do nothing.
  168 +
  169 +HISTORY: Date: Author: Comment:
  170 + 10/27/95 AllenD Wrote it
  171 +
  172 +-----------------------------------------------------------------------------*/
  173 +void OutputABuffer(HWND hTTY, char * lpBuf, DWORD dwBufLen)
  174 +{
  175 + if (dwBufLen == 0) {
  176 + OutputDebugString("NULL Buffer in OutputABuffer\n\r");
  177 + return;
  178 + }
  179 +
  180 + switch(gdwReceiveState)
  181 + {
  182 + case RECEIVE_TTY:
  183 + OutputABufferToWindow(hTTY, lpBuf, dwBufLen);
  184 + break;
  185 +
  186 + case RECEIVE_CAPTURED:
  187 + OutputABufferToFile(ghFileCapture, lpBuf, dwBufLen);
  188 + break;
  189 +
  190 + default:
  191 + OutputDebugString("Unknown receive state!\n\r");
  192 + }
  193 +
  194 + return;
  195 +}
... ...
  1 +/*-----------------------------------------------------------------------------
  2 + This is a part of the Microsoft Source Code Samples.
  3 + Copyright (C) 1995 Microsoft Corporation.
  4 + All rights reserved.
  5 + This source code is only intended as a supplement to
  6 + Microsoft Development Tools and/or WinHelp documentation.
  7 + See these sources for detailed information regarding the
  8 + Microsoft samples programs.
  9 +
  10 + MODULE: ReadStat.c
  11 +
  12 + PURPOSE: Thread procedure responsible for reading comm port,
  13 + reporting status events, report status messages,
  14 + and periodically updating status controls
  15 +
  16 + FUNCTIONS:
  17 + ReaderAndStatusProc - Thread procedure does the work here
  18 +
  19 +-----------------------------------------------------------------------------*/
  20 +
  21 +#include <windows.h>
  22 +#include "mttty.h"
  23 +
  24 +#define AMOUNT_TO_READ 512
  25 +#define NUM_READSTAT_HANDLES 4
  26 +
  27 +/*-----------------------------------------------------------------------------
  28 +
  29 +FUNCTION: ReaderAndStatusProc(LPVOID)
  30 +
  31 +PURPOSE: Thread function controls comm port reading, comm port status
  32 + checking, and status messages.
  33 +
  34 +PARMATERS:
  35 + lpV - 4 byte value contains the tty child window handle
  36 +
  37 +RETURN: always 1
  38 +
  39 +COMMENTS: Waits on various events in the applications to handle
  40 + port reading, status checking, status messages and modem status.
  41 +
  42 +HISTORY: Date: Author: Comment:
  43 + 10/27/95 AllenD Wrote it
  44 + 11/21/95 AllenD Incorporated status message heap
  45 +
  46 +-----------------------------------------------------------------------------*/
  47 +DWORD WINAPI ReaderAndStatusProc(LPVOID lpV)
  48 +{
  49 + OVERLAPPED osReader = {0}; // overlapped structure for read operations
  50 + OVERLAPPED osStatus = {0}; // overlapped structure for status operations
  51 + HANDLE hArray[NUM_READSTAT_HANDLES];
  52 + DWORD dwStoredFlags = 0xFFFFFFFF; // local copy of event flags
  53 + DWORD dwCommEvent; // result from WaitCommEvent
  54 + DWORD dwOvRes; // result from GetOverlappedResult
  55 + DWORD dwRead; // bytes actually read
  56 + DWORD dwRes; // result from WaitForSingleObject
  57 + BOOL fWaitingOnRead = FALSE;
  58 + BOOL fWaitingOnStat = FALSE;
  59 + BOOL fThreadDone = FALSE;
  60 + char lpBuf[AMOUNT_TO_READ];
  61 + HWND hTTY;
  62 +
  63 + hTTY = (HANDLE) lpV;
  64 +
  65 + //
  66 + // create two overlapped structures, one for read events
  67 + // and another for status events
  68 + //
  69 + osReader.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
  70 + if (osReader.hEvent == NULL)
  71 + ErrorInComm("CreateEvent (Reader Event)");
  72 +
  73 + osStatus.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
  74 + if (osStatus.hEvent == NULL)
  75 + ErrorInComm("CreateEvent (Status Event)");
  76 +
  77 + //
  78 + // We want to detect the following events:
  79 + // Read events (from ReadFile)
  80 + // Status events (from WaitCommEvent)
  81 + // Status message events (from our UpdateStatus)
  82 + // Thread exit evetns (from our shutdown functions)
  83 + //
  84 + hArray[0] = osReader.hEvent;
  85 + hArray[1] = osStatus.hEvent;
  86 + hArray[2] = ghStatusMessageEvent;
  87 + hArray[3] = ghThreadExitEvent;
  88 +
  89 + //
  90 + // initial check, forces updates
  91 + //
  92 + CheckModemStatus(TRUE);
  93 + CheckComStat(TRUE);
  94 +
  95 + while ( !fThreadDone ) {
  96 +
  97 + //
  98 + // If no reading is allowed, then set flag to
  99 + // make it look like a read is already outstanding.
  100 + //
  101 + if (NOREADING( TTYInfo ))
  102 + fWaitingOnRead = TRUE;
  103 +
  104 + //
  105 + // if no read is outstanding, then issue another one
  106 + //
  107 + if (!fWaitingOnRead) {
  108 + if (!ReadFile(COMDEV(TTYInfo), lpBuf, AMOUNT_TO_READ, &dwRead, &osReader)) {
  109 + if (GetLastError() != ERROR_IO_PENDING) // read not delayed?
  110 + ErrorInComm("ReadFile in ReaderAndStatusProc");
  111 +
  112 + fWaitingOnRead = TRUE;
  113 + }
  114 + else { // read completed immediately
  115 + if ((dwRead != MAX_READ_BUFFER) && SHOWTIMEOUTS(TTYInfo))
  116 + UpdateStatus("Read timed out immediately.\r\n");
  117 +
  118 + if (dwRead)
  119 + OutputABuffer(hTTY, lpBuf, dwRead);
  120 + }
  121 + }
  122 +
  123 + //
  124 + // If status flags have changed, then reset comm mask.
  125 + // This will cause a pending WaitCommEvent to complete
  126 + // and the resultant event flag will be NULL.
  127 + //
  128 + if (dwStoredFlags != EVENTFLAGS(TTYInfo)) {
  129 + dwStoredFlags = EVENTFLAGS(TTYInfo);
  130 + if (!SetCommMask(COMDEV(TTYInfo), dwStoredFlags))
  131 + ErrorReporter("SetCommMask");
  132 + }
  133 +
  134 + //
  135 + // If event checks are not allowed, then make it look
  136 + // like an event check operation is outstanding
  137 + //
  138 + if (NOEVENTS(TTYInfo))
  139 + fWaitingOnStat = TRUE;
  140 + //
  141 + // if no status check is outstanding, then issue another one
  142 + //
  143 + if (!fWaitingOnStat) {
  144 + if (NOEVENTS(TTYInfo))
  145 + fWaitingOnStat = TRUE;
  146 + else {
  147 + if (!WaitCommEvent(COMDEV(TTYInfo), &dwCommEvent, &osStatus)) {
  148 + if (GetLastError() != ERROR_IO_PENDING) // Wait not delayed?
  149 + ErrorReporter("WaitCommEvent");
  150 + else
  151 + fWaitingOnStat = TRUE;
  152 + }
  153 + else
  154 + // WaitCommEvent returned immediately
  155 + ReportStatusEvent(dwCommEvent);
  156 + }
  157 + }
  158 +
  159 + //
  160 + // wait for pending operations to complete
  161 + //
  162 + if ( fWaitingOnStat && fWaitingOnRead ) {
  163 + dwRes = WaitForMultipleObjects(NUM_READSTAT_HANDLES, hArray, FALSE, STATUS_CHECK_TIMEOUT);
  164 + switch(dwRes)
  165 + {
  166 + //
  167 + // read completed
  168 + //
  169 + case WAIT_OBJECT_0:
  170 + if (!GetOverlappedResult(COMDEV(TTYInfo), &osReader, &dwRead, FALSE)) {
  171 + if (GetLastError() == ERROR_OPERATION_ABORTED)
  172 + UpdateStatus("Read aborted\r\n");
  173 + else
  174 + ErrorInComm("GetOverlappedResult (in Reader)");
  175 + }
  176 + else { // read completed successfully
  177 + if ((dwRead != MAX_READ_BUFFER) && SHOWTIMEOUTS(TTYInfo))
  178 + UpdateStatus("Read timed out overlapped.\r\n");
  179 +
  180 + if (dwRead)
  181 + OutputABuffer(hTTY, lpBuf, dwRead);
  182 + }
  183 +
  184 + fWaitingOnRead = FALSE;
  185 + break;
  186 +
  187 + //
  188 + // status completed
  189 + //
  190 + case WAIT_OBJECT_0 + 1:
  191 + if (!GetOverlappedResult(COMDEV(TTYInfo), &osStatus, &dwOvRes, FALSE)) {
  192 + if (GetLastError() == ERROR_OPERATION_ABORTED)
  193 + UpdateStatus("WaitCommEvent aborted\r\n");
  194 + else
  195 + ErrorInComm("GetOverlappedResult (in Reader)");
  196 + }
  197 + else // status check completed successfully
  198 + ReportStatusEvent(dwCommEvent);
  199 +
  200 + fWaitingOnStat = FALSE;
  201 + break;
  202 +
  203 + //
  204 + // status message event
  205 + //
  206 + case WAIT_OBJECT_0 + 2:
  207 + StatusMessage();
  208 + break;
  209 +
  210 + //
  211 + // thread exit event
  212 + //
  213 + case WAIT_OBJECT_0 + 3:
  214 + fThreadDone = TRUE;
  215 + break;
  216 +
  217 + case WAIT_TIMEOUT:
  218 + //
  219 + // timeouts are not reported because they happen too often
  220 + // OutputDebugString("Timeout in Reader & Status checking\n\r");
  221 + //
  222 +
  223 + //
  224 + // if status checks are not allowed, then don't issue the
  225 + // modem status check nor the com stat check
  226 + //
  227 + if (!NOSTATUS(TTYInfo)) {
  228 + CheckModemStatus(FALSE); // take this opportunity to do
  229 + CheckComStat(FALSE); // a modem status check and
  230 + // a comm status check
  231 + }
  232 +
  233 + break;
  234 +
  235 + default:
  236 + ErrorReporter("WaitForMultipleObjects(Reader & Status handles)");
  237 + break;
  238 + }
  239 + }
  240 + }
  241 +
  242 + //
  243 + // close event handles
  244 + //
  245 + CloseHandle(osReader.hEvent);
  246 + CloseHandle(osStatus.hEvent);
  247 +
  248 + return 1;
  249 +}
... ...
1   -========================================================================
2   - MICROSOFT FOUNDATION CLASS LIBRARY : BlueFlashTool
3   -========================================================================
4   -
5   -
6   -AppWizard has created this BlueFlashTool application for you. This application
7   -not only demonstrates the basics of using the Microsoft Foundation classes
8   -but is also a starting point for writing your application.
9   -
10   -This file contains a summary of what you will find in each of the files that
11   -make up your BlueFlashTool application.
12   -
13   -BlueFlashTool.dsp
14   - This file (the project file) contains information at the project level and
15   - is used to build a single project or subproject. Other users can share the
16   - project (.dsp) file, but they should export the makefiles locally.
17   -
18   -BlueFlashTool.h
19   - This is the main header file for the application. It includes other
20   - project specific headers (including Resource.h) and declares the
21   - CBlueFlashToolApp application class.
22   -
23   -BlueFlashTool.cpp
24   - This is the main application source file that contains the application
25   - class CBlueFlashToolApp.
26   -
27   -BlueFlashTool.rc
28   - This is a listing of all of the Microsoft Windows resources that the
29   - program uses. It includes the icons, bitmaps, and cursors that are stored
30   - in the RES subdirectory. This file can be directly edited in Microsoft
31   - Visual C++.
32   -
33   -BlueFlashTool.clw
34   - This file contains information used by ClassWizard to edit existing
35   - classes or add new classes. ClassWizard also uses this file to store
36   - information needed to create and edit message maps and dialog data
37   - maps and to create prototype member functions.
38   -
39   -res\BlueFlashTool.ico
40   - This is an icon file, which is used as the application's icon. This
41   - icon is included by the main resource file BlueFlashTool.rc.
42   -
43   -res\BlueFlashTool.rc2
44   - This file contains resources that are not edited by Microsoft
45   - Visual C++. You should place all resources not editable by
46   - the resource editor in this file.
47   -
48   -
49   -
50   -
51   -/////////////////////////////////////////////////////////////////////////////
52   -
53   -AppWizard creates one dialog class:
54   -
55   -BlueFlashToolDlg.h, BlueFlashToolDlg.cpp - the dialog
56   - These files contain your CBlueFlashToolDlg class. This class defines
57   - the behavior of your application's main dialog. The dialog's
58   - template is in BlueFlashTool.rc, which can be edited in Microsoft
59   - Visual C++.
60   -
61   -
62   -/////////////////////////////////////////////////////////////////////////////
63   -Other standard files:
64   -
65   -StdAfx.h, StdAfx.cpp
66   - These files are used to build a precompiled header (PCH) file
67   - named BlueFlashTool.pch and a precompiled types file named StdAfx.obj.
68   -
69   -Resource.h
70   - This is the standard header file, which defines new resource IDs.
71   - Microsoft Visual C++ reads and updates this file.
72   -
73   -/////////////////////////////////////////////////////////////////////////////
74   -Other notes:
75   -
76   -AppWizard uses "TODO:" to indicate parts of the source code you
77   -should add to or customize.
78   -
79   -If your application uses MFC in a shared DLL, and your application is
80   -in a language other than the operating system's current language, you
81   -will need to copy the corresponding localized resources MFC42XXX.DLL
82   -from the Microsoft Visual C++ CD-ROM onto the system or system32 directory,
83   -and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation.
84   -For example, MFC42DEU.DLL contains resources translated to German.) If you
85   -don't do this, some of the UI elements of your application will remain in the
86   -language of the operating system.
87   -
88   -/////////////////////////////////////////////////////////////////////////////
  1 +/*-----------------------------------------------------------------------------
  2 + This is a part of the Microsoft Source Code Samples.
  3 + Copyright (C) 1995 Microsoft Corporation.
  4 + All rights reserved.
  5 + This source code is only intended as a supplement to
  6 + Microsoft Development Tools and/or WinHelp documentation.
  7 + See these sources for detailed information regarding the
  8 + Microsoft samples programs.
  9 +
  10 + MODULE: Settings.c
  11 +
  12 + PURPOSE: Controls all dialog controls in the Settings Dialog as well
  13 + as the comm events dialog, flow control dialog, and timeouts
  14 + dialog. The module also controls the tty settings based on
  15 + these dialogs and also control comm port settings using
  16 + SetCommState and SetCommTimeouts.
  17 +
  18 + FUNCTIONS:
  19 + OpenSettingsToolbar - Creates the Settings Dialog
  20 + ChangeConnection - Modifies menus & controls based on connection state
  21 + UpdateTTYInfo - Modifies TTY data from Settings Dialog and
  22 + if connected, updates open comm port settings
  23 + FillComboBox - Fills a combo box with strings
  24 + SetComboBox - Selects an entry from a combo box
  25 + SettingDlgInit - Initializes settings dialog
  26 + GetdwTTYItem - returns a DWORD value from a dialog control
  27 + GetbTTYItem - returns a BYTE value from a dialog control
  28 + ToolbarProc - Dialog procedure for Settings Dialog
  29 + InitHexControl - Places a byte value into edit controls of a dialog
  30 + GetHexControl - returns hex data from a control and converts to a char
  31 + InitCommEventsDlg - Initializes Comm Events Dialog
  32 + SaveCommEventsDlg - Saves comm events flag if changed
  33 + CommEventsProc - Dialog procedure for Comm Events Dialog
  34 + SaveFlowControlDlg - Saves flow control settings if changed
  35 + InitFlowControlDlg - Inititlizes Flow Control Dialog
  36 + FlowDefault - sets "hardware" or "software" flow control
  37 + FlowControlProc - Dialog procedure for Flow Control Dialog
  38 + InitTimeoutsDlg - Initializes Timeouts Dialog
  39 + SaveTimeoutsDlg - Saves comm timeouts from Timeouts Dialog
  40 + TimeoutsProc - Dialog procedure for Timeouts Dialog
  41 +
  42 +-----------------------------------------------------------------------------*/
  43 +
  44 +#include <windows.h>
  45 +#include <stdio.h>
  46 +
  47 +#include "mttty.h"
  48 +
  49 +#define MAXLEN_TEMPSTR 20
  50 +
  51 +/*
  52 + Prototypes for functions called only within this file
  53 +*/
  54 +void FillComboBox( HWND, char ** szString, DWORD *, WORD, DWORD );
  55 +BOOL SettingsDlgInit( HWND );
  56 +DWORD GetdwTTYItem( HWND, int, char **, DWORD *, int );
  57 +BYTE GetbTTYItem( HWND, int, char **, DWORD *, int);
  58 +BOOL CALLBACK CommEventsProc( HWND, UINT, WPARAM, LPARAM );
  59 +BOOL CALLBACK ToolbarProc( HWND, UINT, WPARAM, LPARAM );
  60 +void InitHexControl(HWND, WORD, WORD, char);
  61 +char GetHexControl(HWND, WORD, WORD);
  62 +void SaveCommEventsDlg( HWND );
  63 +void InitCommEventsDlg( HWND, DWORD );
  64 +BOOL CALLBACK FlowControlProc( HWND, UINT, WPARAM, LPARAM );
  65 +void InitFlowControlDlg( HWND );
  66 +void SaveFlowControlDlg( HWND );
  67 +void FlowDefault(HWND hdlg, WORD wId);
  68 +BOOL CALLBACK TimeoutsProc( HWND, UINT, WPARAM, LPARAM );
  69 +void InitTimeoutsDlg( HWND, COMMTIMEOUTS );
  70 +void SaveTimeoutsDlg( HWND );
  71 +BOOL CALLBACK GetADWORDProc( HWND, UINT, WPARAM, LPARAM );
  72 +
  73 +/*
  74 + GLOBALS for this file
  75 + The string arrays are the items in the dialog list controls.
  76 +*/
  77 +
  78 +DCB dcbTemp;
  79 +
  80 +#if 1
  81 +char * szBaud[] = {
  82 + "115200*1", "115200*2", "115200*4", "115200*8"
  83 +};
  84 +
  85 +DWORD BaudTable[] = {
  86 + (CBR_115200)*1,(CBR_115200)*2,(CBR_115200)*4,(CBR_115200)*8
  87 +} ;
  88 +
  89 +#else
  90 +char * szBaud[] = {
  91 + "110", "300", "600", "1200", "2400",
  92 + "4800", "9600", "14400", "19200",
  93 + "38400", "56000", "57600", "460800",
  94 + "128000"
  95 + };
  96 +
  97 +DWORD BaudTable[] = {
  98 + CBR_110, CBR_300, CBR_600, CBR_1200, CBR_2400,
  99 + CBR_4800, CBR_9600, CBR_14400, CBR_19200, CBR_38400,
  100 + CBR_56000, CBR_57600, (CBR_115200)*4, CBR_128000
  101 + } ;
  102 +#endif
  103 +char * szParity[] = { "None", "Even", "Odd", "Mark", "Space" };
  104 +
  105 +DWORD ParityTable[] = { NOPARITY, EVENPARITY, ODDPARITY, MARKPARITY, SPACEPARITY } ;
  106 +
  107 +char * szStopBits[] = { "1", "1.5", "2" };
  108 +
  109 +DWORD StopBitsTable[] = { ONESTOPBIT, ONE5STOPBITS, TWOSTOPBITS } ;
  110 +
  111 +char * szDTRControlStrings[] = { "Enable", "Disable", "Handshake" };
  112 +
  113 +DWORD DTRControlTable[] = { DTR_CONTROL_ENABLE, DTR_CONTROL_DISABLE, DTR_CONTROL_HANDSHAKE };
  114 +
  115 +char * szRTSControlStrings[] = { "Enable", "Disable", "Handshake", "Toggle" };
  116 +
  117 +DWORD RTSControlTable[] = { RTS_CONTROL_ENABLE, RTS_CONTROL_DISABLE,
  118 + RTS_CONTROL_HANDSHAKE, RTS_CONTROL_TOGGLE };
  119 +
  120 +DWORD EventFlagsTable[] = {
  121 + EV_BREAK, EV_CTS, EV_DSR, EV_ERR, EV_RING,
  122 + EV_RLSD, EV_RXCHAR, EV_RXFLAG, EV_TXEMPTY
  123 + };
  124 +
  125 +/*-----------------------------------------------------------------------------
  126 +
  127 +FUNCTION: OpenSettingsToolbar(HWND)
  128 +
  129 +PURPOSE: Open Settings Dialog
  130 +
  131 +PARAMETERS:
  132 + hWnd - dialog owner window handle
  133 +
  134 +HISTORY: Date: Author: Comment:
  135 + 10/27/95 AllenD Wrote it
  136 +
  137 +-----------------------------------------------------------------------------*/
  138 +void OpenSettingsToolbar(HWND hWnd)
  139 +{
  140 + ghWndToolbarDlg = CreateDialog(ghInst, MAKEINTRESOURCE(IDD_TOOLBARSETTINGS), hWnd, ToolbarProc);
  141 +
  142 + if (ghWndToolbarDlg == NULL)
  143 + ErrorReporter("CreateDialog (Toolbar Dialog)");
  144 +
  145 + return;
  146 +}
  147 +
  148 +/*-----------------------------------------------------------------------------
  149 +
  150 +FUNCTION: ChangeConnection(HWND, BOOL)
  151 +
  152 +PURPOSE: Modifies connection appearance
  153 +
  154 +PARAMETERS:
  155 + hwnd - menu owner windows
  156 + fConnected - TRUE sets connection appearance to connected
  157 + FALSE sets appearance to not connected
  158 +
  159 +HISTORY: Date: Author: Comment:
  160 + 10/27/95 AllenD Wrote it
  161 +
  162 +-----------------------------------------------------------------------------*/
  163 +void ChangeConnection( HWND hwnd, BOOL fConnected )
  164 +{
  165 + HMENU hMenu;
  166 + int i;
  167 +
  168 + if (fConnected) {
  169 + /*
  170 + The port is connected. Need to :
  171 + Disable connect menu and enable disconnect menu.
  172 + Enable file transfer menu
  173 + Disable comm port selection box
  174 + Disable no writing, no reading, no events, no status check boxes
  175 + Enable status check boxes
  176 + Set focus to the child tty window
  177 + */
  178 + hMenu = GetMenu( hwnd ) ;
  179 + EnableMenuItem( hMenu, ID_FILE_CONNECT,
  180 + MF_GRAYED | MF_DISABLED | MF_BYCOMMAND ) ;
  181 + EnableMenuItem( hMenu, ID_FILE_DISCONNECT,
  182 + MF_ENABLED | MF_BYCOMMAND ) ;
  183 +
  184 + EnableMenuItem( hMenu, ID_TRANSFER_SENDFILETEXT,
  185 + MF_ENABLED | MF_BYCOMMAND ) ;
  186 + EnableMenuItem( hMenu, ID_TRANSFER_RECEIVEFILETEXT,
  187 + MF_ENABLED | MF_BYCOMMAND ) ;
  188 + EnableMenuItem( hMenu, ID_TRANSFER_SENDREPEATEDLY,
  189 + MF_ENABLED | MF_BYCOMMAND ) ;
  190 + EnableMenuItem( hMenu, ID_TRANSFER_ABORTSENDING,
  191 + MF_DISABLED | MF_GRAYED | MF_BYCOMMAND );
  192 + EnableMenuItem( hMenu, ID_TRANSFER_ABORTREPEATEDSENDING,
  193 + MF_DISABLED | MF_GRAYED | MF_BYCOMMAND );
  194 +
  195 + EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_PORTCOMBO), FALSE);
  196 + EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_NOWRITINGCHK), FALSE);
  197 + EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_NOREADINGCHK), FALSE);
  198 + EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_NOEVENTSCHK), FALSE);
  199 + EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_NOSTATUSCHK), FALSE);
  200 +
  201 + for (i = IDC_STATCTS; i <= IDC_STATRLSD; i++)
  202 + EnableWindow( GetDlgItem(ghWndStatusDlg, i), TRUE );
  203 +
  204 + for (i = IDC_CTSHOLDCHK; i <= IDC_RXCHAREDIT; i++)
  205 + EnableWindow( GetDlgItem(ghWndStatusDlg, i), TRUE);
  206 +
  207 + SetFocus(ghWndTTY);
  208 + }
  209 + else {
  210 + //
  211 + // Not connected, do opposite of above.
  212 + //
  213 + hMenu = GetMenu( hwnd ) ;
  214 + EnableMenuItem( hMenu, ID_FILE_CONNECT,
  215 + MF_ENABLED | MF_BYCOMMAND ) ;
  216 + EnableMenuItem( hMenu, ID_FILE_DISCONNECT,
  217 + MF_GRAYED | MF_DISABLED | MF_BYCOMMAND ) ;
  218 +
  219 + EnableMenuItem( hMenu, ID_TRANSFER_SENDFILETEXT,
  220 + MF_DISABLED | MF_GRAYED | MF_BYCOMMAND ) ;
  221 + EnableMenuItem( hMenu, ID_TRANSFER_RECEIVEFILETEXT,
  222 + MF_DISABLED | MF_GRAYED | MF_BYCOMMAND ) ;
  223 + EnableMenuItem( hMenu, ID_TRANSFER_SENDREPEATEDLY,
  224 + MF_DISABLED | MF_GRAYED | MF_BYCOMMAND ) ;
  225 + EnableMenuItem( hMenu, ID_TRANSFER_ABORTSENDING,
  226 + MF_DISABLED | MF_GRAYED | MF_BYCOMMAND ) ;
  227 + EnableMenuItem( hMenu, ID_TRANSFER_ABORTREPEATEDSENDING,
  228 + MF_DISABLED | MF_GRAYED | MF_BYCOMMAND );
  229 +
  230 + EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_PORTCOMBO), TRUE);
  231 + EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_NOWRITINGCHK), TRUE);
  232 + EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_NOREADINGCHK), TRUE);
  233 + EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_NOEVENTSCHK), TRUE);
  234 + EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_NOSTATUSCHK), TRUE);
  235 +
  236 + for (i = IDC_STATCTS; i <= IDC_STATRLSD; i++) {
  237 + CheckDlgButton(ghWndStatusDlg, i, 0);
  238 + EnableWindow( GetDlgItem(ghWndStatusDlg, i), FALSE );
  239 + }
  240 +
  241 + for (i = IDC_CTSHOLDCHK; i <= IDC_RXCHAREDIT; i++) {
  242 + if (i != IDC_TXCHAREDIT && i != IDC_RXCHAREDIT)
  243 + CheckDlgButton(ghWndStatusDlg, i, 0);
  244 + else
  245 + SetDlgItemInt(ghWndStatusDlg, i, 0, FALSE);
  246 +
  247 + EnableWindow( GetDlgItem(ghWndStatusDlg, i), FALSE);
  248 + }
  249 +
  250 + SetFocus(ghwndMain);
  251 + }
  252 +
  253 + return;
  254 +}
  255 +
  256 +
  257 +/*-----------------------------------------------------------------------------
  258 +
  259 +FUNCTION: UpdateTTYInfo(void)
  260 +
  261 +PURPOSE: Modifies TTY data based on the settings and calls UpdateConnection
  262 +
  263 +COMMENTS: Modifies the data based on the dialog. If connected,
  264 + calls UpdateConnection.
  265 +
  266 +HISTORY: Date: Author: Comment:
  267 + 10/27/95 AllenD Wrote it
  268 + 1/ 9/96 AllenD Split DCB settings to new function
  269 +
  270 +-----------------------------------------------------------------------------*/
  271 +void UpdateTTYInfo()
  272 +{
  273 + //
  274 + // update globals from dialog settings
  275 + //
  276 + char gszPort_Temp[20] = {0};
  277 +
  278 + GetDlgItemText(ghWndToolbarDlg, IDC_PORTCOMBO, gszPort, sizeof(gszPort));
  279 + /*MessageBox(NULL, gszPort, "TEST", MB_OK);*/
  280 +
  281 + if (gszPort[3] - '0' > 0 && gszPort[4] - '0' > 0)
  282 + {
  283 + wsprintf(gszPort_Temp,"\\\\.\\%s%d","COM", (gszPort[3] - '0' )*10 + (gszPort[4] - '0'));
  284 + memset(gszPort, 20, sizeof(char));
  285 + strcpy(gszPort, gszPort_Temp);
  286 + /*MessageBox(NULL, gszPort, "TEST---", MB_OK);*/
  287 + }
  288 +
  289 + BAUDRATE(TTYInfo) = GetdwTTYItem( ghWndToolbarDlg,
  290 + IDC_BAUDCOMBO,
  291 + szBaud,
  292 + BaudTable,
  293 + sizeof(BaudTable)/sizeof(BaudTable[0]));
  294 +
  295 + PARITY(TTYInfo) = GetbTTYItem( ghWndToolbarDlg,
  296 + IDC_PARITYCOMBO,
  297 + szParity,
  298 + ParityTable,
  299 + sizeof(ParityTable)/sizeof(ParityTable[0]));
  300 +
  301 + STOPBITS(TTYInfo) = GetbTTYItem( ghWndToolbarDlg,
  302 + IDC_STOPBITSCOMBO,
  303 + szStopBits,
  304 + StopBitsTable,
  305 + sizeof(StopBitsTable)/sizeof(StopBitsTable[0]));
  306 +
  307 + LOCALECHO(TTYInfo) = IsDlgButtonChecked(ghWndToolbarDlg, IDC_LOCALECHOCHK);
  308 + BYTESIZE(TTYInfo) = GetDlgItemInt(ghWndToolbarDlg, IDC_DATABITSCOMBO, NULL, FALSE);
  309 + NEWLINE(TTYInfo) = IsDlgButtonChecked(ghWndToolbarDlg, IDC_LFBTN);
  310 + AUTOWRAP(TTYInfo) = IsDlgButtonChecked(ghWndToolbarDlg, IDC_AUTOWRAPCHK);
  311 + DISPLAYERRORS(TTYInfo) = IsDlgButtonChecked(ghWndToolbarDlg, IDC_DISPLAYERRORSCHK);
  312 +
  313 + NOREADING(TTYInfo) = IsDlgButtonChecked(ghWndToolbarDlg, IDC_NOREADINGCHK);
  314 + NOWRITING(TTYInfo) = IsDlgButtonChecked(ghWndToolbarDlg, IDC_NOWRITINGCHK);
  315 + NOEVENTS(TTYInfo) = IsDlgButtonChecked(ghWndToolbarDlg, IDC_NOEVENTSCHK);
  316 + NOSTATUS(TTYInfo) = IsDlgButtonChecked(ghWndToolbarDlg, IDC_NOSTATUSCHK);
  317 +
  318 + if (CONNECTED(TTYInfo)) // if connected, then update port state
  319 + UpdateConnection();
  320 +
  321 + return;
  322 +}
  323 +
  324 +/*-----------------------------------------------------------------------------
  325 +
  326 +FUNCTION: UpdateConnection( void )
  327 +
  328 +PURPOSE: Sets port state based on settings from the user
  329 +
  330 +COMMENTS: Sets up DCB structure and calls SetCommState.
  331 + Sets up new timeouts by calling SetCommTimeouts.
  332 +
  333 +HISTORY: Date: Author: Comment:
  334 + 1/ 9/96 AllenD Wrote it
  335 +
  336 +-----------------------------------------------------------------------------*/
  337 +BOOL UpdateConnection()
  338 +{
  339 + DCB dcb = {0};
  340 +
  341 + dcb.DCBlength = sizeof(dcb);
  342 +
  343 + //
  344 + // get current DCB settings
  345 + //
  346 + if (!GetCommState(COMDEV(TTYInfo), &dcb))
  347 + ErrorReporter("GetCommState");
  348 +
  349 + //
  350 + // update DCB rate, byte size, parity, and stop bits size
  351 + //
  352 + dcb.BaudRate = BAUDRATE(TTYInfo);
  353 + dcb.ByteSize = BYTESIZE(TTYInfo);
  354 + dcb.Parity = PARITY(TTYInfo);
  355 + dcb.StopBits = STOPBITS(TTYInfo);
  356 +
  357 + //
  358 + // update event flags
  359 + //
  360 + if (EVENTFLAGS(TTYInfo) & EV_RXFLAG)
  361 + dcb.EvtChar = FLAGCHAR(TTYInfo);
  362 + else
  363 + dcb.EvtChar = '\0';
  364 +
  365 + //
  366 + // update flow control settings
  367 + //
  368 + dcb.fDtrControl = DTRCONTROL(TTYInfo);
  369 + dcb.fRtsControl = RTSCONTROL(TTYInfo);
  370 +
  371 + dcb.fOutxCtsFlow = CTSOUTFLOW(TTYInfo);
  372 + dcb.fOutxDsrFlow = DSROUTFLOW(TTYInfo);
  373 + dcb.fDsrSensitivity = DSRINFLOW(TTYInfo);
  374 + dcb.fOutX = XONXOFFOUTFLOW(TTYInfo);
  375 + dcb.fInX = XONXOFFINFLOW(TTYInfo);
  376 + dcb.fTXContinueOnXoff = TXAFTERXOFFSENT(TTYInfo);
  377 + dcb.XonChar = XONCHAR(TTYInfo);
  378 + dcb.XoffChar = XOFFCHAR(TTYInfo);
  379 + dcb.XonLim = XONLIMIT(TTYInfo);
  380 + dcb.XoffLim = XOFFLIMIT(TTYInfo);
  381 +
  382 + //
  383 + // DCB settings not in the user's control
  384 + //
  385 + dcb.fParity = TRUE;
  386 +
  387 + //
  388 + // set new state
  389 + //
  390 + if (!SetCommState(COMDEV(TTYInfo), &dcb))
  391 + ErrorReporter("SetCommState");
  392 +
  393 + //
  394 + // set new timeouts
  395 + //
  396 + if (!SetCommTimeouts(COMDEV(TTYInfo), &(TIMEOUTSNEW(TTYInfo))))
  397 + ErrorReporter("SetCommTimeouts");
  398 +
  399 + return TRUE;
  400 +}
  401 +
  402 +
  403 +/*-----------------------------------------------------------------------------
  404 +
  405 +FUNCTION: FillComboBox(HWND, char **, DWORD *, WORD, DWORD)
  406 +
  407 +PURPOSE: Populates dialog controls with proper strings
  408 +
  409 +PARAMETERS:
  410 + hCtrlWnd - window handle of control being filled
  411 + szString - string table contains strings to fill control with
  412 + npTable - table of values corresponding to strings
  413 + wTableLen - length of the string table
  414 + dwCurrentSetting - initialz combo box selection
  415 +
  416 +COMMENTS: This function originally found in the Win32 COMM sample
  417 + Written by BryanW. Modified for Win32 MTTTY Sample.
  418 +
  419 +HISTORY: Date: Author: Comment:
  420 + 10/27/95 AllenD Modified for MTTTY
  421 +
  422 +-----------------------------------------------------------------------------*/
  423 +void FillComboBox( HWND hCtrlWnd, char ** szString,
  424 + DWORD * npTable, WORD wTableLen, DWORD dwCurrentSetting )
  425 +{
  426 + WORD wCount, wPosition ;
  427 +
  428 + for (wCount = 0; wCount < wTableLen; wCount++) {
  429 + wPosition = LOWORD( SendMessage( hCtrlWnd, CB_ADDSTRING, 0,
  430 + (LPARAM) (LPSTR) szString[wCount] ) ) ;
  431 +
  432 + //
  433 + // use item data to store the actual table value
  434 + //
  435 + SendMessage( hCtrlWnd, CB_SETITEMDATA, (WPARAM) wPosition,
  436 + (LPARAM) *(npTable + wCount) ) ;
  437 +
  438 + //
  439 + // if this is our current setting, select it
  440 + //
  441 + if (*(npTable + wCount) == dwCurrentSetting)
  442 + SendMessage( hCtrlWnd, CB_SETCURSEL, (WPARAM) wPosition, 0L ) ;
  443 + }
  444 + return ;
  445 +}
  446 +
  447 +/*-----------------------------------------------------------------------------
  448 +
  449 +FUNCTION: SetComboBox(HWND, WORD, DWORD)
  450 +
  451 +PURPOSE: Selects an entry from a dialog combobox
  452 +
  453 +PARAMETERS:
  454 + hCtrlWnd - windows handle of control
  455 + wTableLen - length of value table for this control
  456 + dwNewSetting - new item to base selection on
  457 +
  458 +HISTORY: Date: Author: Comment:
  459 + 11/20/95 AllenD Wrote it
  460 +
  461 +-----------------------------------------------------------------------------*/
  462 +void SetComboBox( HWND hCtrlWnd, WORD wTableLen, DWORD dwNewSetting )
  463 +{
  464 + WORD wCount, wItemData ;
  465 +
  466 + for (wCount = 0; wCount < wTableLen; wCount++) {
  467 + wItemData = LOWORD( SendMessage( hCtrlWnd, CB_GETITEMDATA, (WPARAM) wCount, 0L ) );
  468 +
  469 + if (wItemData == dwNewSetting) {
  470 + SendMessage( hCtrlWnd, CB_SETCURSEL, (WPARAM) wCount, 0L ) ;
  471 + break;
  472 + }
  473 + }
  474 + return ;
  475 +}
  476 +
  477 +//???ù′??ú
  478 +//2?êy£obEnablePort£?????′??úóDD§£?bEnablePort[0]±íê?COM1£?bEnablePort[n-1]±íê?COMn
  479 +//·μ???μ£oóDD§μ?′??ú??êy
  480 +int EnumAllComPort(int* bEnablePort)
  481 +{
  482 + int nCommSum = 0;//′??ú??êy
  483 +
  484 + HANDLE hCom;
  485 + int i;
  486 +// CString str;
  487 + char str[ MAXLEN_TEMPSTR ], szTemp[ MAXLEN_TEMPSTR ] ;
  488 +
  489 + strcpy(szTemp, "COM");
  490 +
  491 + for(i=1;i<=MAXPORTS;i++)
  492 + {
  493 + //str.Format(_T("COM%d"),i);
  494 + if (i > 9)
  495 + {
  496 + wsprintf(str, "\\\\.\\%s%d", (LPSTR)szTemp, i);
  497 + }
  498 + else
  499 + {
  500 + wsprintf(str, "%s%d", (LPSTR)szTemp, i);
  501 + }
  502 +
  503 + hCom = CreateFile(str, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
  504 +
  505 + if (hCom == INVALID_HANDLE_VALUE)
  506 + {
  507 + bEnablePort[i-1] = 0;
  508 + continue;
  509 + }
  510 + else
  511 + {
  512 + bEnablePort[i-1] = 1;
  513 + }
  514 + CloseHandle(hCom);
  515 + nCommSum++;
  516 + }
  517 +
  518 + return nCommSum;
  519 +}
  520 +
  521 +
  522 +/*-----------------------------------------------------------------------------
  523 +
  524 +FUNCTION: SettingsDlgInit(HWND)
  525 +
  526 +PURPOSE: Initializes Settings Dialog
  527 +
  528 +PARAMETERS:
  529 + hDlg - Dialog window handle
  530 +
  531 +RETURN: always TRUE
  532 +
  533 +COMMENTS: This function originally found in the Win32 COMM sample
  534 + Written by BryanW. Modified for Win32 MTTTY Sample.
  535 +
  536 +HISTORY: Date: Author: Comment:
  537 + 10/27/95 AllenD Modified for MTTTY
  538 +
  539 +-----------------------------------------------------------------------------*/
  540 +BOOL SettingsDlgInit( HWND hDlg )
  541 +{
  542 + char szBuffer[ MAXLEN_TEMPSTR ], szTemp[ MAXLEN_TEMPSTR ] ;
  543 + WORD wCount, wMaxCOM, wPosition ;
  544 + int cmdT[MAXPORTS];
  545 +
  546 + wMaxCOM = MAXPORTS ;
  547 + strcpy(szTemp, "COM");
  548 +
  549 + memset(cmdT,0,sizeof(cmdT));
  550 + EnumAllComPort(cmdT);
  551 +
  552 + //for (int i=0;i<10;i++)
  553 + {
  554 + //UpdateStatus("com%d:%d\r\n",i+1,cmdT[i]);
  555 + }
  556 +
  557 +
  558 + //
  559 + // fill port combo box and make initial selection
  560 + //
  561 + for (wCount = 0; wCount < wMaxCOM; wCount++) {
  562 + //wsprintf( szBuffer, "%s%d", (LPSTR) szTemp, wCount + 1 ) ;
  563 + if (cmdT[wCount])
  564 + {
  565 + wsprintf(szBuffer, "%s%d", (LPSTR)szTemp, wCount + 1);
  566 + SendDlgItemMessage( hDlg, IDC_PORTCOMBO, CB_ADDSTRING, 0,
  567 + (LPARAM) (LPSTR) szBuffer ) ;
  568 + }
  569 + }
  570 +
  571 + SendDlgItemMessage( hDlg, IDC_PORTCOMBO, CB_SETCURSEL,
  572 + (WPARAM) (PORT( TTYInfo ) - 1), 0L ) ;
  573 +
  574 + GetDlgItemText(hDlg, IDC_PORTCOMBO, gszPort, sizeof(gszPort));
  575 +
  576 + //
  577 + // fill baud combo box and make initial selection
  578 + //
  579 + FillComboBox( GetDlgItem( hDlg, IDC_BAUDCOMBO ),
  580 + szBaud, BaudTable,
  581 + sizeof( BaudTable ) / sizeof( BaudTable[ 0 ] ),
  582 + BAUDRATE( TTYInfo ) ) ;
  583 +
  584 + //
  585 + // fill data bits combo box and make initial selection
  586 + //
  587 + for (wCount = 5; wCount < 9; wCount++) {
  588 + wsprintf( szBuffer, "%d", wCount ) ;
  589 + wPosition = LOWORD( SendDlgItemMessage( hDlg, IDC_DATABITSCOMBO,
  590 + CB_ADDSTRING, 0,
  591 + (LPARAM) (LPSTR) szBuffer ) ) ;
  592 +
  593 + //
  594 + // if wCount is current selection, tell the combo box
  595 + //
  596 + if (wCount == BYTESIZE( TTYInfo ))
  597 + SendDlgItemMessage( hDlg, IDC_DATABITSCOMBO, CB_SETCURSEL,
  598 + (WPARAM) wPosition, 0L ) ;
  599 + }
  600 +
  601 + //
  602 + // fill parity combo box and make initial selection
  603 + //
  604 + FillComboBox( GetDlgItem( hDlg, IDC_PARITYCOMBO ),
  605 + szParity, ParityTable,
  606 + sizeof( ParityTable ) / sizeof( ParityTable[ 0 ] ),
  607 + PARITY( TTYInfo ) ) ;
  608 +
  609 + //
  610 + // fill stop bits combo box and make initial selection
  611 + //
  612 + FillComboBox( GetDlgItem( hDlg, IDC_STOPBITSCOMBO ),
  613 + szStopBits, StopBitsTable,
  614 + sizeof( StopBitsTable ) / sizeof ( StopBitsTable[ 0 ] ),
  615 + STOPBITS( TTYInfo ) ) ;
  616 + //
  617 + // set check marks based on TTY data
  618 + //
  619 + CheckDlgButton( hDlg, IDC_LOCALECHOCHK, LOCALECHO( TTYInfo ) ) ;
  620 + CheckDlgButton( hDlg, IDC_DISPLAYERRORSCHK, DISPLAYERRORS( TTYInfo ) );
  621 + CheckDlgButton( hDlg, IDC_LFBTN, NEWLINE( TTYInfo ) );
  622 + CheckDlgButton( hDlg, IDC_AUTOWRAPCHK, AUTOWRAP( TTYInfo ) );
  623 +
  624 + CheckDlgButton( hDlg, IDC_NOWRITINGCHK, NOWRITING( TTYInfo ) );
  625 + CheckDlgButton( hDlg, IDC_NOREADINGCHK, NOREADING( TTYInfo ) );
  626 + CheckDlgButton( hDlg, IDC_NOSTATUSCHK, NOSTATUS( TTYInfo ) );
  627 + CheckDlgButton( hDlg, IDC_NOEVENTSCHK, NOEVENTS( TTYInfo ) );
  628 +
  629 + return ( TRUE ) ;
  630 +
  631 +} // end of SettingsDlgInit()
  632 +
  633 +
  634 +/*-----------------------------------------------------------------------------
  635 +
  636 +FUNCTION: GetdwTTYItem(HWND, int, char **, DWORD *, int)
  637 +
  638 +PURPOSE: Returns a DWORD item from a dialog control
  639 +
  640 +PARAMETERS:
  641 + hDlg - Dialog window handle
  642 + idControl - id of control to get data from
  643 + szString - table of strings that the control displays
  644 + pTable - table of data associated with strings
  645 + iNumItems - size of table
  646 +
  647 +RETURN:
  648 + DWORD item corresponding to control selection
  649 + 0 if item not found correctly
  650 +
  651 +HISTORY: Date: Author: Comment:
  652 + 10/27/95 AllenD Wrote it
  653 +
  654 +-----------------------------------------------------------------------------*/
  655 +DWORD GetdwTTYItem(HWND hDlg, int idControl, char ** szString, DWORD * pTable, int iNumItems)
  656 +{
  657 + int i;
  658 + char szItem[MAXLEN_TEMPSTR];
  659 +
  660 + //
  661 + // Get current selection (a string)
  662 + //
  663 + GetDlgItemText(hDlg, idControl, szItem, sizeof(szItem));
  664 +
  665 + /*
  666 + Compare current selection with table to find index of item.
  667 + If index is found, then return the DWORD item from table.
  668 + */
  669 + for (i = 0; i < iNumItems; i++) {
  670 + if (strcmp(szString[i], szItem) == 0)
  671 + return pTable[i];
  672 + }
  673 +
  674 + return 0;
  675 +}
  676 +
  677 +/*-----------------------------------------------------------------------------
  678 +
  679 +FUNCTION: GetbTTYItem(HWND, int, char **, DWORD *, int)
  680 +
  681 +PURPOSE: Returns a BYTE item from a dialog control
  682 +
  683 +PARAMETERS:
  684 + hDlg - Dialog window handle
  685 + idControl - id of control to get data from
  686 + szString - table of strings that the control displays
  687 + pTable - table of data associated with strings
  688 + iNumItems - size of table
  689 +
  690 +RETURN:
  691 + BYTE item from corresponding to control selection
  692 + 0 if item data not found
  693 +
  694 +HISTORY: Date: Author: Comment:
  695 + 10/27/95 AllenD Wrote it
  696 +
  697 +-----------------------------------------------------------------------------*/
  698 +BYTE GetbTTYItem(HWND hDlg, int idControl, char ** szString, DWORD * pTable, int iNumItems)
  699 +{
  700 + int i;
  701 + char szItem[MAXLEN_TEMPSTR];
  702 +
  703 + //
  704 + // Get current selection (a string)
  705 + //
  706 + GetDlgItemText(hDlg, idControl, szItem, sizeof(szItem));
  707 +
  708 + /*
  709 + Compare current selection with table to find index of item.
  710 + If index is found, then return the BYTE item from table.
  711 + */
  712 + for (i = 0; i < iNumItems; i++) {
  713 + if (strcmp(szString[i], szItem) == 0)
  714 + return (BYTE) pTable[i];
  715 + }
  716 +
  717 + return 0;
  718 +}
  719 +
  720 +extern char szFileName[MAX_PATH];
  721 +
  722 +int szFileName_check(char* fileName)
  723 +{
  724 + int i,ret = 0;
  725 + for(i=0;i<MAX_PATH;i++)
  726 + {
  727 + if (fileName[i] != 0)
  728 + {
  729 + ret = 1;
  730 + break;
  731 + }
  732 + }
  733 +
  734 + return ret;
  735 +}
  736 +
  737 +/*-----------------------------------------------------------------------------
  738 +
  739 +FUNCTION: ToolbarProc(HWND, UINT, WPARAM, LPARAM)
  740 +
  741 +PURPOSE: Dialog Procedure for Settings Dialog
  742 +
  743 +PARAMETERS:
  744 + hWndDlg - Dialog window handle
  745 + uMsg - Window message
  746 + wParam - message parameter (depends on message)
  747 + lParam - message parameter (depends on message)
  748 +
  749 +RETURN:
  750 + TRUE if message is handled
  751 + FALSE if message is not handled
  752 + Exception is WM_INITDIALOG: returns FALSE since focus is not set
  753 +
  754 +HISTORY: Date: Author: Comment:
  755 + 10/27/95 AllenD Wrote it
  756 +
  757 +-----------------------------------------------------------------------------*/
  758 +BOOL CALLBACK ToolbarProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  759 +{
  760 + BOOL fRet = FALSE;
  761 +
  762 + switch(uMsg)
  763 + {
  764 + case WM_INITDIALOG: // setup dialog with defaults
  765 + SettingsDlgInit(hWndDlg);
  766 + break;
  767 +
  768 + case WM_COMMAND:
  769 + {
  770 + switch(LOWORD(wParam))
  771 + {
  772 + case IDC_FONTBTN: // font button pressed
  773 + {
  774 + CHOOSEFONT cf = {0};
  775 + LOGFONT lf;
  776 +
  777 + lf = LFTTYFONT(TTYInfo);
  778 + cf.lStructSize = sizeof(CHOOSEFONT);
  779 + cf.hwndOwner = hWndDlg;
  780 + cf.lpLogFont = &lf;
  781 + cf.rgbColors = FGCOLOR(TTYInfo);
  782 + cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_FIXEDPITCHONLY | \
  783 + CF_EFFECTS;
  784 +
  785 + if (!ChooseFont(&cf))
  786 + break;
  787 +
  788 + InitNewFont(lf, cf.rgbColors);
  789 +
  790 + //
  791 + // fix scroll bar sizes since we may have more or less pixels per
  792 + // character now
  793 + //
  794 + SizeTTY(ghWndTTY, (WORD)XSIZE(TTYInfo), (WORD)YSIZE(TTYInfo));
  795 +
  796 + //
  797 + // repaint screen contents
  798 + //
  799 + InvalidateRect(ghWndTTY, NULL, TRUE);
  800 +
  801 + //
  802 + // kill old cursor
  803 + //
  804 + KillTTYFocus(ghWndTTY);
  805 +
  806 + //
  807 + // create new cursor
  808 + //
  809 + SetTTYFocus(ghWndTTY);
  810 + }
  811 + fRet = FALSE;
  812 + break;
  813 +
  814 + case IDC_SENDBTN: // send button pressed
  815 + if (!EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_PORTCOMBO), FALSE))
  816 + {
  817 + EnableWindow(GetDlgItem(ghWndToolbarDlg, IDC_PORTCOMBO), TRUE);
  818 + MessageBox(NULL,"Please connect port!\r\n","Warring",MB_OK);
  819 + fRet = FALSE;
  820 + break;
  821 + }
  822 +
  823 + if (szFileName_check(szFileName))
  824 + {
  825 + EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_SENDBTN), FALSE);
  826 + // EnableWindow(GetDlgItem(ghWndToolbarDlg, IDC_PORTCOMBO), FALSE);
  827 + TransferFileTextStart(szFileName);
  828 + }
  829 + else
  830 + {
  831 + /*MessageBox(NULL,"-_-","test3", MB_OK);*/
  832 + ErrorReporter("Please select file!\r\n");
  833 + }
  834 +
  835 + fRet = FALSE;
  836 + break;
  837 +
  838 + case IDC_COMMEVENTSBTN: // comm events button pressed
  839 + DialogBox(ghInst, MAKEINTRESOURCE(IDD_COMMEVENTSDLG), ghwndMain, CommEventsProc);
  840 + fRet = FALSE;
  841 + break;
  842 +
  843 + case IDC_FLOWCONTROLBTN:
  844 + DialogBox(ghInst, MAKEINTRESOURCE(IDD_FLOWCONTROLDLG), ghwndMain, FlowControlProc);
  845 + fRet = FALSE;
  846 + break;
  847 +
  848 + case IDC_TIMEOUTSBTN:
  849 + DialogBox(ghInst, MAKEINTRESOURCE(IDD_TIMEOUTSDLG), ghwndMain, TimeoutsProc);
  850 + break;
  851 + fRet = FALSE;
  852 + break;
  853 +
  854 + default: // some other control has been modified
  855 + if (CONNECTED(TTYInfo))
  856 + UpdateTTYInfo();
  857 + break;
  858 + }
  859 + }
  860 + break;
  861 +
  862 + default:
  863 + break;
  864 + }
  865 +
  866 + return fRet;
  867 +}
  868 +
  869 +/*-----------------------------------------------------------------------------
  870 +
  871 +FUNCTION: InitHexControl(HWND, WORD, WORD, char)
  872 +
  873 +PURPOSE: Places byte value into two edit boxes of the dialog
  874 +
  875 +PARAMETERS:
  876 + hdlg - Dialog Handle
  877 + wIdNumberBox - Edit control ID ; displays hex
  878 + wIdCharBox - Edit control ID ; displays char
  879 + chData - data to display
  880 +
  881 +COMMENTS: Some dialogs may have an edit control designed to accept
  882 + hexidecimal input from the user. This function initializes
  883 + such edit controls. First, the byte (char) is placed into a
  884 + zero terminated string. This is set as the item text of one
  885 + of the controls. Next, the byte is converted to a hexidecimal
  886 + string. This is set as the item text of the other control.
  887 +
  888 +HISTORY: Date: Author: Comment:
  889 + 10/27/95 AllenD Wrote it
  890 +
  891 +-----------------------------------------------------------------------------*/
  892 +void InitHexControl(HWND hdlg, WORD wIdNumberBox, WORD wIdCharBox, char chData)
  893 +{
  894 + char szFlagText[3] = {0};
  895 + char szFlagChar[2] = {0};
  896 +
  897 + //
  898 + // put character into char edit display control
  899 + //
  900 + szFlagChar[0] = chData;
  901 + SetDlgItemText(hdlg, wIdCharBox, szFlagChar);
  902 +
  903 + //
  904 + // put flag character into hex numeric edit control
  905 + //
  906 + wsprintf(szFlagText, "%02x", 0x000000FF & chData);
  907 + SetDlgItemText(hdlg, wIdNumberBox, szFlagText);
  908 +
  909 + return;
  910 +}
  911 +
  912 +/*-----------------------------------------------------------------------------
  913 +
  914 +FUNCTION: GetHexControl(HWND, WORD, WORD)
  915 +
  916 +PURPOSE: Get hex data from control and convert to character
  917 +
  918 +PARAMETERS:
  919 + hdlg - Dialog Handle
  920 + wIdNumberBox - Edit control ID ; contains hex string
  921 + wIdCharBox - Edit control ID ; displays the char
  922 +
  923 +RETURN:
  924 + 0 if can't get hex string from edit control
  925 + byte value of hex string otherwise
  926 +
  927 +COMMENTS: Function does the following:
  928 + 1) Gets first two characters from edit control
  929 + 2) Converts hex string to numeric value
  930 + 3) Displays ascii char of numeric value
  931 + 4) Returns numeric value
  932 +
  933 +HISTORY: Date: Author: Comment:
  934 + 10/27/95 AllenD Wrote it
  935 +
  936 +-----------------------------------------------------------------------------*/
  937 +char GetHexControl(HWND hdlg, WORD wIdNumberBox, WORD wIdCharBox)
  938 +{
  939 + UINT uFlagValue;
  940 + char chFlagEntered[3] = {0};
  941 + char chFlag[2] = {0};
  942 +
  943 + //
  944 + // get numeric value from control
  945 + //
  946 + if (0 == GetDlgItemText(hdlg, wIdNumberBox, chFlagEntered, 3))
  947 + return 0;
  948 +
  949 + sscanf(chFlagEntered, "%x", &uFlagValue);
  950 +
  951 + chFlag[0] = (char) uFlagValue;
  952 + SetDlgItemText(hdlg, wIdCharBox, chFlag); // display character
  953 +
  954 + return chFlag[0];
  955 +}
  956 +
  957 +/*-----------------------------------------------------------------------------
  958 +
  959 +FUNCTION: InitCommEventsDlg(HWND, DWORD)
  960 +
  961 +PURPOSE: Initializes Comm Event Dialog Control
  962 +
  963 +PARAMETERS:
  964 + hdlg - Dialog window handle
  965 + dwEventFlags - event flag to set controls to
  966 +
  967 +COMMENTS: Since controls are checked based on the dwEventFlags parameter,
  968 + it is easy to init control based on current settings,
  969 + or default settings.
  970 +
  971 +HISTORY: Date: Author: Comment:
  972 + 10/27/95 AllenD Wrote it
  973 +
  974 +-----------------------------------------------------------------------------*/
  975 +void InitCommEventsDlg(HWND hdlg, DWORD dwEventFlags)
  976 +{
  977 + int i,j;
  978 +
  979 + for (i = IDC_EVBREAKBTN, j = 0; i <= IDC_EVTXEMPTYBTN; i++, j++)
  980 + CheckDlgButton( hdlg, i, dwEventFlags & EventFlagsTable[j]) ;
  981 +
  982 + InitHexControl(hdlg, IDC_FLAGEDIT, IDC_FLAGCHAR, FLAGCHAR(TTYInfo));
  983 +
  984 + EnableWindow(GetDlgItem(hdlg, IDC_FLAGEDIT), dwEventFlags & EV_RXFLAG);
  985 + EnableWindow(GetDlgItem(hdlg, IDC_FLAGCHAR), dwEventFlags & EV_RXFLAG);
  986 +
  987 + return;
  988 +}
  989 +
  990 +/*-----------------------------------------------------------------------------
  991 +
  992 +FUNCTION: SaveCommEventsDlg(HWND)
  993 +
  994 +PURPOSE: Saves new Comm Events Flag
  995 +
  996 +PARAMETERS:
  997 + hdlg - Dialog window handle
  998 +
  999 +COMMENTS: Builds a new flag based on current dialog control.
  1000 + If the new flag differs from old, then new is updated.
  1001 +
  1002 +HISTORY: Date: Author: Comment:
  1003 + 10/27/95 AllenD Wrote it
  1004 +
  1005 +-----------------------------------------------------------------------------*/
  1006 +void SaveCommEventsDlg(HWND hdlg)
  1007 +{
  1008 + int i,j;
  1009 + DWORD dwNew = {0};
  1010 + char chNewFlag = '\0';
  1011 + BOOL fChangingRXFLAG;
  1012 +
  1013 + //
  1014 + // create a flag out of dialog selections
  1015 + //
  1016 + for (i = IDC_EVBREAKBTN, j = 0; i <= IDC_EVTXEMPTYBTN; i++, j++) {
  1017 + if (IsDlgButtonChecked(hdlg, i))
  1018 + dwNew |= EventFlagsTable[j];
  1019 + }
  1020 +
  1021 + //
  1022 + // get current flag character from dialog
  1023 + //
  1024 + chNewFlag = GetHexControl(hdlg, IDC_FLAGEDIT, IDC_FLAGCHAR);
  1025 + fChangingRXFLAG = (EVENTFLAGS(TTYInfo) & EV_RXFLAG) != (dwNew & EV_RXFLAG);
  1026 + if (chNewFlag != FLAGCHAR(TTYInfo) || fChangingRXFLAG) {
  1027 + FLAGCHAR(TTYInfo) = chNewFlag;
  1028 + UpdateTTYInfo();
  1029 + }
  1030 +
  1031 + //
  1032 + // if new flags have been selected, or
  1033 + //
  1034 + if (dwNew != EVENTFLAGS(TTYInfo))
  1035 + EVENTFLAGS(TTYInfo) = dwNew;
  1036 +
  1037 + return;
  1038 +}
  1039 +
  1040 +/*-----------------------------------------------------------------------------
  1041 +
  1042 +FUNCTION: CommEventsProc(HWND, UINT, WPARAM, LPARAM)
  1043 +
  1044 +PURPOSE: Dialog Procedure for Comm Events Dialog
  1045 +
  1046 +PARAMETERS:
  1047 + hdlg - Dialog window handle
  1048 + uMessage - window message
  1049 + wparam - message parameter (depends on message)
  1050 + lparam - message parameter (depends on message)
  1051 +
  1052 +RETURN:
  1053 + TRUE if message is handled
  1054 + FALSE if message is not handled
  1055 + Exception is WM_INITDIALOG: returns FALSE since focus is not set
  1056 +
  1057 +HISTORY: Date: Author: Comment:
  1058 + 10/27/95 AllenD Wrote it
  1059 +
  1060 +-----------------------------------------------------------------------------*/
  1061 +BOOL CALLBACK CommEventsProc(HWND hdlg, UINT uMessage, WPARAM wparam, LPARAM lparam)
  1062 +{
  1063 + switch(uMessage)
  1064 + {
  1065 + case WM_INITDIALOG: // init controls
  1066 + InitCommEventsDlg(hdlg, EVENTFLAGS(TTYInfo));
  1067 + break;
  1068 +
  1069 + case WM_COMMAND:
  1070 + switch(LOWORD(wparam))
  1071 + {
  1072 + case IDOK:
  1073 + SaveCommEventsDlg(hdlg);
  1074 +
  1075 + //
  1076 + // FALL THROUGH
  1077 + //
  1078 +
  1079 + case IDCANCEL:
  1080 + EndDialog(hdlg, LOWORD(wparam));
  1081 + return TRUE;
  1082 +
  1083 + case IDC_DEFAULTSBTN:
  1084 + InitCommEventsDlg(hdlg, EVENTFLAGS_DEFAULT);
  1085 + return TRUE;
  1086 +
  1087 + case IDC_EVRXFLAGBTN:
  1088 + EnableWindow(GetDlgItem(hdlg, IDC_FLAGEDIT), IsDlgButtonChecked(hdlg, IDC_EVRXFLAGBTN));
  1089 + EnableWindow(GetDlgItem(hdlg, IDC_FLAGCHAR), IsDlgButtonChecked(hdlg, IDC_EVRXFLAGBTN));
  1090 + return TRUE;
  1091 +
  1092 + case IDC_FLAGEDIT:
  1093 + GetHexControl(hdlg, IDC_FLAGEDIT, IDC_FLAGCHAR);
  1094 + return TRUE;
  1095 + }
  1096 + break;
  1097 + }
  1098 +
  1099 + return FALSE;
  1100 +}
  1101 +
  1102 +/*-----------------------------------------------------------------------------
  1103 +
  1104 +FUNCTION: SaveFlowControlDlg(HWND)
  1105 +
  1106 +PURPOSE: Sets TTY flow control settings based on dlg controls
  1107 +
  1108 +PARAMETERS:
  1109 + hdlg - Dialog window handle
  1110 +
  1111 +HISTORY: Date: Author: Comment:
  1112 + 10/27/95 AllenD Wrote it
  1113 +
  1114 +-----------------------------------------------------------------------------*/
  1115 +void SaveFlowControlDlg(HWND hdlg)
  1116 +{
  1117 + BOOL fNewCTSOut, fNewDSROut, fNewDSRIn, fNewXOut, fNewXIn, fNewTXafterXoffSent;
  1118 + DWORD dwNewDTRControl, dwNewRTSControl;
  1119 + WORD wNewXONLimit, wNewXOFFLimit;
  1120 + char chNewXON, chNewXOFF;
  1121 + BOOL fSuccess;
  1122 +
  1123 + BOOL fUpdateDCB = FALSE;
  1124 +
  1125 + //
  1126 + // update DTR and RTS control if needed
  1127 + //
  1128 + dwNewDTRControl = GetdwTTYItem( hdlg, IDC_DTRCONTROLCOMBO,
  1129 + szDTRControlStrings, DTRControlTable,
  1130 + sizeof(DTRControlTable)/sizeof(DTRControlTable[0]));
  1131 +
  1132 + dwNewRTSControl = GetdwTTYItem( hdlg, IDC_RTSCONTROLCOMBO,
  1133 + szRTSControlStrings, RTSControlTable,
  1134 + sizeof(RTSControlTable)/sizeof(RTSControlTable[0]));
  1135 + if (dwNewRTSControl != RTSCONTROL(TTYInfo) ||
  1136 + dwNewDTRControl != DTRCONTROL(TTYInfo)) {
  1137 + RTSCONTROL(TTYInfo) = dwNewRTSControl;
  1138 + DTRCONTROL(TTYInfo) = dwNewDTRControl;
  1139 + fUpdateDCB = TRUE;
  1140 + }
  1141 +
  1142 + //
  1143 + // update XON/XOFF limits if needed
  1144 + //
  1145 + wNewXONLimit = GetDlgItemInt(hdlg, IDC_XONLIMITEDIT, &fSuccess, FALSE);
  1146 + wNewXOFFLimit = GetDlgItemInt(hdlg, IDC_XOFFLIMITEDIT, &fSuccess, FALSE);
  1147 + if (wNewXOFFLimit != XOFFLIMIT(TTYInfo) ||
  1148 + wNewXONLimit != XONLIMIT(TTYInfo)) {
  1149 + XOFFLIMIT(TTYInfo) = wNewXOFFLimit;
  1150 + XONLIMIT(TTYInfo) = wNewXONLimit;
  1151 + fUpdateDCB = TRUE;
  1152 + }
  1153 +
  1154 + //
  1155 + // update XON/XOFF chars if needed
  1156 + //
  1157 + chNewXON = GetHexControl(hdlg, IDC_XONCHAREDIT, IDC_XONCHARDISP);
  1158 + chNewXOFF = GetHexControl(hdlg, IDC_XOFFCHAREDIT, IDC_XOFFCHARDISP);
  1159 + if (chNewXOFF != XOFFCHAR(TTYInfo) ||
  1160 + chNewXON != XONCHAR(TTYInfo)) {
  1161 + XOFFCHAR(TTYInfo) = chNewXOFF;
  1162 + XONCHAR(TTYInfo) = chNewXON;
  1163 + fUpdateDCB = TRUE;
  1164 + }
  1165 +
  1166 + //
  1167 + // update booleans from check boxes
  1168 + //
  1169 + fNewTXafterXoffSent = IsDlgButtonChecked(hdlg, IDC_TXAFTERXOFFSENTCHK);
  1170 + fNewCTSOut = IsDlgButtonChecked(hdlg, IDC_CTSOUTCHK);
  1171 + fNewDSROut = IsDlgButtonChecked(hdlg, IDC_DSROUTCHK);
  1172 + fNewDSRIn = IsDlgButtonChecked(hdlg, IDC_DSRINCHK);
  1173 + fNewXOut = IsDlgButtonChecked(hdlg, IDC_XONXOFFOUTCHK);
  1174 + fNewXIn = IsDlgButtonChecked(hdlg, IDC_XONXOFFINCHK);
  1175 +
  1176 + if (fNewTXafterXoffSent != TXAFTERXOFFSENT(TTYInfo) ||
  1177 + fNewCTSOut != CTSOUTFLOW(TTYInfo) ||
  1178 + fNewDSROut != DSROUTFLOW(TTYInfo) ||
  1179 + fNewDSRIn != DSRINFLOW(TTYInfo) ||
  1180 + fNewXOut != XONXOFFOUTFLOW(TTYInfo) ||
  1181 + fNewXIn != XONXOFFINFLOW(TTYInfo) ) {
  1182 + CTSOUTFLOW(TTYInfo) = fNewCTSOut;
  1183 + DSROUTFLOW(TTYInfo) = fNewDSROut;
  1184 + DSRINFLOW(TTYInfo) = fNewDSRIn;
  1185 + XONXOFFOUTFLOW(TTYInfo) = fNewXOut;
  1186 + XONXOFFINFLOW(TTYInfo) = fNewXIn;
  1187 + TXAFTERXOFFSENT(TTYInfo) = fNewTXafterXoffSent;
  1188 + fUpdateDCB = TRUE;
  1189 + }
  1190 +
  1191 + //
  1192 + // update current settings if they have actually changed
  1193 + //
  1194 + if (fUpdateDCB)
  1195 + UpdateTTYInfo();
  1196 +
  1197 + return;
  1198 +}
  1199 +
  1200 +/*-----------------------------------------------------------------------------
  1201 +
  1202 +FUNCTION: InitFlowControlDlg(HWND)
  1203 +
  1204 +PURPOSE: Sets controls based on current tty flow control settings
  1205 +
  1206 +PARAMETERS:
  1207 + hdlg - Dialog window handle
  1208 +
  1209 +HISTORY: Date: Author: Comment:
  1210 + 10/27/95 AllenD Wrote it
  1211 +
  1212 +-----------------------------------------------------------------------------*/
  1213 +void InitFlowControlDlg(HWND hdlg)
  1214 +{
  1215 + //
  1216 + // fill and init DTR control combo
  1217 + //
  1218 + FillComboBox( GetDlgItem( hdlg, IDC_DTRCONTROLCOMBO ),
  1219 + szDTRControlStrings, DTRControlTable,
  1220 + sizeof( DTRControlTable) / sizeof( DTRControlTable[0] ),
  1221 + DTRCONTROL( TTYInfo ) );
  1222 +
  1223 + //
  1224 + // fill and init RTS control combo
  1225 + //
  1226 + FillComboBox( GetDlgItem( hdlg, IDC_RTSCONTROLCOMBO ),
  1227 + szRTSControlStrings, RTSControlTable,
  1228 + sizeof( RTSControlTable) / sizeof( RTSControlTable[0] ),
  1229 + RTSCONTROL( TTYInfo ) );
  1230 +
  1231 + //
  1232 + // XON/XOFF characters
  1233 + //
  1234 + InitHexControl(hdlg, IDC_XONCHAREDIT, IDC_XONCHARDISP, XONCHAR(TTYInfo));
  1235 + InitHexControl(hdlg, IDC_XOFFCHAREDIT, IDC_XOFFCHARDISP, XOFFCHAR(TTYInfo));
  1236 +
  1237 + //
  1238 + // XON/XOFF limits
  1239 + //
  1240 + SetDlgItemInt(hdlg, IDC_XONLIMITEDIT, XONLIMIT(TTYInfo), FALSE);
  1241 + SetDlgItemInt(hdlg, IDC_XOFFLIMITEDIT, XOFFLIMIT(TTYInfo), FALSE);
  1242 +
  1243 + //
  1244 + // check boxes
  1245 + //
  1246 + CheckDlgButton(hdlg, IDC_CTSOUTCHK, CTSOUTFLOW(TTYInfo));
  1247 + CheckDlgButton(hdlg, IDC_DSROUTCHK, DSROUTFLOW(TTYInfo));
  1248 + CheckDlgButton(hdlg, IDC_DSRINCHK, DSRINFLOW(TTYInfo));
  1249 + CheckDlgButton(hdlg, IDC_XONXOFFOUTCHK, XONXOFFOUTFLOW(TTYInfo));
  1250 + CheckDlgButton(hdlg, IDC_XONXOFFINCHK, XONXOFFINFLOW(TTYInfo));
  1251 + CheckDlgButton(hdlg, IDC_TXAFTERXOFFSENTCHK, TXAFTERXOFFSENT(TTYInfo));
  1252 +
  1253 + return;
  1254 +}
  1255 +
  1256 +/*-----------------------------------------------------------------------------
  1257 +
  1258 +FUNCTION: FlowDefault(HWND, WORD)
  1259 +
  1260 +PURPOSE: Sets controls based on hardware or software flow control
  1261 +
  1262 +PARAMETERS:
  1263 + hdlg - Dialog window handle
  1264 + wId - ID of button used to set the default:
  1265 + IDC_DTRDSRBTN - DTR/DSR hardware flow-control
  1266 + IDC_RTSCTSBTN - RTS/CTS hardware flow-control
  1267 + IDC_XOFFXONBTNBTN - XOFF/XON software flow control
  1268 + IDC_NONEBTN - no flow control
  1269 +
  1270 +HISTORY: Date: Author: Comment:
  1271 + 10/27/95 AllenD Wrote it
  1272 +
  1273 +-----------------------------------------------------------------------------*/
  1274 +void FlowDefault(HWND hdlg, WORD wId)
  1275 +{
  1276 + //
  1277 + // set dtr control to handshake if using DTR/DSR flow-control
  1278 + //
  1279 + SetComboBox( GetDlgItem( hdlg, IDC_DTRCONTROLCOMBO ),
  1280 + sizeof( DTRControlTable) / sizeof( DTRControlTable[0] ),
  1281 + wId == IDC_DTRDSRBTN ? DTR_CONTROL_HANDSHAKE : DTR_CONTROL_ENABLE);
  1282 +
  1283 + //
  1284 + // set rts control to handshake if using RTS/CTS flow-control
  1285 + //
  1286 + SetComboBox( GetDlgItem( hdlg, IDC_RTSCONTROLCOMBO ),
  1287 + sizeof( RTSControlTable) / sizeof( RTSControlTable[0] ),
  1288 + wId == IDC_RTSCTSBTN ? RTS_CONTROL_HANDSHAKE : RTS_CONTROL_ENABLE);
  1289 +
  1290 + //
  1291 + // set check boxes according to wId
  1292 + //
  1293 + switch(wId)
  1294 + {
  1295 + case IDC_RTSCTSBTN:
  1296 + case IDC_DTRDSRBTN:
  1297 + CheckDlgButton(hdlg, IDC_CTSOUTCHK, wId == IDC_RTSCTSBTN);
  1298 + CheckDlgButton(hdlg, IDC_DSROUTCHK, wId == IDC_DTRDSRBTN);
  1299 + CheckDlgButton(hdlg, IDC_XONXOFFOUTCHK, FALSE);
  1300 + CheckDlgButton(hdlg, IDC_XONXOFFINCHK, FALSE);
  1301 + break;
  1302 +
  1303 + case IDC_XOFFXONBTN:
  1304 + case IDC_NONEBTN:
  1305 + CheckDlgButton(hdlg, IDC_CTSOUTCHK, FALSE);
  1306 + CheckDlgButton(hdlg, IDC_DSROUTCHK, FALSE);
  1307 + CheckDlgButton(hdlg, IDC_XONXOFFOUTCHK, wId == IDC_XOFFXONBTN);
  1308 + CheckDlgButton(hdlg, IDC_XONXOFFINCHK, wId == IDC_XOFFXONBTN);
  1309 + break;
  1310 + }
  1311 +
  1312 + //
  1313 + // settings that are disabled when any 'default' flow-control is used
  1314 + //
  1315 + CheckDlgButton(hdlg, IDC_DSRINCHK, FALSE);
  1316 + CheckDlgButton(hdlg, IDC_TXAFTERXOFFSENTCHK, FALSE);
  1317 +
  1318 +
  1319 + return;
  1320 +}
  1321 +
  1322 +/*-----------------------------------------------------------------------------
  1323 +
  1324 +FUNCTION: FlowControlProc(HWND, UINT, WPARAM, LPARAM)
  1325 +
  1326 +PURPOSE: Dialog Procedure for Flow Control Settings Dialog
  1327 +
  1328 +PARAMETERS:
  1329 + hdlg - Dialog window handle
  1330 + uMessage - window message
  1331 + wparam - message parameter (depends on message)
  1332 + lparam - message parameter (depends on message)
  1333 +
  1334 +RETURN:
  1335 + TRUE if message is handled
  1336 + FALSE if message is not handled
  1337 + Exception is WM_INITDIALOG: returns FALSE since focus is not set
  1338 +
  1339 +HISTORY: Date: Author: Comment:
  1340 + 10/27/95 AllenD Wrote it
  1341 +
  1342 +-----------------------------------------------------------------------------*/
  1343 +BOOL CALLBACK FlowControlProc(HWND hdlg, UINT uMessage, WPARAM wparam, LPARAM lparam)
  1344 +{
  1345 + switch(uMessage)
  1346 + {
  1347 + case WM_INITDIALOG: // init controls
  1348 + InitFlowControlDlg(hdlg);
  1349 + break;
  1350 +
  1351 + case WM_COMMAND:
  1352 + switch(LOWORD(wparam))
  1353 + {
  1354 + case IDOK:
  1355 + SaveFlowControlDlg(hdlg);
  1356 + //
  1357 + // FALL THROUGH
  1358 + //
  1359 +
  1360 + case IDCANCEL:
  1361 + EndDialog(hdlg, LOWORD(wparam));
  1362 + return TRUE;
  1363 +
  1364 + case IDC_RTSCTSBTN:
  1365 + case IDC_DTRDSRBTN:
  1366 + case IDC_XOFFXONBTN:
  1367 + case IDC_NONEBTN:
  1368 + FlowDefault(hdlg, LOWORD(wparam));
  1369 + return TRUE;
  1370 +
  1371 + case IDC_XONCHAREDIT:
  1372 + GetHexControl(hdlg, IDC_XONCHAREDIT, IDC_XONCHARDISP);
  1373 + return TRUE;
  1374 +
  1375 + case IDC_XOFFCHAREDIT:
  1376 + GetHexControl(hdlg, IDC_XOFFCHAREDIT, IDC_XOFFCHARDISP);
  1377 + return TRUE;
  1378 + }
  1379 + break;
  1380 + }
  1381 +
  1382 + return FALSE;
  1383 +}
  1384 +
  1385 +/*-----------------------------------------------------------------------------
  1386 +
  1387 +FUNCTION: InitTimeoutsDlg(HWND, COMMTIMEOUTS)
  1388 +
  1389 +PURPOSE: Initializes timeouts dialog controls based on parameter
  1390 +
  1391 +PARAMETERS:
  1392 + hdlg - Dialog window handle
  1393 + ct - COMMTIMEOUTS used to set the dialog controls
  1394 +
  1395 +HISTORY: Date: Author: Comment:
  1396 + 10/27/95 AllenD Wrote it
  1397 +
  1398 +-----------------------------------------------------------------------------*/
  1399 +void InitTimeoutsDlg(HWND hdlg, COMMTIMEOUTS ct)
  1400 +{
  1401 + SetDlgItemInt(hdlg, IDC_READINTERVALEDIT, ct.ReadIntervalTimeout, FALSE);
  1402 + SetDlgItemInt(hdlg, IDC_READMULTIPLIEREDIT, ct.ReadTotalTimeoutMultiplier, FALSE);
  1403 + SetDlgItemInt(hdlg, IDC_READCONSTANTEDIT, ct.ReadTotalTimeoutConstant, FALSE);
  1404 + SetDlgItemInt(hdlg, IDC_WRITEMULTIPLIEREDIT, ct.WriteTotalTimeoutMultiplier, FALSE);
  1405 + SetDlgItemInt(hdlg, IDC_WRITECONSTANTEDIT, ct.WriteTotalTimeoutConstant, FALSE);
  1406 + CheckDlgButton(hdlg, IDC_DISPLAYTIMEOUTS, SHOWTIMEOUTS(TTYInfo));
  1407 + return;
  1408 +}
  1409 +
  1410 +/*-----------------------------------------------------------------------------
  1411 +
  1412 +FUNCTION: SaveTimeoutsDlg(HWND)
  1413 +
  1414 +PURPOSE: Saves values from controls into tty timeout settings
  1415 +
  1416 +PARAMETERS:
  1417 + hdlg - Dialog window handle
  1418 +
  1419 +HISTORY: Date: Author: Comment:
  1420 + 10/27/95 AllenD Wrote it
  1421 +
  1422 +-----------------------------------------------------------------------------*/
  1423 +void SaveTimeoutsDlg(HWND hdlg)
  1424 +{
  1425 + COMMTIMEOUTS ctNew;
  1426 +
  1427 + //
  1428 + // get new timeouts from dialog controls
  1429 + //
  1430 + ctNew.ReadIntervalTimeout = GetDlgItemInt(hdlg, IDC_READINTERVALEDIT, NULL, FALSE);
  1431 + ctNew.ReadTotalTimeoutMultiplier = GetDlgItemInt(hdlg, IDC_READMULTIPLIEREDIT, NULL, FALSE);
  1432 + ctNew.ReadTotalTimeoutConstant = GetDlgItemInt(hdlg, IDC_READCONSTANTEDIT, NULL, FALSE);
  1433 + ctNew.WriteTotalTimeoutMultiplier = GetDlgItemInt(hdlg, IDC_WRITEMULTIPLIEREDIT, NULL, FALSE);
  1434 + ctNew.WriteTotalTimeoutConstant = GetDlgItemInt(hdlg, IDC_WRITECONSTANTEDIT, NULL, FALSE);
  1435 +
  1436 + SHOWTIMEOUTS(TTYInfo) = IsDlgButtonChecked(hdlg, IDC_DISPLAYTIMEOUTS);
  1437 +
  1438 + //
  1439 + // set new timeouts if they are different
  1440 + //
  1441 + if (memcmp(&ctNew, &(TIMEOUTSNEW(TTYInfo)), sizeof(COMMTIMEOUTS))) {
  1442 + //
  1443 + // if connected, set new time outs and purge pending operations
  1444 + //
  1445 + if (CONNECTED(TTYInfo)) {
  1446 + if (!SetCommTimeouts(COMDEV(TTYInfo), &ctNew)) {
  1447 + ErrorReporter("SetCommTimeouts");
  1448 + return;
  1449 + }
  1450 +
  1451 + if (!PurgeComm(COMDEV(TTYInfo), PURGE_TXABORT | PURGE_RXABORT))
  1452 + ErrorReporter("PurgeComm");
  1453 + }
  1454 +
  1455 + //
  1456 + // save timeouts in the tty info structure
  1457 + //
  1458 + TIMEOUTSNEW(TTYInfo) = ctNew;
  1459 + }
  1460 +
  1461 + return;
  1462 +}
  1463 +
  1464 +/*-----------------------------------------------------------------------------
  1465 +
  1466 +FUNCTION: TimeoutsProc(HWND, UINT, WPARAM, LPARAM)
  1467 +
  1468 +PURPOSE: Dialog Procedure for comm timeouts
  1469 +
  1470 +PARAMETERS:
  1471 + hdlg - Dialog window handle
  1472 + uMessage - window message
  1473 + wparam - message parameter (depends on message)
  1474 + lparam - message parameter (depends on message)
  1475 +
  1476 +RETURN:
  1477 + TRUE if message is handled
  1478 + FALSE if message is not handled
  1479 + Exception is WM_INITDIALOG: returns FALSE since focus is not set
  1480 +
  1481 +HISTORY: Date: Author: Comment:
  1482 + 10/27/95 AllenD Wrote it
  1483 +
  1484 +-----------------------------------------------------------------------------*/
  1485 +BOOL CALLBACK TimeoutsProc(HWND hdlg, UINT uMessage, WPARAM wparam, LPARAM lparam)
  1486 +{
  1487 + switch(uMessage)
  1488 + {
  1489 + case WM_INITDIALOG: // init controls
  1490 + InitTimeoutsDlg(hdlg, TIMEOUTSNEW(TTYInfo));
  1491 + break;
  1492 +
  1493 + case WM_COMMAND:
  1494 + switch(LOWORD(wparam))
  1495 + {
  1496 + case IDOK:
  1497 + SaveTimeoutsDlg(hdlg);
  1498 +
  1499 + //
  1500 + // FALL THROUGH
  1501 + //
  1502 +
  1503 + case IDCANCEL:
  1504 + EndDialog(hdlg, LOWORD(wparam));
  1505 + return TRUE;
  1506 +
  1507 + case IDC_DEFAULTSBTN:
  1508 + InitTimeoutsDlg(hdlg, gTimeoutsDefault);
  1509 + return TRUE;
  1510 + }
  1511 + break;
  1512 + }
  1513 +
  1514 + return FALSE;
  1515 +}
  1516 +
  1517 +BOOL CALLBACK GetADWORDProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
  1518 +{
  1519 + int iRet = 0;
  1520 +
  1521 + if (uMessage == WM_COMMAND) {
  1522 + switch(LOWORD(wParam)) {
  1523 + case IDOK:
  1524 + iRet = GetDlgItemInt(hDlg, IDC_DWORDEDIT, NULL, FALSE);
  1525 + //
  1526 + // FALL THROUGH
  1527 + //
  1528 +
  1529 + case IDCANCEL:
  1530 + EndDialog(hDlg, iRet);
  1531 + return TRUE;
  1532 + }
  1533 + }
  1534 +
  1535 + return FALSE;
  1536 +}
  1537 +
  1538 +DWORD GetAFrequency()
  1539 +{
  1540 + return ((DWORD) DialogBox(ghInst, MAKEINTRESOURCE(IDD_GETADWORD), ghwndMain, GetADWORDProc));
  1541 +}
... ...
  1 +/*-----------------------------------------------------------------------------
  2 + This is a part of the Microsoft Source Code Samples.
  3 + Copyright (C) 1995 Microsoft Corporation.
  4 + All rights reserved.
  5 + This source code is only intended as a supplement to
  6 + Microsoft Development Tools and/or WinHelp documentation.
  7 + See these sources for detailed information regarding the
  8 + Microsoft samples programs.
  9 +
  10 + MODULE: Status.c
  11 +
  12 + PURPOSE: Controls the status dialog at bottom of screen
  13 +
  14 + Functions:
  15 + OpenStatusToolBar - Creates the status dialog
  16 + CreateStatusEditFont - Creates the status edit control font
  17 + StatusDlgProc - Status dialog procedure
  18 + InitStatusMessage - Initializes the status message mechanism
  19 + StatusMessage - Updates status edit control
  20 + UpdateStatus - Creates a status message node (entry point
  21 + for other threads
  22 + ReportModemStatus - Updates modem status controls
  23 + CheckModemStatus - Calls GetCommModemStatus and ReportModemStatus
  24 + ReportComStat - Updates comm status controls based on
  25 + COMSTAT structure (from ClearCommError)
  26 + ReportCommError - Reports comm errors when they occur
  27 + ReportStatusEvent - Reports comm events when they occur
  28 +
  29 +-----------------------------------------------------------------------------*/
  30 +
  31 +#include <windows.h>
  32 +#include <string.h>
  33 +#include <stdio.h>
  34 +#include "MTTTY.h"
  35 +
  36 +#define MAX_STATUS_LENGTH 100
  37 +
  38 +//
  39 +// Prototypes for functions called only within this file
  40 +//
  41 +void ReportStatusEvent( DWORD );
  42 +void ReportCommError( void );
  43 +void ReportModemStatus( DWORD );
  44 +BOOL CALLBACK StatusDlgProc( HWND, UINT, WPARAM, LPARAM );
  45 +void InitStatusMessage( void );
  46 +
  47 +
  48 +/*-----------------------------------------------------------------------------
  49 +
  50 +FUNCTION: OpenStatusToolbar(HWND)
  51 +
  52 +PURPOSE: Opens the modeless status dialog
  53 +
  54 +PARAMETERS:
  55 + hWnd - Handle of window which owns the dialog
  56 +
  57 +HISTORY: Date: Author: Comment:
  58 + 10/27/95 AllenD Wrote it
  59 +
  60 +/*-----------------------------------------------------------------------------*/
  61 +void OpenStatusToolbar(HWND hWnd)
  62 +{
  63 + ghWndStatusDlg = CreateDialog(ghInst, MAKEINTRESOURCE(IDD_STATUSDIALOG), hWnd, StatusDlgProc);
  64 +
  65 + if (ghWndStatusDlg == NULL)
  66 + ErrorReporter("CreateDialog (Status Dialog)");
  67 +
  68 + return;
  69 +}
  70 +
  71 +/*-----------------------------------------------------------------------------
  72 +
  73 +FUNCTION: CreateStatusEditFont
  74 +
  75 +PURPOSE: Creates the font for the status edit control
  76 +
  77 +RETURN: HFONT of new font created
  78 +
  79 +HISTORY: Date: Author: Comment:
  80 + 10/27/95 AllenD Wrote it
  81 +
  82 +-----------------------------------------------------------------------------*/
  83 +HFONT CreateStatusEditFont()
  84 +{
  85 + LOGFONT lf = {0};
  86 + HFONT hFont;
  87 +
  88 + lf.lfHeight = 14 ;
  89 + lf.lfCharSet = ANSI_CHARSET ;
  90 + lf.lfOutPrecision = OUT_DEFAULT_PRECIS ;
  91 + lf.lfClipPrecision = CLIP_DEFAULT_PRECIS ;
  92 + lf.lfQuality = DEFAULT_QUALITY ;
  93 + lf.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS ;
  94 +
  95 + hFont = CreateFontIndirect(&lf);
  96 + return hFont;
  97 +}
  98 +
  99 +/*-----------------------------------------------------------------------------
  100 +
  101 +FUNCTION: StatusDlgProc(HWND, UINT, WPARAM, LPARAM)
  102 +
  103 +PURPOSE: Provides the dialog procedure for the status dialog
  104 +
  105 +PARAMETERS:
  106 + hWndDlg - Dialog window handle
  107 + uMsg - Window message
  108 + wParam - message parameter (depends on message)
  109 + lParam - message parameter (depends on message)
  110 +
  111 +RETURN:
  112 + TRUE if message is handled
  113 + FALSE if message is not handled
  114 + Exception is WM_INITDIALOG: returns FALSE since focus is not set
  115 +
  116 +HISTORY: Date: Author: Comment:
  117 + 10/27/95 AllenD Wrote it
  118 +
  119 +-----------------------------------------------------------------------------*/
  120 +BOOL CALLBACK StatusDlgProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  121 +{
  122 + BOOL fRet = FALSE;
  123 +
  124 + switch(uMsg)
  125 + {
  126 + case WM_INITDIALOG: // setup dialog with defaults
  127 + SendMessage(GetDlgItem(hWndDlg, IDC_STATUSEDIT), WM_SETFONT, (WPARAM)ghFontStatus, 0);
  128 + InitStatusMessage();
  129 + break;
  130 +
  131 + case WM_COMMAND:
  132 + {
  133 + switch(LOWORD(wParam))
  134 + {
  135 + case IDC_ABORTBTN:
  136 + SendMessage(ghwndMain, WM_COMMAND, ID_TRANSFER_ABORTSENDING, MAKELPARAM(IDC_ABORTBTN,0) );
  137 + fRet = TRUE;
  138 + break;
  139 +
  140 + case IDC_STATCTS:
  141 + case IDC_STATDSR:
  142 + case IDC_STATRING:
  143 + case IDC_STATRLSD:
  144 + CheckModemStatus(TRUE);
  145 + fRet = TRUE;
  146 + break;
  147 +
  148 + case IDC_CTSHOLDCHK:
  149 + case IDC_DSRHOLDCHK:
  150 + case IDC_RLSDHOLDCHK:
  151 + case IDC_XOFFHOLDCHK:
  152 + case IDC_XOFFSENTCHK:
  153 + case IDC_EOFSENTCHK:
  154 + case IDC_TXIMCHK:
  155 + CheckComStat(TRUE);
  156 + fRet = TRUE;
  157 + break;
  158 +
  159 + default:
  160 + break;
  161 + }
  162 + }
  163 + break;
  164 +
  165 + default:
  166 + break;
  167 + }
  168 +
  169 + return fRet;
  170 +}
  171 +
  172 +/*-----------------------------------------------------------------------------
  173 +
  174 +FUNCTION: InitStatusMessage
  175 +
  176 +PURPOSE: Initializes status message heap and linked list
  177 +
  178 +HISTORY: Date: Author: Comment:
  179 + 11/21/95 AllenD Wrote it
  180 +
  181 +-----------------------------------------------------------------------------*/
  182 +void InitStatusMessage()
  183 +{
  184 + SYSTEM_INFO SysInfo;
  185 +
  186 + GetSystemInfo(&SysInfo);
  187 + ghStatusMessageHeap = HeapCreate(0, SysInfo.dwPageSize, 0);
  188 + if (ghStatusMessageHeap == NULL)
  189 + ErrorReporter("HeapCreate (Status message)");
  190 +
  191 + glpStatusMessageHead = HeapAlloc(ghStatusMessageHeap, HEAP_ZERO_MEMORY, sizeof(STATUS_MESSAGE));
  192 + glpStatusMessageTail = glpStatusMessageHead;
  193 +
  194 + gnStatusIndex = 0;
  195 +
  196 + /*
  197 + Queue the initial status message.
  198 + This won't show up until the ReaderAndStatusProc function
  199 + is called when the threads are created after the port is connected.
  200 + */
  201 + UpdateStatus("Status message go here:\r\n");
  202 +
  203 + return;
  204 +}
  205 +
  206 +/*-----------------------------------------------------------------------------
  207 +
  208 +FUNCTION: StatusMessage
  209 +
  210 +PURPOSE: Retrieves status message from status message linked list
  211 + and updates status edit control.
  212 +
  213 +COMMENTS: Called from ReaderAndStatusProc when the status event
  214 + has been set. Clears edit control when number of characters
  215 + exceeds MAX_STATUS_BUFFER.
  216 +
  217 +HISTORY: Date: Author: Comment:
  218 + 11/21/95 AllenD Wrote it
  219 +
  220 +-----------------------------------------------------------------------------*/
  221 +void StatusMessage()
  222 +{
  223 + STATUS_MESSAGE * lpStatusMessage;
  224 + DWORD dwRes;
  225 + HWND hEdit;
  226 + BOOL bRes;
  227 +
  228 + hEdit = GetDlgItem (ghWndStatusDlg, IDC_STATUSEDIT);
  229 +
  230 + /*
  231 + If status control has a lot of characters in it,
  232 + then wipe them out and start over
  233 + */
  234 + if (gnStatusIndex > MAX_STATUS_BUFFER) {
  235 + SendMessageTimeout( hEdit, EM_SETSEL,
  236 + (WPARAM) (INT) 0, (LPARAM) (INT) -1,
  237 + SMTO_NORMAL | SMTO_ABORTIFHUNG,
  238 + 500, &dwRes);
  239 + SendMessageTimeout( hEdit, EM_REPLACESEL,
  240 + 0, (LPARAM) "",
  241 + SMTO_NORMAL | SMTO_ABORTIFHUNG,
  242 + 500, &dwRes);
  243 + gnStatusIndex = 0;
  244 + }
  245 +
  246 + //
  247 + // Loop through each node in the status message linked list.
  248 + //
  249 + for ( lpStatusMessage = glpStatusMessageHead->lpNext ; lpStatusMessage ; )
  250 + {
  251 + //
  252 + // if global quit event is set, then just exit this loop
  253 + //
  254 + if (WaitForSingleObject(ghThreadExitEvent, 0) == WAIT_OBJECT_0)
  255 + break;
  256 +
  257 + //
  258 + // Place each status message into the status control.
  259 + //
  260 + SendMessageTimeout( hEdit, EM_SETSEL,
  261 + gnStatusIndex, gnStatusIndex,
  262 + SMTO_NORMAL | SMTO_ABORTIFHUNG,
  263 + 500, &dwRes);
  264 + SendMessageTimeout( hEdit, EM_REPLACESEL,
  265 + 0, (LPARAM) ((LPSTR) &(lpStatusMessage->chMessageStart)),
  266 + SMTO_NORMAL | SMTO_ABORTIFHUNG,
  267 + 500, &dwRes);
  268 + gnStatusIndex += strlen(&(lpStatusMessage->chMessageStart));
  269 +
  270 + //
  271 + // Update status message linked list
  272 + //
  273 + EnterCriticalSection(&gStatusCritical);
  274 +
  275 + bRes = HeapFree(ghStatusMessageHeap, 0, glpStatusMessageHead);
  276 +
  277 + glpStatusMessageHead = lpStatusMessage;
  278 + lpStatusMessage = lpStatusMessage->lpNext;
  279 +
  280 + LeaveCriticalSection(&gStatusCritical);
  281 +
  282 + if (!bRes)
  283 + ErrorReporter("HeapFree (status message)");
  284 + }
  285 +
  286 + return;
  287 +}
  288 +
  289 +/*-----------------------------------------------------------------------------
  290 +
  291 +FUNCTION: UpdateStatus(char *)
  292 +
  293 +PURPOSE: Places the passed in string into the status message linked
  294 + list and sets the event to make the message display.
  295 +
  296 +PARAMETERS:
  297 + szText - message to be placed in the status control
  298 +
  299 +COMMENTS: Synchronization needed in order to ensure that only
  300 + one thread at a time places a string in the list
  301 +
  302 +HISTORY: Date: Author: Comment:
  303 + 10/27/95 AllenD Wrote it
  304 + 11/21/95 AllenD Modified to use a status message heap
  305 +
  306 +-----------------------------------------------------------------------------*/
  307 +void UpdateStatus(char * szText)
  308 +{
  309 + char * szNewMsg;
  310 + DWORD dwSize;
  311 + STATUS_MESSAGE * lpStatusMessage;
  312 + static dwMessageCounter = 0;
  313 +
  314 + dwMessageCounter++;
  315 +
  316 + dwSize = strlen(szText) + 30; // include NULL terminator and space for counter
  317 +
  318 + EnterCriticalSection(&gStatusCritical);
  319 +
  320 + szNewMsg = HeapAlloc(ghStatusMessageHeap, 0, dwSize+30);
  321 + if (szNewMsg == NULL) {
  322 + LeaveCriticalSection(&gStatusCritical);
  323 + ErrorReporter("HeapAlloc (status message)");
  324 + return;
  325 + }
  326 + else {
  327 + wsprintf(szNewMsg, "%d:%s", dwMessageCounter, szText);
  328 + if (strlen(szNewMsg) > dwSize) {
  329 + LeaveCriticalSection(&gStatusCritical);
  330 + ErrorInComm("Heap Corruption in UpdateStatus\n");
  331 + }
  332 + }
  333 +
  334 + lpStatusMessage = HeapAlloc(ghStatusMessageHeap, 0, sizeof(LPSTR) + dwSize );
  335 + if (lpStatusMessage == NULL) {
  336 + LeaveCriticalSection(&gStatusCritical);
  337 + ErrorReporter("HeapAlloc (status message)");
  338 + return ;
  339 + }
  340 +
  341 + lpStatusMessage->lpNext = NULL;
  342 + glpStatusMessageTail->lpNext = lpStatusMessage;
  343 + glpStatusMessageTail = lpStatusMessage;
  344 + CopyMemory(&(lpStatusMessage->chMessageStart), szNewMsg, dwSize);
  345 + LeaveCriticalSection(&gStatusCritical);
  346 +
  347 + SetEvent(ghStatusMessageEvent);
  348 +
  349 + return ;
  350 +}
  351 +
  352 +/*-----------------------------------------------------------------------------
  353 +
  354 +FUNCTION: ReportModemStatus(DWORD)
  355 +
  356 +PURPOSE: Reports modem status line states
  357 +
  358 +PARAMETERS:
  359 + dwModemStatus - current modem status flag
  360 +
  361 +COMMENTS: Checks each button according to the state
  362 +
  363 +HISTORY: Date: Author: Comment:
  364 + 10/27/95 AllenD Wrote it
  365 +
  366 +-----------------------------------------------------------------------------*/
  367 +void ReportModemStatus(DWORD dwModemStatus)
  368 +{
  369 + BOOL fCTS, fDSR, fRING, fRLSD;
  370 + BOOL fStat[4];
  371 + int i;
  372 +
  373 + fCTS = fStat[0] = MS_CTS_ON & dwModemStatus;
  374 + fDSR = fStat[1] = MS_DSR_ON & dwModemStatus;
  375 + fRING = fStat[2] = MS_RING_ON & dwModemStatus;
  376 + fRLSD = fStat[3] = MS_RLSD_ON & dwModemStatus;
  377 +
  378 + for (i = IDC_STATCTS; i <= IDC_STATRLSD; i++)
  379 + CheckDlgButton(ghWndStatusDlg, i, fStat[i-IDC_STATCTS] ? 1 : 0);
  380 +
  381 + return;
  382 +}
  383 +
  384 +/*-----------------------------------------------------------------------------
  385 +
  386 +FUNCTION: CheckModemStatus(BOOL)
  387 +
  388 +PURPOSE: Check new status and possibly report it
  389 +
  390 +PARAMETERS:
  391 + bUpdateNow - if TRUE, update should be done
  392 + if FALSE, update is done only if status is different
  393 +
  394 +COMMENTS: Reports status if bUpdateNow is true or
  395 + new status is different from old status
  396 +
  397 +HISTORY: Date: Author: Comment:
  398 + 10/27/95 AllenD Wrote it
  399 +
  400 +-----------------------------------------------------------------------------*/
  401 +void CheckModemStatus( BOOL bUpdateNow )
  402 +{
  403 + //
  404 + // dwOldStatus needs to be static so that it is maintained
  405 + // between function calls by the same thread.
  406 + // It also needs to be __declspec(thread) so that it is
  407 + // initialized when a new thread is created.
  408 + //
  409 +
  410 + __declspec(thread) static DWORD dwOldStatus = 0;
  411 +
  412 + DWORD dwNewModemStatus;
  413 +
  414 + if (!GetCommModemStatus(COMDEV(TTYInfo), &dwNewModemStatus))
  415 + ErrorReporter("GetCommModemStatus");
  416 +
  417 + //
  418 + // Report status if bUpdateNow is true or status has changed
  419 + //
  420 + if (bUpdateNow || (dwNewModemStatus != dwOldStatus)) {
  421 + ReportModemStatus(dwNewModemStatus);
  422 + dwOldStatus = dwNewModemStatus;
  423 + }
  424 +
  425 + return;
  426 +}
  427 +
  428 +/*-----------------------------------------------------------------------------
  429 +
  430 +FUNCTION: ReportComStat( COMSTAT )
  431 +
  432 +PURPOSE: Update status dialog controls based on the COMSTAT structure
  433 +
  434 +PARAMETERS:
  435 + ComStat - comstat structure used to update comm stat controls.
  436 +
  437 +HISTORY: Date: Author: Comment:
  438 + 12/01/95 AllenD Wrote it
  439 + 12/18/95 AllenD Modified it
  440 +
  441 +-----------------------------------------------------------------------------*/
  442 +void ReportComStat(COMSTAT ComStat)
  443 +{
  444 + CheckDlgButton(ghWndStatusDlg, IDC_CTSHOLDCHK, ComStat.fCtsHold);
  445 + CheckDlgButton(ghWndStatusDlg, IDC_DSRHOLDCHK, ComStat.fDsrHold);
  446 + CheckDlgButton(ghWndStatusDlg, IDC_RLSDHOLDCHK, ComStat.fRlsdHold);
  447 + CheckDlgButton(ghWndStatusDlg, IDC_XOFFHOLDCHK, ComStat.fXoffHold);
  448 + CheckDlgButton(ghWndStatusDlg, IDC_XOFFSENTCHK, ComStat.fXoffSent);
  449 + CheckDlgButton(ghWndStatusDlg, IDC_EOFSENTCHK, ComStat.fEof);
  450 + CheckDlgButton(ghWndStatusDlg, IDC_TXIMCHK, ComStat.fTxim);
  451 +
  452 + SetDlgItemInt(ghWndStatusDlg, IDC_TXCHAREDIT, ComStat.cbOutQue, FALSE);
  453 + SetDlgItemInt(ghWndStatusDlg, IDC_RXCHAREDIT, ComStat.cbInQue, FALSE);
  454 +
  455 + return;
  456 +}
  457 +
  458 +/*-----------------------------------------------------------------------------
  459 +
  460 +FUNCTION: CheckComStat(BOOL)
  461 +
  462 +PURPOSE: Calls ClearCommError and reports the results.
  463 +
  464 +PARAMETERS:
  465 + bUpdateNow - If TRUE, then ReportComStat is called with new results.
  466 + if FALSE, then ReportComStat is called only if
  467 + new results differ from old.
  468 +
  469 +COMMENTS: Called when the ReaderAndStatusProc times out after waiting on
  470 + its event handles. Also called from ReportStatusEvent.
  471 +
  472 +HISTORY: Date: Author: Comment:
  473 + 12/18/95 AllenD Wrote it
  474 +
  475 +-----------------------------------------------------------------------------*/
  476 +void CheckComStat(BOOL bUpdateNow)
  477 +{
  478 + COMSTAT ComStatNew;
  479 + DWORD dwErrors;
  480 +
  481 + __declspec(thread) static COMSTAT ComStatOld = {0};
  482 + __declspec(thread) static DWORD dwErrorsOld = 0;
  483 +
  484 + BOOL bReport = bUpdateNow;
  485 +
  486 + if (!ClearCommError(COMDEV(TTYInfo), &dwErrors, &ComStatNew))
  487 + ErrorReporter("ClearCommError");
  488 +
  489 + if (dwErrors != dwErrorsOld) {
  490 + bReport = TRUE;
  491 + dwErrorsOld = dwErrors;
  492 + }
  493 +
  494 + if (memcmp(&ComStatOld, &ComStatNew, sizeof(COMSTAT))) {
  495 + bReport = TRUE;
  496 + ComStatOld = ComStatNew;
  497 + }
  498 +
  499 + if (bReport)
  500 + ReportComStat(ComStatNew);
  501 +
  502 + ComStatOld = ComStatNew;
  503 +
  504 + return;
  505 +}
  506 +
  507 +/*-----------------------------------------------------------------------------
  508 +
  509 +FUNCTION: ReportCommError
  510 +
  511 +PURPOSE: Calls ClearCommError and reports the results
  512 +
  513 +COMMENTS: This function is called if EV_ERR occurs and is called
  514 + when the ReaderAndStatusProc times out after waiting on
  515 + its event handles.
  516 +
  517 +HISTORY: Date: Author: Comment:
  518 + 10/27/95 AllenD Wrote it
  519 +
  520 +-----------------------------------------------------------------------------*/
  521 +void ReportCommError()
  522 +{
  523 + COMSTAT comStat;
  524 + DWORD dwErrors;
  525 + BOOL fOOP, fOVERRUN, fPTO, fRXOVER, fRXPARITY, fTXFULL;
  526 + BOOL fBREAK, fDNS, fFRAME, fIOE, fMODE;
  527 + char szMessage[100];
  528 +
  529 + //
  530 + // Get and clear current errors on the port
  531 + //
  532 + if (!ClearCommError(COMDEV(TTYInfo), &dwErrors, &comStat))
  533 + ErrorReporter("ClearCommError");
  534 +
  535 + //
  536 + // get error flags
  537 + //
  538 + fDNS = dwErrors & CE_DNS;
  539 + fIOE = dwErrors & CE_IOE;
  540 + fOOP = dwErrors & CE_OOP;
  541 + fPTO = dwErrors & CE_PTO;
  542 + fMODE = dwErrors & CE_MODE;
  543 + fBREAK = dwErrors & CE_BREAK;
  544 + fFRAME = dwErrors & CE_FRAME;
  545 + fRXOVER = dwErrors & CE_RXOVER;
  546 + fTXFULL = dwErrors & CE_TXFULL;
  547 + fOVERRUN = dwErrors & CE_OVERRUN;
  548 + fRXPARITY = dwErrors & CE_RXPARITY;
  549 +
  550 + //
  551 + // create error string
  552 + //
  553 + strcpy(szMessage, "ERROR: ");
  554 + strcat(szMessage, fDNS ? "DNS " : "");
  555 + strcat(szMessage, fIOE ? "IOE " : "");
  556 + strcat(szMessage, fOOP ? "OOP " : "");
  557 + strcat(szMessage, fPTO ? "PTO " : "");
  558 + strcat(szMessage, fMODE ? "MODE " : "");
  559 + strcat(szMessage, fBREAK ? "BREAK " : "");
  560 + strcat(szMessage, fFRAME ? "FRAME " : "");
  561 + strcat(szMessage, fRXOVER ? "RXOVER " : "");
  562 + strcat(szMessage, fTXFULL ? "TXFULL " : "");
  563 + strcat(szMessage, fOVERRUN ? "OVERRUN " : "");
  564 + strcat(szMessage, fRXPARITY ? "RXPARITY " : "");
  565 +
  566 + strcat(szMessage, "\r\n");
  567 +
  568 + //
  569 + // if there really were errors, then report them
  570 + //
  571 + if (dwErrors)
  572 + UpdateStatus(szMessage);
  573 +
  574 + //
  575 + // Report info from the COMSTAT structure
  576 + //
  577 + ReportComStat(comStat);
  578 +
  579 + //
  580 + // Show COMSTAT structure with the error indicator
  581 + //
  582 + if (comStat.fCtsHold)
  583 + UpdateStatus("Tx waiting for CTS signal.\r\n");
  584 +
  585 + if (comStat.fDsrHold)
  586 + UpdateStatus("Tx waiting for DSR signal.\r\n");
  587 +
  588 + if (comStat.fRlsdHold)
  589 + UpdateStatus("Tx waiting for RLSD signal.\r\n");
  590 +
  591 + if (comStat.fXoffHold)
  592 + UpdateStatus("Tx waiting, XOFF char rec'd.\r\n");
  593 +
  594 + if (comStat.fXoffSent)
  595 + UpdateStatus("Tx waiting, XOFF char sent.\r\n");
  596 +
  597 + if (comStat.fEof)
  598 + UpdateStatus("EOF character received.\r\n");
  599 +
  600 + if (comStat.fTxim)
  601 + UpdateStatus("Character waiting for Tx.\r\n");
  602 +
  603 + if (comStat.cbInQue) {
  604 + wsprintf(szMessage, "%d bytes in input buffer.\r\n", comStat.cbInQue);
  605 + UpdateStatus(szMessage);
  606 + }
  607 +
  608 + if (comStat.cbOutQue) {
  609 + wsprintf(szMessage, "%d bytes in output buffer.\r\n", comStat.cbOutQue);
  610 + UpdateStatus(szMessage);
  611 + }
  612 +
  613 + return;
  614 +}
  615 +
  616 +/*-----------------------------------------------------------------------------
  617 +
  618 +FUNCTION: ReportStatusEvent(DWORD)
  619 +
  620 +PURPOSE: Report a comm status event
  621 +
  622 +PARAMETERS:
  623 + dwStatus - status event flag from WaitCommEvent
  624 +
  625 +COMMENTS: This is different than line status (aka Modem Status).
  626 +
  627 +NOTE: EV_RING isn't detected on Windows 95. This is a known problem.
  628 + A workaround to the problem is to rely on GetCommModemStatus, or
  629 + set the modem to send a "RING" and have the app detect it.
  630 +
  631 +HISTORY: Date: Author: Comment:
  632 + 10/27/95 AllenD Wrote it
  633 +
  634 +/*-----------------------------------------------------------------------------*/
  635 +void ReportStatusEvent(DWORD dwStatus)
  636 +{
  637 + BOOL fRING, fRLSD, fRXCHAR, fRXFLAG, fTXEMPTY;
  638 + BOOL fBREAK, fCTS, fDSR, fERR;
  639 + char szMessage[70];
  640 +
  641 + //
  642 + // Get status event flags.
  643 + //
  644 + fCTS = EV_CTS & dwStatus;
  645 + fDSR = EV_DSR & dwStatus;
  646 + fERR = EV_ERR & dwStatus;
  647 + fRING = EV_RING & dwStatus;
  648 + fRLSD = EV_RLSD & dwStatus;
  649 + fBREAK = EV_BREAK & dwStatus;
  650 + fRXCHAR = EV_RXCHAR & dwStatus;
  651 + fRXFLAG = EV_RXFLAG & dwStatus;
  652 + fTXEMPTY = EV_TXEMPTY & dwStatus;
  653 +
  654 + /*
  655 + Construct status message indicating the
  656 + status event flags that are set.
  657 + */
  658 + strcpy(szMessage, "EVENT: ");
  659 + strcat(szMessage, fCTS ? "CTS " : "");
  660 + strcat(szMessage, fDSR ? "DSR " : "");
  661 + strcat(szMessage, fERR ? "ERR " : "");
  662 + strcat(szMessage, fRING ? "RING " : "");
  663 + strcat(szMessage, fRLSD ? "RLSD " : "");
  664 + strcat(szMessage, fBREAK ? "BREAK " : "");
  665 + strcat(szMessage, fRXFLAG ? "RXFLAG " : "");
  666 + strcat(szMessage, fRXCHAR ? "RXCHAR " : "");
  667 + strcat(szMessage, fTXEMPTY ? "TXEMPTY " : "");
  668 +
  669 + /*
  670 + If dwStatus == NULL, then no status event flags are set.
  671 + This happens when the event flag is changed with SetCommMask.
  672 + */
  673 + if (dwStatus == 0x0000)
  674 + strcat(szMessage, "NULL");
  675 +
  676 + strcat(szMessage, "\r\n");
  677 +
  678 + //
  679 + // Queue the status message for the status control
  680 + //
  681 + UpdateStatus(szMessage);
  682 +
  683 + /*
  684 + If an error flag is set in the event flag, then
  685 + report the error with the status message
  686 + If not, then just report the comm status.
  687 + */
  688 + if (fERR)
  689 + ReportCommError();
  690 +
  691 + /*
  692 + Might as well check the modem status and comm status now since
  693 + the event may have been caused by a change in line status.
  694 + Line status is indicated by the CheckModemStatus function.
  695 + */
  696 + CheckModemStatus( FALSE );
  697 +
  698 + /*
  699 + Since line status can affect sending/receiving when
  700 + hardware flow-control is used, ReportComStat should
  701 + be called to show comm status. This is called only if no error
  702 + was reported in the event flag. If an error was reported, then
  703 + ReportCommError was called above and CheckComStat was already called
  704 + in that function.
  705 + */
  706 + if (!fERR)
  707 + CheckComStat( FALSE );
  708 +
  709 + return;
  710 +}
... ...
1   -// stdafx.cpp : source file that includes just the standard includes
2   -// BlueFlashTool.pch will be the pre-compiled header
3   -// stdafx.obj will contain the pre-compiled type information
4   -
5   -#include "stdafx.h"
6   -
7   -
8   -
1   -// stdafx.h : include file for standard system include files,
2   -// or project specific include files that are used frequently, but
3   -// are changed infrequently
4   -//
5   -
6   -#if !defined(AFX_STDAFX_H__BC94D060_2C36_43A8_BAA1_30E1771BCA95__INCLUDED_)
7   -#define AFX_STDAFX_H__BC94D060_2C36_43A8_BAA1_30E1771BCA95__INCLUDED_
8   -
9   -#if _MSC_VER > 1000
10   -#pragma once
11   -#endif // _MSC_VER > 1000
12   -
13   -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
14   -
15   -#include <afxwin.h> // MFC core and standard components
16   -#include <afxext.h> // MFC extensions
17   -#include <afxdisp.h> // MFC Automation classes
18   -#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
19   -#ifndef _AFX_NO_AFXCMN_SUPPORT
20   -#include <afxcmn.h> // MFC support for Windows Common Controls
21   -#endif // _AFX_NO_AFXCMN_SUPPORT
22   -
23   -
24   -//{{AFX_INSERT_LOCATION}}
25   -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
26   -
27   -#endif // !defined(AFX_STDAFX_H__BC94D060_2C36_43A8_BAA1_30E1771BCA95__INCLUDED_)
  1 +/*-----------------------------------------------------------------------------
  2 + This is a part of the Microsoft Source Code Samples.
  3 + Copyright (C) 1995 Microsoft Corporation.
  4 + All rights reserved.
  5 + This source code is only intended as a supplement to
  6 + Microsoft Development Tools and/or WinHelp documentation.
  7 + See these sources for detailed information regarding the
  8 + Microsoft samples programs.
  9 +
  10 + MODULE: Transfer.c
  11 +
  12 + PURPOSE: Transfer a file (receive or send).
  13 +
  14 + FUNCTIONS:
  15 + TransferRepeatCreate - Preps program for a repeated send
  16 + TransferRepeatDestroy - Completes a repeated send
  17 + TransferRepeatDo - Sends the data to the writer thread
  18 + TransferFileTextStart - Preps program for a text file send
  19 + TransferFileTextEnd - Completes a file transfer
  20 + TransferThreadProc - Thread procedure to do actual transfer
  21 + TransferFileText - Preps program for a text file send
  22 + ReceiveFileText - Preps program for a text file capture
  23 + OpenTheFile - Opens a file
  24 + CreateTheFile - Creates a file
  25 + GetTransferSizes - Determines transfer metrics from file and buffer sizes
  26 + ShowTransferStatistics - Displays transfer stats
  27 + CheckForMessges - Peek message check to keep things flowing
  28 + during a transfer
  29 + SendFile - Send a file
  30 + CaptureFile - Sets the receive state for file capture
  31 +
  32 +-----------------------------------------------------------------------------*/
  33 +
  34 +#include <windows.h>
  35 +#include <commctrl.h>
  36 +#include "mttty.h"
  37 +
  38 +#pragma comment(lib,"winmm.lib")
  39 +
  40 +//
  41 +// Globals used in this file only
  42 +//
  43 +HANDLE hFile;
  44 +HANDLE hTransferAbortEvent;
  45 +HANDLE hTransferThread;
  46 +UINT uTimerId;
  47 +MMRESULT mmTimer = (MMRESULT)NULL;
  48 +char * lpBuf;
  49 +//
  50 +// Prototypes for functions called only within this file
  51 +//
  52 +DWORD WINAPI TransferThreadProc(LPVOID);
  53 +HANDLE OpenTheFile( LPCTSTR );
  54 +HANDLE CreateTheFile( LPCTSTR );
  55 +void CaptureFile( HANDLE, HWND );
  56 +UINT CheckForMessages( void );
  57 +BOOL GetTransferSizes( HANDLE, DWORD *, DWORD *, DWORD *);
  58 +
  59 +
  60 +/*-----------------------------------------------------------------------------
  61 +
  62 +FUNCTION: TransferRepeatCreate(LPCTSTR, DWORD)
  63 +
  64 +PURPOSE: Prepares program for a repeated text file transfer (send)
  65 +
  66 +PARAMETERS:
  67 + lpstrFileName - name of file selected to send
  68 + dwFrequency - frequency of timer
  69 +
  70 +COMMENTS: This function sets up a window timer to fire off
  71 + every so often. When it fires, TransferRepeatDo is
  72 + called with the same name as above. This causes the file transfer
  73 + to actuall take place.
  74 + TransferRepeatDestroy is called to kill the timer.
  75 + This function disables certain menu items that should not be
  76 + available for the duration of a repeated send even if the actual
  77 + Tx is not taking place.
  78 +
  79 +HISTORY: Date: Author: Comment:
  80 + 1/29/96 AllenD Wrote it
  81 +
  82 +-----------------------------------------------------------------------------*/
  83 +void TransferRepeatCreate(LPCTSTR lpszFileName, DWORD dwFrequency)
  84 +{
  85 + HMENU hMenu;
  86 + UINT MenuFlags ;
  87 + DWORD dwFileSize;
  88 + DWORD dwMaxPackets;
  89 + DWORD dwPacketSize;
  90 + DWORD dwRead;
  91 +
  92 + //
  93 + // open the file
  94 + //
  95 + hFile = OpenTheFile(lpszFileName);
  96 + if (hFile == INVALID_HANDLE_VALUE)
  97 + return;
  98 +
  99 + //
  100 + // modify transfer menu
  101 + //
  102 + hMenu = GetMenu(ghwndMain);
  103 + MenuFlags = MF_DISABLED | MF_GRAYED;
  104 + EnableMenuItem(hMenu, ID_TRANSFER_SENDFILETEXT, MenuFlags);
  105 + EnableMenuItem(hMenu, IDC_SENDBTN, MenuFlags);
  106 + EnableMenuItem(hMenu, ID_TRANSFER_SENDREPEATEDLY, MenuFlags);
  107 + EnableMenuItem(hMenu, ID_TRANSFER_ABORTREPEATEDSENDING, MF_ENABLED);
  108 + EnableMenuItem(hMenu, ID_TRANSFER_RECEIVEFILETEXT, MenuFlags);
  109 +
  110 + //
  111 + // enable abort button and progress bar
  112 + //
  113 + SetWindowText(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), "Abort Tx");
  114 + ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), SW_SHOW);
  115 +
  116 + if (!GetTransferSizes(hFile, &dwPacketSize, &dwMaxPackets, &dwFileSize)) {
  117 + TransferRepeatDestroy();
  118 + return;
  119 + }
  120 +
  121 + // Allocate a buffer
  122 + lpBuf = HeapAlloc(ghWriterHeap, 0, dwFileSize);
  123 + if (lpBuf == NULL) {
  124 + ErrorReporter("HeapAlloc (data block from writer heap).\r\nFile is too large");
  125 + TransferRepeatDestroy();
  126 + return;
  127 + }
  128 +
  129 + // fill the buffer
  130 + if (!ReadFile(hFile, lpBuf, dwFileSize, &dwRead, NULL)) {
  131 + ErrorReporter("Can't read from file\n");
  132 + TransferRepeatDestroy();
  133 + }
  134 +
  135 + if (dwRead != dwFileSize)
  136 + ErrorReporter("Didn't read entire file\n");
  137 +
  138 + mmTimer = timeSetEvent((UINT) dwFrequency, 10, TransferRepeatDo, dwRead, TIME_PERIODIC);
  139 + if (mmTimer == (MMRESULT) NULL) {
  140 + ErrorReporter("Could not create mm timer");
  141 + TransferRepeatDestroy();
  142 + }
  143 + else {
  144 + REPEATING(TTYInfo) = TRUE;
  145 + OutputDebugString("Timer setup.\n");
  146 + }
  147 +
  148 + return;
  149 +}
  150 +
  151 +/*-----------------------------------------------------------------------------
  152 +
  153 +FUNCTION: TransferRepeatDestroy( void )
  154 +
  155 +PURPOSE: Stops a repeated text file transfer (send)
  156 +
  157 +COMMENTS: Kills the repeated-send timer.
  158 +
  159 +HISTORY: Date: Author: Comment:
  160 + 1/29/96 AllenD Wrote it
  161 +
  162 +-----------------------------------------------------------------------------*/
  163 +void TransferRepeatDestroy()
  164 +{
  165 + HMENU hMenu;
  166 + DWORD MenuFlags;
  167 + MMRESULT mmRes;
  168 +
  169 + if (mmTimer != (MMRESULT) NULL) {
  170 + mmRes = timeKillEvent(mmTimer);
  171 + if (mmRes != TIMERR_NOERROR)
  172 + ErrorReporter("Can't kill mm timer");
  173 + mmTimer = (MMRESULT) NULL;
  174 + }
  175 +
  176 + // close the file
  177 + CloseHandle(hFile);
  178 +
  179 + // inform writer to abort all pending write requests
  180 + if (!WriterAddFirstNodeTimeout(WRITE_ABORT, 0, 0, NULL, NULL, NULL, 500))
  181 + ErrorReporter("Couldn't inform writer to abort sending.");
  182 +
  183 + // free the buffer
  184 + if (!HeapFree(ghWriterHeap, 0, lpBuf))
  185 + ErrorReporter("HeapFree (data block from writer heap)");
  186 +
  187 + REPEATING(TTYInfo) = FALSE;
  188 + OutputDebugString("Repeated transfer destroyed.\r\n");
  189 +
  190 + //
  191 + // enable transfer menu
  192 + //
  193 + hMenu = GetMenu(ghwndMain);
  194 + MenuFlags = MF_ENABLED;
  195 + EnableMenuItem(hMenu, ID_TRANSFER_ABORTREPEATEDSENDING, MF_DISABLED | MF_GRAYED);
  196 + EnableMenuItem(hMenu, ID_TRANSFER_SENDFILETEXT, MenuFlags);
  197 + EnableMenuItem(hMenu, IDC_SENDBTN, MenuFlags);
  198 + EnableMenuItem(hMenu, ID_TRANSFER_SENDREPEATEDLY, MenuFlags);
  199 + EnableMenuItem(hMenu, ID_TRANSFER_RECEIVEFILETEXT, MenuFlags);
  200 +
  201 + ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), SW_HIDE);
  202 +
  203 + return;
  204 +}
  205 +
  206 +/*-----------------------------------------------------------------------------
  207 +
  208 +FUNCTION: TransferRepeatDo( void )
  209 +
  210 +PURPOSE: Performs a single text file transfer (send)
  211 +
  212 +COMMENTS: Allocates a block to hold the file.
  213 + Prepares the writer packet.
  214 +
  215 +HISTORY: Date: Author: Comment:
  216 + 1/29/96 AllenD Wrote it
  217 +
  218 +-----------------------------------------------------------------------------*/
  219 +void CALLBACK TransferRepeatDo( UINT uTimerId,
  220 + UINT uRes,
  221 + DWORD dwFileSize,
  222 + DWORD dwRes1,
  223 + DWORD dwRes2)
  224 +{
  225 + if (!WriterAddNewNodeTimeout(WRITE_BLOCK, dwFileSize, 0, lpBuf, 0, 0, 10))
  226 + PostMessage(ghwndMain, WM_COMMAND, ID_TRANSFER_ABORTSENDING, MAKELPARAM(IDC_ABORTBTN, 0) );
  227 +
  228 + return;
  229 +}
  230 +
  231 +/*-----------------------------------------------------------------------------
  232 +
  233 +FUNCTION: TransferFileTextStart(LPCTSTR)
  234 +
  235 +PURPOSE: Prepares program for a text file transfer (send)
  236 +
  237 +PARAMETERS:
  238 + lpstrFileName - name of file selected to send
  239 +
  240 +COMMENTS: Modifies menus and dialog control, then restores them
  241 +
  242 +HISTORY: Date: Author: Comment:
  243 + 1/26/96 AllenD Wrote it
  244 +
  245 +-----------------------------------------------------------------------------*/
  246 +void TransferFileTextStart(LPCTSTR lpstrFileName)
  247 +{
  248 + DWORD dwThreadId;
  249 + HMENU hMenu;
  250 + UINT MenuFlags ;
  251 +
  252 + //
  253 + // open the file
  254 + //
  255 + hFile = OpenTheFile(lpstrFileName);
  256 + if (hFile == INVALID_HANDLE_VALUE)
  257 + return;
  258 +
  259 + //
  260 + // modify transfer menu
  261 + //
  262 + hMenu = GetMenu(ghwndMain);
  263 + MenuFlags = MF_DISABLED | MF_GRAYED;
  264 + EnableMenuItem(hMenu, ID_TRANSFER_SENDFILETEXT, MenuFlags);
  265 + EnableMenuItem(hMenu, IDC_SENDBTN, MenuFlags);
  266 + EnableMenuItem(hMenu, ID_TRANSFER_SENDREPEATEDLY, MenuFlags);
  267 + EnableMenuItem(hMenu, ID_TRANSFER_ABORTSENDING, MF_ENABLED);
  268 + EnableMenuItem(hMenu, ID_TRANSFER_RECEIVEFILETEXT, MenuFlags);
  269 + //
  270 + // enable abort button and progress bar
  271 + //
  272 + gfAbortTransfer = FALSE;
  273 + SetWindowText(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), "Abort Tx");
  274 + ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), SW_SHOW);
  275 + ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_TRANSFERPROGRESS), SW_SHOW);
  276 +
  277 + // start the transfer thread
  278 + hTransferAbortEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
  279 + if (hTransferAbortEvent == NULL)
  280 + ErrorReporter("CreateEvent(Transfer Abort Event)");
  281 +
  282 + hTransferThread = CreateThread(NULL, 0,
  283 + TransferThreadProc,
  284 + (LPVOID) hFile, 0, &dwThreadId);
  285 +
  286 + if (hTransferThread == NULL) {
  287 + ErrorReporter("CreateThread (Transfer Thread)");
  288 + TransferFileTextEnd();
  289 + }
  290 + else
  291 + TRANSFERRING(TTYInfo) = TRUE;
  292 +
  293 + return;
  294 +}
  295 +
  296 +/*-----------------------------------------------------------------------------
  297 +
  298 +FUNCTION: TransferFileTextEnd()
  299 +
  300 +PURPOSE: Stops a text file transfer (send)
  301 +
  302 +COMMENTS: Modifies menus and dialog control, then restores them
  303 +
  304 +HISTORY: Date: Author: Comment:
  305 + 1/26/96 AllenD Wrote it
  306 +
  307 +-----------------------------------------------------------------------------*/
  308 +void TransferFileTextEnd()
  309 +{
  310 + HMENU hMenu;
  311 + UINT MenuFlags ;
  312 +
  313 + // stop the transfer thread
  314 + SetEvent(hTransferAbortEvent);
  315 +
  316 + OutputDebugString("Waiting for transfer thread...\n");
  317 +
  318 + if (WaitForSingleObject(hTransferThread, 3000) != WAIT_OBJECT_0) {
  319 + ErrorReporter("TransferThread didn't stop.");
  320 + TerminateThread(hTransferThread, 0);
  321 + }
  322 + else
  323 + OutputDebugString("Transfer thread exited\n");
  324 +
  325 + CloseHandle(hTransferAbortEvent);
  326 + CloseHandle(hTransferThread);
  327 +
  328 + TRANSFERRING(TTYInfo) = FALSE;
  329 +
  330 + //
  331 + // enable transfer menu
  332 + //
  333 + hMenu = GetMenu(ghwndMain);
  334 + MenuFlags = MF_ENABLED;
  335 + EnableMenuItem(hMenu, ID_TRANSFER_SENDFILETEXT, MenuFlags);
  336 + EnableMenuItem(hMenu, IDC_SENDBTN, MenuFlags);
  337 + EnableMenuItem(hMenu, ID_TRANSFER_SENDREPEATEDLY, MenuFlags);
  338 + EnableMenuItem(hMenu, ID_TRANSFER_RECEIVEFILETEXT, MenuFlags);
  339 + EnableMenuItem(hMenu, ID_TRANSFER_ABORTSENDING, MF_DISABLED | MF_GRAYED);
  340 +
  341 + //
  342 + // disable abort button and progress bar
  343 + //
  344 + ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), SW_HIDE);
  345 + ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_TRANSFERPROGRESS), SW_HIDE);
  346 + EnableWindow( GetDlgItem(ghWndToolbarDlg, IDC_SENDBTN), TRUE);
  347 + //
  348 + // close the file
  349 + //
  350 + CloseHandle(hFile);
  351 +}
  352 +
  353 +
  354 +/*-----------------------------------------------------------------------------
  355 +
  356 +FUNCTION: ReceiveFileText(LPCTSTR)
  357 +
  358 +PURPOSE: Prepares program for a text file transfer (receive)
  359 +
  360 +PARAMETERS:
  361 + lpstrFileName - name of file selected for receiving
  362 +
  363 +COMMENTS: Modifies menus and control, then restores them
  364 +
  365 +HISTORY: Date: Author: Comment:
  366 + 10/27/95 AllenD Wrote it
  367 +
  368 +-----------------------------------------------------------------------------*/
  369 +void ReceiveFileText(LPCTSTR lpstrFileName)
  370 +{
  371 + HMENU hMenu;
  372 + UINT MenuFlags ;
  373 +
  374 + //
  375 + // create the file
  376 + //
  377 + ghFileCapture = CreateTheFile(lpstrFileName);
  378 + if (ghFileCapture == INVALID_HANDLE_VALUE)
  379 + return;
  380 +
  381 + /*
  382 + setup transfer
  383 + disable file menu
  384 + */
  385 + hMenu = GetMenu(ghwndMain);
  386 + MenuFlags = MF_DISABLED | MF_GRAYED;
  387 + EnableMenuItem(hMenu, ID_FILE_CONNECT, MenuFlags);
  388 + EnableMenuItem(hMenu, ID_FILE_DISCONNECT, MenuFlags);
  389 +
  390 + //
  391 + // disable transfer menu
  392 + //
  393 + EnableMenuItem(hMenu, ID_TRANSFER_SENDFILETEXT, MenuFlags);
  394 + EnableMenuItem(hMenu, IDC_SENDBTN, MenuFlags);
  395 + EnableMenuItem(hMenu, ID_TRANSFER_RECEIVEFILETEXT, MenuFlags);
  396 + EnableMenuItem(hMenu, ID_TRANSFER_SENDREPEATEDLY, MenuFlags);
  397 +
  398 + //
  399 + // enable abort button and progress bar
  400 + //
  401 + gfAbortTransfer = FALSE;
  402 + SetWindowText(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), "Close Capture");
  403 + ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), SW_SHOW);
  404 + ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_TRANSFERPROGRESS), SW_SHOW);
  405 +
  406 + //
  407 + // send file until done or abort
  408 + //
  409 + CaptureFile(ghFileCapture, GetDlgItem(ghWndStatusDlg, IDC_TRANSFERPROGRESS));
  410 +
  411 + //
  412 + // enable menu
  413 + //
  414 + hMenu = GetMenu(ghwndMain);
  415 + MenuFlags = MF_ENABLED;
  416 + ChangeConnection(ghwndMain, CONNECTED(TTYInfo));
  417 +
  418 + //
  419 + // enable transfer menu
  420 + //
  421 + EnableMenuItem(hMenu, ID_TRANSFER_SENDFILETEXT, MenuFlags);
  422 + EnableMenuItem(hMenu, IDC_SENDBTN, MenuFlags);
  423 + EnableMenuItem(hMenu, ID_TRANSFER_RECEIVEFILETEXT, MenuFlags);
  424 + EnableMenuItem(hMenu, ID_TRANSFER_SENDREPEATEDLY, MenuFlags);
  425 +
  426 + //
  427 + // hide abort button and progress bar
  428 + //
  429 + ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_ABORTBTN), SW_HIDE);
  430 + ShowWindow(GetDlgItem(ghWndStatusDlg, IDC_TRANSFERPROGRESS), SW_HIDE);
  431 +
  432 + gfAbortTransfer = FALSE;
  433 +
  434 + CloseHandle(ghFileCapture);
  435 +
  436 + return; // returns when file transfer is complete or aborted
  437 +}
  438 +
  439 +/*-----------------------------------------------------------------------------
  440 +
  441 +FUNCTION: OpenTheFile(LPCTSTR)
  442 +
  443 +PURPOSE: Open a file and return the file handle
  444 +
  445 +PARAMETERS:
  446 + lpFName - name of file to open
  447 +
  448 +HISTORY: Date: Author: Comment:
  449 + 10/27/95 AllenD Wrote it
  450 +
  451 +-----------------------------------------------------------------------------*/
  452 +HANDLE OpenTheFile(LPCTSTR lpFName)
  453 +{
  454 + HANDLE hTemp;
  455 +
  456 + hTemp = CreateFile(lpFName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0,NULL);
  457 +
  458 + if (hTemp == INVALID_HANDLE_VALUE)
  459 + ErrorReporter("CreateFile");
  460 +
  461 + return hTemp;
  462 +}
  463 +
  464 +/*-----------------------------------------------------------------------------
  465 +
  466 +FUNCTION: CreateTheFile(LPCTSTR)
  467 +
  468 +PURPOSE: Creates a file and returns the file handle
  469 +
  470 +PARAMETERS:
  471 + lpFName - name of file to create
  472 +
  473 +HISTORY: Date: Author: Comment:
  474 + 10/27/95 AllenD Wrote it
  475 +
  476 +-----------------------------------------------------------------------------*/
  477 +HANDLE CreateTheFile(LPCTSTR lpFName)
  478 +{
  479 + HANDLE hTemp;
  480 +
  481 + hTemp = CreateFile(lpFName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0,NULL);
  482 +
  483 + if (hTemp == INVALID_HANDLE_VALUE)
  484 + ErrorReporter("CreateFile");
  485 +
  486 + return hTemp;
  487 +}
  488 +
  489 +/*-----------------------------------------------------------------------------
  490 +
  491 +FUNCTION: GetTransferSizes(HANDLE, DWORD *, DWORD *, DWORD *)
  492 +
  493 +PURPOSE: Examines file and determines packet size, number of packets,
  494 + and file size.
  495 +
  496 +PARAMETERS:
  497 + hFile - handle of file to get size information from
  498 + pdwDataPacketSize - size of an individual data packet
  499 + pdwNumPackets - total number of packets
  500 + pdwFileSize - size of file
  501 +
  502 +RETURN:
  503 + TRUE - all metrics could be determined
  504 + FALSE - something wrong with the file metrics, can't transfer
  505 +
  506 +COMMENTS:
  507 + This module can't handle files that are extremely large, so
  508 + it may return FALSE if a large file is specified.
  509 +
  510 +HISTORY: Date: Author: Comment:
  511 + 10/27/95 AllenD Wrote it
  512 +
  513 +-----------------------------------------------------------------------------*/
  514 +BOOL GetTransferSizes(HANDLE hFile, DWORD * pdwDataPacketSize, DWORD * pdwNumPackets, DWORD * pdwFileSize)
  515 +{
  516 + BY_HANDLE_FILE_INFORMATION fi;
  517 +
  518 + if (!GetFileInformationByHandle(hFile, &fi)) {
  519 + ErrorReporter("GetFileInformationByHandle");
  520 + return FALSE;
  521 + }
  522 + else {
  523 + if (fi.nFileSizeHigh) {
  524 + MessageBox(ghwndMain, "File is too large to transfer.", "File Transfer Error", MB_OK);
  525 + return FALSE;
  526 + }
  527 +
  528 + //
  529 + // setup packet size, file size and compute the number of packets
  530 + //
  531 + *pdwDataPacketSize = MAX_WRITE_BUFFER;
  532 + *pdwFileSize = fi.nFileSizeLow;
  533 + *pdwNumPackets = *pdwFileSize / *pdwDataPacketSize;
  534 +
  535 + if (*pdwNumPackets > 65534) {
  536 + MessageBox(ghwndMain, "File is too large for buffer size.", "File Transfer Error", MB_OK);
  537 + return FALSE;
  538 + }
  539 + }
  540 + return TRUE;
  541 +}
  542 +
  543 +/*-----------------------------------------------------------------------------
  544 +
  545 +FUNCTION: ShowTransferStatistics(DWORD, DWORD, DWORD)
  546 +
  547 +PURPOSE: Displays bytes transferred and bytes per second
  548 +
  549 +PARAMETERS:
  550 + dwEnd - ending time in milliseconds
  551 + dwStart - starting time
  552 + dwBytesTransferred - bytes sent
  553 +
  554 +HISTORY: Date: Author: Comment:
  555 + 10/27/95 AllenD Wrote it
  556 +
  557 +-----------------------------------------------------------------------------*/
  558 +void ShowTransferStatistics(DWORD dwEnd, DWORD dwStart, DWORD dwBytesTransferred)
  559 +{
  560 + char szTemp[100];
  561 + DWORD dwSecs;
  562 +
  563 + dwSecs = (dwEnd - dwStart) / 1000;
  564 +
  565 + //
  566 + // display only if dwSecs != 0; if dwSecs == 0, then divide by zero occurs.
  567 + //
  568 + if (dwSecs != 0) {
  569 + wsprintf(szTemp, "Bytes transferred: %d\r\nBytes/Second: %d\r\n", dwBytesTransferred, dwBytesTransferred / dwSecs);
  570 + UpdateStatus(szTemp);
  571 + }
  572 +
  573 + return;
  574 +}
  575 +
  576 +/*-----------------------------------------------------------------------------
  577 +
  578 +FUNCTION: CheckForMessages
  579 +
  580 +PURPOSE: Check for a message and dispatch it.
  581 +
  582 +RETURN:
  583 + If the WM_CLOSE message or the WM_SYSCOMMAND (SC_CLOSE) is
  584 + retrieved, WM_CLOSE is posted, and WM_CLOSEQUIT is
  585 + returned by the function. This allows the caller
  586 + to detect this as an abort condition and exit properly. When
  587 + the caller exits, the main message loop in the WinMain function
  588 + should be entered again and the WM_CLOSE message will be
  589 + handled properly.
  590 +
  591 + If there is a message other than those above, it is dispatched
  592 + and TRUE is returned indicating that a message was dispatched.
  593 +
  594 + If no message is found, FALSE is returned.
  595 +
  596 +HISTORY: Date: Author: Comment:
  597 + 10/27/95 AllenD Wrote it
  598 +
  599 +-----------------------------------------------------------------------------*/
  600 +UINT CheckForMessages()
  601 +{
  602 + MSG msg;
  603 +
  604 + if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
  605 + if (msg.message == WM_CLOSE) {
  606 + PostMessage(ghwndMain, WM_CLOSE, 0, 0);
  607 + return WM_CLOSE;
  608 + }
  609 +
  610 + if (msg.message == WM_SYSCOMMAND && msg.wParam == SC_CLOSE) {
  611 + PostMessage(ghwndMain, WM_CLOSE, 0, 0);
  612 + return WM_CLOSE;
  613 + }
  614 +
  615 + if (!TranslateAccelerator( ghwndMain, ghAccel, &msg )) {
  616 + TranslateMessage( &msg ) ;
  617 + DispatchMessage( &msg ) ;
  618 + }
  619 +
  620 + return TRUE ;
  621 + }
  622 +
  623 + return FALSE ;
  624 +}
  625 +
  626 +/*-----------------------------------------------------------------------------
  627 +
  628 +FUNCTION: CaptureFile(HANDLE, HWND)
  629 +
  630 +PURPOSE: Receives a file
  631 +
  632 +PARAMETERS:
  633 + hFile - handle of file to receive the data being captured (not used)
  634 + hWndProgress - window handle of progress bar (not used)
  635 +
  636 +COMMENTS: Sets the receive state and waits for capture to end
  637 +
  638 +HISTORY: Date: Author: Comment:
  639 + 10/27/95 AllenD Wrote it
  640 +
  641 +-----------------------------------------------------------------------------*/
  642 +void CaptureFile(HANDLE hFile, HWND hWndProgress)
  643 +{
  644 + UINT uMsgResult;
  645 + gdwReceiveState = RECEIVE_CAPTURED;
  646 +
  647 + while ( !gfAbortTransfer ) {
  648 +
  649 + uMsgResult = CheckForMessages();
  650 +
  651 + //
  652 + // If WM_CLOSE is retrieved, then exit.
  653 + // If no message is retrieved, then sleep a little.
  654 + // If any other message is retrieved, check for another one.
  655 + //
  656 + switch(uMsgResult)
  657 + {
  658 + case WM_CLOSE: gfAbortTransfer = TRUE; break;
  659 + case FALSE: Sleep(200); break;
  660 + case TRUE: break;
  661 + }
  662 + }
  663 +
  664 + gdwReceiveState = RECEIVE_TTY;
  665 +
  666 + return;
  667 +}
  668 +
  669 +/*-----------------------------------------------------------------------------
  670 +
  671 +FUNCTION: TransferThreadProc(LPVOID)
  672 +
  673 +PURPOSE: Worker thread does all the file transfer work
  674 +
  675 +PARAMETERS:
  676 + lpV - actually a HANDLE for the file
  677 +
  678 +COMMENTS: Function allows the hTransferAbortEvent to
  679 + signal an abort condition.
  680 + If the thread finishes OK, then the thread
  681 + calls the TransferFileTextEnd function itself.
  682 +
  683 +HISTORY: Date: Author: Comment:
  684 + 1/26/96 AllenD Wrote it
  685 +
  686 +-----------------------------------------------------------------------------*/
  687 +
  688 +#define HEADER_START 0x44332211
  689 +#define BAUDRATE_DET_DATA 0xFFAAFF55
  690 +#define BAUDRATE_DET_DATA_LEN 0xB00
  691 +#define HEADER_LEN 0x20
  692 +#define MAC_ADDR_OFFSET 0x68000
  693 +
  694 +#define U32 unsigned int
  695 +
  696 +enum {
  697 + READ_CPU_TICKS_ERR,
  698 + WRONG_FILE_FORMAT,
  699 + CHECKSUM_ERROR,
  700 + FILE_CHCK_SUCCESSFUL
  701 +};
  702 +
  703 +typedef struct {
  704 + U32 rx_header_start;
  705 + U32 rx_copy_addr;
  706 + U32 rx_run_addr;
  707 + U32 rx_total_bytes;
  708 + U32 rx_bootloader_flag;
  709 + U32 rx_sflash_size;
  710 + U32 rx_checksum;
  711 + U32 rx_dummy_data_size;
  712 +} BOOT_HEADER;
  713 +
  714 +const char dft_bdaddr[6] = {0x00,0x00,0x00,0x3F,0x9f,0x94};
  715 +
  716 +int fileCheck(char *fData,char *dataLen)
  717 +{
  718 + int i;
  719 + /*BOOL flag = FALSE;*/
  720 + int ret = FILE_CHCK_SUCCESSFUL;
  721 + U32 *p1 = (U32 *)fData;
  722 + BOOT_HEADER *p_header;
  723 + char *p = fData+MAC_ADDR_OFFSET+BAUDRATE_DET_DATA_LEN+HEADER_LEN;
  724 + unsigned char baaddr[6];
  725 + LARGE_INTEGER ticks;
  726 +
  727 + if (dataLen < MAC_ADDR_OFFSET + BAUDRATE_DET_DATA_LEN + HEADER_LEN + 0x2000)
  728 + {
  729 + /*flag = TRUE;*/
  730 +
  731 + return FILE_CHCK_SUCCESSFUL;
  732 + }
  733 +
  734 +
  735 +
  736 + p1 = (U32 *)fData;
  737 +
  738 + memcpy(baaddr,dft_bdaddr,sizeof(baaddr));
  739 +
  740 + /***********det data check*********************/
  741 + for (i=0;i<BAUDRATE_DET_DATA_LEN/4;i++)
  742 + {
  743 + if (*p1++ != BAUDRATE_DET_DATA)
  744 + {
  745 + ret = WRONG_FILE_FORMAT;
  746 + break;
  747 + }
  748 + }
  749 +
  750 + p_header = (BOOT_HEADER *)(fData+BAUDRATE_DET_DATA_LEN);
  751 + /***********header check*********************/
  752 + if (ret == FILE_CHCK_SUCCESSFUL)
  753 + {
  754 + if (p_header->rx_header_start != HEADER_START)
  755 + {
  756 + ret = WRONG_FILE_FORMAT;
  757 + }
  758 + else if (p_header->rx_total_bytes != (dataLen - BAUDRATE_DET_DATA_LEN - sizeof(BOOT_HEADER)))
  759 + {
  760 + ret = WRONG_FILE_FORMAT;
  761 + }
  762 + }
  763 +
  764 + /***********checksum*********************/
  765 + if (ret == FILE_CHCK_SUCCESSFUL)
  766 + {
  767 + int checksum = 0;
  768 + p1 = (U32*)(fData + BAUDRATE_DET_DATA_LEN + sizeof(BOOT_HEADER));
  769 + for(i=0;i<(p_header->rx_total_bytes-4)/4;i++)
  770 + {
  771 + checksum += *p1++;
  772 + }
  773 +
  774 + if ((checksum != *p1)||(checksum != p_header->rx_checksum))
  775 + {
  776 + ret = CHECKSUM_ERROR;
  777 + }
  778 + }
  779 +
  780 +
  781 +//BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
  782 + if (QueryPerformanceCounter(&ticks))
  783 + {
  784 + char szMessage[70];
  785 + baaddr[0] = (unsigned char)(ticks.LowPart&0x000000ff);
  786 + baaddr[1] = (unsigned char)(ticks.LowPart>>8)&0x000000ff;
  787 + baaddr[2] = (unsigned char)(ticks.LowPart>>16)&0x000000ff;
  788 +
  789 + wsprintf(szMessage, "bt bdaddr:0x%02x%02x%02x%02x%02x%02x\r\n",baaddr[5],baaddr[4],baaddr[3],baaddr[2],baaddr[1],baaddr[0]);
  790 + UpdateStatus(szMessage);
  791 + }
  792 + else
  793 + {
  794 + ret = READ_CPU_TICKS_ERR;
  795 + }
  796 +
  797 +// "Optek Bt\0\0"
  798 + *p++ = 'O';
  799 + *p++ = 'p';
  800 + *p++ = 't';
  801 + *p++ = 'e';
  802 + *p++ = 'k';
  803 + *p++ = ' ';
  804 + *p++ = 'B';
  805 + *p++ = 't';
  806 +// *p++ = 0;
  807 +
  808 +//u32 wr_cn;
  809 + *p++ = 0;
  810 + *p++ = 0;
  811 + *p++ = 0;
  812 + *p++ = 0;
  813 +
  814 + *p++ = 0;
  815 + *p++ = 0;
  816 + *p++ = 0;
  817 + *p++ = 0;
  818 +
  819 +// bt mac id
  820 +/* *p++ = 0x11;
  821 + *p++ = 0x12;
  822 + *p++ = 0x13;
  823 + *p++ = 0x14;
  824 + *p++ = 0x15;
  825 + *p++ = 0x16;*/
  826 + memcpy(p,baaddr,sizeof(baaddr));
  827 + p+=6;
  828 +
  829 + //if (flag)
  830 + //{
  831 + // OutputDebugString("àÓ\n");
  832 + p = fData + MAC_ADDR_OFFSET + BAUDRATE_DET_DATA_LEN + HEADER_LEN + 0X1000;
  833 + /*}
  834 + else
  835 + {
  836 + OutputDebugString("àÓàÓàÓ\n");
  837 + p = fData + MAC_ADDR_OFFSET + 0X1000 + 0xb20;
  838 + }*/
  839 +
  840 +// "Optek Bt\0\0"
  841 + *p++ = 'O';
  842 + *p++ = 'p';
  843 + *p++ = 't';
  844 + *p++ = 'e';
  845 + *p++ = 'k';
  846 + *p++ = ' ';
  847 + *p++ = 'B';
  848 + *p++ = 't';
  849 + // *p++ = 0;
  850 +
  851 +//u32 wr_cn;
  852 + *p++ = 0;
  853 + *p++ = 0;
  854 + *p++ = 0;
  855 + *p++ = 0;
  856 +
  857 + *p++ = 0;
  858 + *p++ = 0;
  859 + *p++ = 0;
  860 + *p++ = 0;
  861 +// bt mac id
  862 +/* *p++ = 0x11;
  863 + *p++ = 0x12;
  864 + *p++ = 0x13;
  865 + *p++ = 0x14;
  866 + *p++ = 0x15;
  867 + *p++ = 0x16;*/
  868 + memcpy(p,baaddr,sizeof(baaddr));
  869 + p+=6;
  870 +
  871 + //a-a5
  872 +/*
  873 + buf = buf+0xfc00c;
  874 + buf[0] = a;
  875 + buf[1] = a1;
  876 + buf[2] = a2;
  877 + buf[3] = a3;
  878 + buf[4] = a4;
  879 + buf[5] = a5;
  880 + buf = buf-0xfc00c;
  881 + */
  882 +
  883 + if (ret == FILE_CHCK_SUCCESSFUL)
  884 + {
  885 + int checksum = 0;
  886 + p1 = (U32*)(fData + BAUDRATE_DET_DATA_LEN + sizeof(BOOT_HEADER));
  887 + for(i=0;i<(p_header->rx_total_bytes-4)/4;i++)
  888 + {
  889 + checksum += *p1++;
  890 + }
  891 +
  892 + *p1 = checksum;
  893 + p_header->rx_checksum = checksum;
  894 + }
  895 + return ret;
  896 +}
  897 +
  898 +DWORD WINAPI TransferThreadProc(LPVOID lpV)
  899 +{
  900 + DWORD dwPacketSize, dwMaxPackets, dwFileSize;
  901 + DWORD dwStartTime;
  902 + HWND hWndProgress;
  903 + HANDLE hFileHandle;
  904 + HANDLE hDataHeap;
  905 + BOOL fStarted = TRUE;
  906 + BOOL fAborting = FALSE;
  907 + BOOL userAborting = TRUE;
  908 + char *lpfileBuf;
  909 + char *pRead;
  910 + DWORD dwRead;
  911 + int err;
  912 +
  913 +
  914 + hFileHandle = (HANDLE) lpV;
  915 + hWndProgress = GetDlgItem(ghWndStatusDlg, IDC_TRANSFERPROGRESS);
  916 +
  917 + // set up transfer metrics
  918 + if (!GetTransferSizes(hFileHandle, &dwPacketSize, &dwMaxPackets, &dwFileSize))
  919 + fAborting = TRUE;
  920 + else {
  921 + SendMessage(hWndProgress, PBM_SETRANGE, 0, MAKELPARAM(0, dwMaxPackets+1));
  922 +// SendMessage(hWndProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
  923 + SendMessage(hWndProgress, PBM_SETSTEP, (WPARAM) 1, 0);
  924 + SendMessage(hWndProgress, PBM_SETPOS, 0, 0);
  925 + }
  926 +
  927 + // set up transfer heaps
  928 + if (!fAborting) {
  929 + SYSTEM_INFO sysInfo;
  930 + GetSystemInfo(&sysInfo);
  931 +// hDataHeap = HeapCreate(0, sysInfo.dwPageSize * 2, sysInfo.dwPageSize * 10);
  932 + hDataHeap = HeapCreate(0, sysInfo.dwPageSize * 20,0);
  933 + if (hDataHeap == NULL) {
  934 + ErrorReporter("HeapCreate (Data Heap)");
  935 + fAborting = TRUE;
  936 + }
  937 + }
  938 +
  939 + /**********************check file*********************************/
  940 + lpfileBuf = HeapAlloc(hDataHeap, 0, dwFileSize);
  941 + pRead = lpfileBuf;
  942 + memset(lpfileBuf,0,dwFileSize);
  943 + ReadFile(hFileHandle, lpfileBuf, dwFileSize, &dwRead, NULL);
  944 +
  945 + if (dwRead != dwFileSize)
  946 + {
  947 + ErrorReporter("file err!\r\n");
  948 + userAborting =FALSE;
  949 + fAborting = TRUE;
  950 + }
  951 +
  952 + err = fileCheck(lpfileBuf,dwFileSize);
  953 +
  954 + if (err == WRONG_FILE_FORMAT)
  955 + {
  956 + ErrorReporter("wrong file format!");
  957 + userAborting =FALSE;
  958 + fAborting = TRUE;
  959 + }
  960 + else if (err == CHECKSUM_ERROR)
  961 + {
  962 + ErrorReporter("check sum err!");
  963 + userAborting =FALSE;
  964 + fAborting = TRUE;
  965 + }
  966 + else if (err == READ_CPU_TICKS_ERR)
  967 + {
  968 + ErrorReporter("read cpu ticks error!");
  969 + userAborting =FALSE;
  970 + fAborting = TRUE;
  971 + }
  972 +
  973 +
  974 +
  975 + if (WaitForSingleObject(hTransferAbortEvent, 0) == WAIT_OBJECT_0)
  976 + fAborting = TRUE;
  977 +
  978 + // inform writer thread that a file is about to be transferred
  979 + if (!fAborting) {
  980 + if (!WriterAddNewNode(WRITE_FILESTART, dwFileSize, 0, NULL, NULL, NULL))
  981 + fAborting = TRUE;
  982 +
  983 + }
  984 +
  985 + OutputDebugString("Xfer: About to start sending data\n");
  986 +
  987 + // Get Transfer Start Time
  988 + dwStartTime = GetTickCount();
  989 +
  990 + while (!fAborting) {
  991 + PWRITEREQUEST pWrite;
  992 + char * lpDataBuf;
  993 +
  994 + // transfer file, loop until all blocks of file have been read
  995 + lpDataBuf = HeapAlloc(hDataHeap, 0, dwPacketSize);
  996 + pWrite = HeapAlloc(ghWriterHeap, 0, sizeof(WRITEREQUEST));
  997 +
  998 + if ((lpDataBuf != NULL) && (pWrite != NULL)) {
  999 +
  1000 + DWORD wrLen;
  1001 +
  1002 + // read from file into new buffer
  1003 + //if (ReadFile(hFileHandle, lpDataBuf, dwPacketSize, &dwRead, NULL)) {
  1004 + if (dwRead > dwPacketSize){
  1005 + memcpy(lpDataBuf,pRead,dwPacketSize);
  1006 + WriterAddExistingNode(pWrite, WRITE_FILE, dwPacketSize, 0, lpDataBuf, hDataHeap, hWndProgress);
  1007 + dwRead -= dwPacketSize;
  1008 + pRead += dwPacketSize;
  1009 + }
  1010 + else{
  1011 + memcpy(lpDataBuf,pRead,dwRead);
  1012 + WriterAddExistingNode(pWrite, WRITE_FILE, dwRead, 0, lpDataBuf, hDataHeap, hWndProgress);
  1013 + // eof
  1014 + break;
  1015 + }
  1016 + }
  1017 + else {
  1018 + BOOL fRes;
  1019 + /*
  1020 + Either the data heap is full, or the writer heap is full.
  1021 + Free any allocated block, wait a little and try again.
  1022 +
  1023 + Waiting lets the writer thread send some blocks and free
  1024 + the data blocks from the data heap and the control
  1025 + blocks from the writer heap.
  1026 + */
  1027 + if (lpDataBuf) {
  1028 + EnterCriticalSection(&gcsDataHeap);
  1029 + fRes = HeapFree(hDataHeap, 0, lpDataBuf);
  1030 + LeaveCriticalSection(&gcsDataHeap);
  1031 + if (!fRes)
  1032 + ErrorReporter("HeapFree (Data block)");
  1033 + }
  1034 +
  1035 + if (pWrite) {
  1036 + EnterCriticalSection(&gcsWriterHeap);
  1037 + fRes = HeapFree(ghWriterHeap, 0, pWrite);
  1038 + LeaveCriticalSection(&gcsWriterHeap);
  1039 + if (!fRes)
  1040 + ErrorReporter("HeapFree (Writer block)");
  1041 + }
  1042 +
  1043 + OutputDebugString("Xfer: A heap is full. Waiting...\n");
  1044 +
  1045 + // wait a little
  1046 + // check for abort during the wait
  1047 + if (WaitForSingleObject(hTransferAbortEvent, 200) == WAIT_OBJECT_0)
  1048 + fAborting = TRUE;
  1049 + }
  1050 +
  1051 + // has the user aborted?
  1052 + if (WaitForSingleObject(hTransferAbortEvent, 0) == WAIT_OBJECT_0)
  1053 + fAborting = TRUE;
  1054 + }
  1055 +
  1056 + if (lpfileBuf) {
  1057 + BOOL fRes;
  1058 +
  1059 + EnterCriticalSection(&gcsDataHeap);
  1060 + fRes = HeapFree(hDataHeap, 0, lpfileBuf);
  1061 + LeaveCriticalSection(&gcsDataHeap);
  1062 + if (!fRes)
  1063 + ErrorReporter("HeapFree (Data block)");
  1064 + }
  1065 +
  1066 + OutputDebugString("Xfer: Done sending packets.\n");
  1067 +
  1068 + if (fAborting) {
  1069 + // inform writer that transfer is aborting
  1070 +
  1071 + OutputDebugString("Xfer: Sending Abort Packet to writer\n");
  1072 + WriterAddFirstNodeTimeout(WRITE_ABORT, dwFileSize, 0, NULL, NULL, NULL, 500);
  1073 + }
  1074 + else
  1075 + WriterAddNewNodeTimeout(WRITE_FILEEND, dwFileSize, 0, NULL, NULL, NULL, 500);
  1076 +
  1077 + {
  1078 + // wait til writer thread finishes with all blocks
  1079 + HANDLE hEvents[2];
  1080 + DWORD dwRes;
  1081 + BOOL fTransferComplete;
  1082 +
  1083 + hEvents[0] = ghTransferCompleteEvent;
  1084 + hEvents[1] = hTransferAbortEvent;
  1085 +
  1086 + OutputDebugString("Xfer: Waiting for transfer complete signal from writer\n");
  1087 + do {
  1088 + ResetEvent(hTransferAbortEvent);
  1089 +
  1090 + dwRes = WaitForMultipleObjects(2, hEvents, FALSE, INFINITE);
  1091 + switch(dwRes) {
  1092 + case WAIT_OBJECT_0:
  1093 + fTransferComplete = TRUE;
  1094 + OutputDebugString("Transfer complete signal rec'd\n");
  1095 + break;
  1096 + case WAIT_OBJECT_0 + 1:
  1097 + fAborting = TRUE;
  1098 + OutputDebugString("Transfer abort signal rec'd\n");
  1099 + OutputDebugString("Xfer: Sending Abort Packet to writer\n");
  1100 + if (!WriterAddFirstNodeTimeout(WRITE_ABORT, dwFileSize, 0, NULL, NULL, NULL, 500))
  1101 + ErrorReporter("Can't add abort packet\n");
  1102 + break;
  1103 + case WAIT_TIMEOUT: break;
  1104 + default:
  1105 + ErrorReporter("WaitForMultipleObjects(Transfer Complete Event and Transfer Abort Event)");
  1106 + fTransferComplete = TRUE;
  1107 + break;
  1108 + }
  1109 + } while (!fTransferComplete);
  1110 + }
  1111 +
  1112 + OutputDebugString("Xfer: transfer complete\n");
  1113 +
  1114 + // report statistics
  1115 + if (!fAborting)
  1116 + ShowTransferStatistics(GetTickCount(), dwStartTime, dwFileSize);
  1117 +
  1118 + // break down metrics
  1119 + PostMessage(hWndProgress, PBM_SETPOS, 0, 0);
  1120 +
  1121 + // break down heaps
  1122 + if (hDataHeap != NULL) {
  1123 + if (!HeapDestroy(hDataHeap))
  1124 + ErrorReporter("HeapDestroy (data heap)");
  1125 + }
  1126 +
  1127 + // If I am done without user intervention, then post the
  1128 + // "abort" message myself. This will cause the main thread to
  1129 + // clean up after the file transfer.
  1130 + if ((!fAborting)|| (!userAborting))
  1131 + {
  1132 + PostMessage(ghwndMain, WM_COMMAND, ID_TRANSFER_ABORTSENDING, 0);
  1133 + }
  1134 +
  1135 + // exit thread
  1136 +
  1137 + return 0;
  1138 +}
  1139 +
... ...
  1 +
  2 +/*-----------------------------------------------------------------------------
  3 + This is a part of the Microsoft Source Code Samples.
  4 + Copyright (C) 1995 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 + MODULE: TTYINFO.h
  12 +
  13 + PURPOSE: Contains global definitions for the TTYINFO structure
  14 +
  15 +-----------------------------------------------------------------------------*/
  16 +
  17 +//
  18 +// constant definitions
  19 +//
  20 +
  21 +//
  22 +// hard coded maximum number of ports
  23 +//
  24 +#define MAXPORTS 32
  25 +
  26 +//
  27 +// terminal size
  28 +//
  29 +#define MAXROWS 50
  30 +#define MAXCOLS 80
  31 +
  32 +//
  33 +// cursor states
  34 +//
  35 +#define CS_HIDE 0x00
  36 +#define CS_SHOW 0x01
  37 +
  38 +//
  39 +// ascii definitions
  40 +//
  41 +#define ASCII_BEL 0x07
  42 +#define ASCII_BS 0x08
  43 +#define ASCII_LF 0x0A
  44 +#define ASCII_CR 0x0D
  45 +#define ASCII_XON 0x11
  46 +#define ASCII_XOFF 0x13
  47 +
  48 +//
  49 +// data structures
  50 +//
  51 +struct TTYInfoStruct
  52 +{
  53 + HANDLE hCommPort, hReaderStatus, hWriter ;
  54 + DWORD dwEventFlags;
  55 + CHAR Screen[MAXCOLS * MAXROWS];
  56 + CHAR chFlag, chXON, chXOFF;
  57 + WORD wXONLimit, wXOFFLimit;
  58 + DWORD fRtsControl;
  59 + DWORD fDtrControl;
  60 + BOOL fConnected, fTransferring, fRepeating,
  61 + fLocalEcho, fNewLine,
  62 + fDisplayErrors, fAutowrap,
  63 + fCTSOutFlow, fDSROutFlow, fDSRInFlow,
  64 + fXonXoffOutFlow, fXonXoffInFlow,
  65 + fTXafterXoffSent,
  66 + fNoReading, fNoWriting, fNoEvents, fNoStatus,
  67 + fDisplayTimeouts;
  68 + BYTE bPort, bByteSize, bParity, bStopBits ;
  69 + DWORD dwBaudRate ;
  70 + WORD wCursorState ;
  71 + HFONT hTTYFont ;
  72 + LOGFONT lfTTYFont ;
  73 + DWORD rgbFGColor ;
  74 + COMMTIMEOUTS timeoutsorig;
  75 + COMMTIMEOUTS timeoutsnew;
  76 + int xSize, ySize, xScroll, yScroll, xOffset, yOffset,
  77 + nColumn, nRow, xChar, yChar , nCharPos;
  78 +
  79 +} TTYInfo;
  80 +
  81 +//
  82 +// macros ( for easier readability )
  83 +//
  84 +#define COMDEV( x ) (x.hCommPort)
  85 +#define CURSORSTATE( x ) (x.wCursorState)
  86 +#define PORT( x ) (x.bPort)
  87 +#define SCREEN( x ) (x.Screen)
  88 +#define CONNECTED( x ) (x.fConnected)
  89 +#define TRANSFERRING( x ) (x.fTransferring)
  90 +#define REPEATING( x ) (x.fRepeating)
  91 +#define LOCALECHO( x ) (x.fLocalEcho)
  92 +#define NEWLINE( x ) (x.fNewLine)
  93 +#define AUTOWRAP( x ) (x.fAutowrap)
  94 +#define BYTESIZE( x ) (x.bByteSize)
  95 +#define PARITY( x ) (x.bParity)
  96 +#define STOPBITS( x ) (x.bStopBits)
  97 +#define BAUDRATE( x ) (x.dwBaudRate)
  98 +#define HTTYFONT( x ) (x.hTTYFont)
  99 +#define LFTTYFONT( x ) (x.lfTTYFont)
  100 +#define FGCOLOR( x ) (x.rgbFGColor)
  101 +#define XSIZE( x ) (x.xSize)
  102 +#define YSIZE( x ) (x.ySize)
  103 +#define XSCROLL( x ) (x.xScroll)
  104 +#define YSCROLL( x ) (x.yScroll)
  105 +#define XOFFSET( x ) (x.xOffset)
  106 +#define YOFFSET( x ) (x.yOffset)
  107 +#define COLUMN( x ) (x.nColumn)
  108 +#define ROW( x ) (x.nRow)
  109 +#define XCHAR( x ) (x.xChar)
  110 +#define YCHAR( x ) (x.yChar)
  111 +#define DISPLAYERRORS( x ) (x.fDisplayErrors)
  112 +#define TIMEOUTSORIG( x ) (x.timeoutsorig)
  113 +#define TIMEOUTSNEW( x ) (x.timeoutsnew)
  114 +#define WRITERTHREAD( x ) (x.hWriter)
  115 +#define READSTATTHREAD( x ) (x.hReaderStatus)
  116 +#define EVENTFLAGS( x ) (x.dwEventFlags)
  117 +#define FLAGCHAR( x ) (x.chFlag)
  118 +#define SCREENCHAR( x, col, row ) (x.Screen[row * MAXCOLS + col])
  119 +
  120 +#define DTRCONTROL( x ) (x.fDtrControl)
  121 +#define RTSCONTROL( x ) (x.fRtsControl)
  122 +#define XONCHAR( x ) (x.chXON)
  123 +#define XOFFCHAR( x ) (x.chXOFF)
  124 +#define XONLIMIT( x ) (x.wXONLimit)
  125 +#define XOFFLIMIT( x ) (x.wXOFFLimit)
  126 +#define CTSOUTFLOW( x ) (x.fCTSOutFlow)
  127 +#define DSROUTFLOW( x ) (x.fDSROutFlow)
  128 +#define DSRINFLOW( x ) (x.fDSRInFlow)
  129 +#define XONXOFFOUTFLOW( x ) (x.fXonXoffOutFlow)
  130 +#define XONXOFFINFLOW( x ) (x.fXonXoffInFlow)
  131 +#define TXAFTERXOFFSENT(x) (x.fTXafterXoffSent)
  132 +
  133 +#define NOREADING( x ) (x.fNoReading)
  134 +#define NOWRITING( x ) (x.fNoWriting)
  135 +#define NOEVENTS( x ) (x.fNoEvents)
  136 +#define NOSTATUS( x ) (x.fNoStatus)
  137 +#define SHOWTIMEOUTS( x ) (x.fDisplayTimeouts)
  138 +
  139 +//---------------------------------------------------------------------------
  140 +// End of File: ttyinfo.h
  141 +//---------------------------------------------------------------------------
... ...
1 1 B<!DOCTYPE html>
... ...
  1 +/*-----------------------------------------------------------------------------
  2 + This is a part of the Microsoft Source Code Samples.
  3 + Copyright (C) 1995 Microsoft Corporation.
  4 + All rights reserved.
  5 + This source code is only intended as a supplement to
  6 + Microsoft Development Tools and/or WinHelp documentation.
  7 + See these sources for detailed information regarding the
  8 + Microsoft samples programs.
  9 +
  10 + MODULE: Writer.c
  11 +
  12 + PURPOSE: Handles all port writing and write request linked list
  13 +
  14 + FUNCTIONS:
  15 + WriterProc - Thread procedure handles all writing
  16 + HandleWriteRequests - calls writing procedures based on write request type
  17 + WriterTerminate - sets the transfer complete event
  18 + WriterFile - Writes a file transfer packet out the port
  19 + WriterFileStart - initializes a file transfer
  20 + WriterChar - Writes a char out the port
  21 + WriterGeneric - Actual writing funciton handles all i/o operations
  22 + WriterAddNewNode - Adds new write request packet to linked list
  23 + WriterAddNewNodeTimeout - Adds new node, but can timeout.
  24 + WriterAddExistingNode - Modifies an existing packet and
  25 + links it to the linked list
  26 + AddToLinkedList - Adds the node to the list
  27 + RemoveFromLinkedList - Removes a node
  28 +
  29 +-----------------------------------------------------------------------------*/
  30 +
  31 +/*-----------------------------------------------------------------------------
  32 +
  33 + Write request packets are put into the writer request linked list
  34 + and processed by the functions in this module.
  35 +
  36 + The members of the WRITEREQUEST structure are described as follows:
  37 +
  38 + DWORD dwWriteType; // dictates the type of request
  39 + DWORD dwSize; // size of data to write
  40 + char ch; // character to send
  41 + char * lpBuf; // address of data buffer
  42 + HANDLE hHeap; // heap containing data buffer
  43 + HWND hWndProgress; // hwnd for progress indicator
  44 +
  45 +
  46 + dwWriteType can be one of the following values:
  47 +
  48 + WRITE_CHAR 0x01 // indicates the request is for sending a single character
  49 +
  50 + WriteRequest.ch contains the character to send
  51 +
  52 +
  53 + WRITE_FILE 0x02 // indicates the request is for a file transfer
  54 +
  55 + WriteRequest.dwSize : contains the size of the buffer
  56 + WriteReqeust.lpBuf : points to the buffer containing the data to send
  57 + WriteRequest.hHeap : contains the handle of the heap containing the data buffer
  58 + WriteReqeust.hWndProgress : contains the hwnd of the file transfer progress indicator
  59 +
  60 +
  61 + WRITE_FILESTART 0x03 // indicates the a file transfer is starting
  62 +
  63 + WriteRequest.dwSize : indicates the total size of the file
  64 +
  65 +
  66 + WRITE_FILEEND 0x04 // indicates the last block in a file transfer
  67 +
  68 +
  69 + WRITE_ABORT 0x05 // indicates the file transfer is aborted
  70 +
  71 + WRITE_BLOCK 0x06 // indicates the request is for sending
  72 + // a block of data
  73 + WriteRequest.dwSize : containst the size of the buffer
  74 + WriteRequest.lpBuf : points to the buffer containing the data to send
  75 +
  76 +
  77 +-----------------------------------------------------------------------------*/
  78 +
  79 +#include <windows.h>
  80 +#include <commctrl.h>
  81 +
  82 +#include "MTTTY.h"
  83 +
  84 +//
  85 +// Prototypes for function called only within this file
  86 +//
  87 +PWRITEREQUEST RemoveFromLinkedList( PWRITEREQUEST );
  88 +BOOL WriterAddExistingNode( PWRITEREQUEST, DWORD, DWORD, char, char *, HANDLE, HWND );
  89 +BOOL WriterAddNewNode( DWORD, DWORD, char, char *, HANDLE, HWND );
  90 +void HandleWriteRequests( void );
  91 +void WriterFileStart( DWORD );
  92 +void WriterComplete( void );
  93 +void WriterAbort( PWRITEREQUEST );
  94 +void AddToLinkedList( PWRITEREQUEST );
  95 +void AddToFrontOfLinkedList( PWRITEREQUEST );
  96 +void WriterGeneric( char *, DWORD );
  97 +void WriterFile( PWRITEREQUEST );
  98 +void WriterChar( PWRITEREQUEST );
  99 +void WriterBlock( PWRITEREQUEST );
  100 +
  101 +
  102 +/*-----------------------------------------------------------------------------
  103 +
  104 +FUNCTION: WriterProc(LPVOID)
  105 +
  106 +PURPOSE: Thread function controls console input and comm port writing
  107 +
  108 +HISTORY: Date: Author: Comment:
  109 + 10/27/95 AllenD Wrote it
  110 +
  111 +-----------------------------------------------------------------------------*/
  112 +DWORD WINAPI WriterProc(LPVOID lpV)
  113 +{
  114 + SYSTEM_INFO sysInfo;
  115 + HANDLE hArray[2];
  116 + DWORD dwRes;
  117 + DWORD dwSize;
  118 + BOOL fDone = FALSE;
  119 +
  120 + //
  121 + // create a heap for WRITE_REQUEST packets
  122 + //
  123 + GetSystemInfo(&sysInfo);
  124 + ghWriterHeap = HeapCreate(0, sysInfo.dwPageSize*2, sysInfo.dwPageSize*4);
  125 + if (ghWriterHeap == NULL)
  126 + ErrorInComm("HeapCreate (write request heap)");
  127 +
  128 + //
  129 + // create synchronization events for write requests and file transfers
  130 + //
  131 + ghWriterEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  132 + if (ghWriterEvent == NULL)
  133 + ErrorInComm("CreateEvent(writ request event)");
  134 +
  135 + ghTransferCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  136 + if (ghTransferCompleteEvent == NULL)
  137 + ErrorInComm("CreateEvent(transfer complete event)");
  138 +
  139 + //
  140 + // initialize write request linked list
  141 + //
  142 + dwSize = sizeof(WRITEREQUEST);
  143 + gpWriterHead = HeapAlloc(ghWriterHeap, HEAP_ZERO_MEMORY, dwSize);
  144 + gpWriterTail = HeapAlloc(ghWriterHeap, HEAP_ZERO_MEMORY, dwSize);
  145 + gpWriterHead->pNext = gpWriterTail;
  146 + gpWriterTail->pPrev = gpWriterHead;
  147 +
  148 + hArray[0] = ghWriterEvent;
  149 + hArray[1] = ghThreadExitEvent;
  150 +
  151 + while ( !fDone ) {
  152 +
  153 + dwRes = WaitForMultipleObjects(2, hArray, FALSE, WRITE_CHECK_TIMEOUT);
  154 + switch(dwRes)
  155 + {
  156 + case WAIT_TIMEOUT:
  157 + break;
  158 +
  159 + case WAIT_FAILED:
  160 + ErrorReporter("WaitForMultipleObjects( writer proc )");
  161 + break;
  162 +
  163 + //
  164 + // write request event
  165 + //
  166 + case WAIT_OBJECT_0:
  167 + HandleWriteRequests();
  168 + break;
  169 + //
  170 + // thread exit event
  171 + //
  172 + case WAIT_OBJECT_0 + 1:
  173 + fDone = TRUE;
  174 + break;
  175 + }
  176 + }
  177 +
  178 + CloseHandle(ghTransferCompleteEvent);
  179 + CloseHandle(ghWriterEvent);
  180 +
  181 + //
  182 + // Destroy WRITE_REQUEST heap
  183 + //
  184 + HeapDestroy(ghWriterHeap);
  185 + return 1;
  186 +}
  187 +
  188 +/*-----------------------------------------------------------------------------
  189 +
  190 +FUNCTION: HandleWriteRequests
  191 +
  192 +PURPOSE: Retrieves write request and calls the proper function
  193 + depending on the write request type.
  194 +
  195 +HISTORY: Date: Author: Comment:
  196 + 10/27/95 AllenD Wrote it
  197 +
  198 + 5/25/96 AllenD Modified to include
  199 +
  200 +-----------------------------------------------------------------------------*/
  201 +void HandleWriteRequests()
  202 +{
  203 + PWRITEREQUEST pWrite;
  204 + BOOL fRes;
  205 +
  206 + pWrite = gpWriterHead->pNext;
  207 +
  208 + while(pWrite != gpWriterTail) {
  209 + switch(pWrite->dwWriteType)
  210 + {
  211 + case WRITE_CHAR: WriterChar(pWrite); break;
  212 +
  213 + case WRITE_FILESTART: WriterFileStart(pWrite->dwSize); break;
  214 +
  215 + case WRITE_FILE: WriterFile(pWrite);
  216 + //
  217 + // free data block
  218 + //
  219 + EnterCriticalSection(&gcsDataHeap);
  220 + fRes = HeapFree(pWrite->hHeap, 0, pWrite->lpBuf);
  221 + LeaveCriticalSection(&gcsDataHeap);
  222 + if (!fRes)
  223 + ErrorReporter("HeapFree(file transfer buffer)");
  224 + break;
  225 +
  226 + case WRITE_FILEEND: WriterComplete(); break;
  227 +
  228 + case WRITE_ABORT: WriterAbort(pWrite); break;
  229 +
  230 + case WRITE_BLOCK: WriterBlock(pWrite); break;
  231 +
  232 + default: ErrorReporter("Bad write request");
  233 + break;
  234 + }
  235 +
  236 + //
  237 + // remove current node and get next node
  238 + //
  239 + pWrite = RemoveFromLinkedList(pWrite);
  240 + pWrite = gpWriterHead->pNext;
  241 + }
  242 +
  243 + return;
  244 +}
  245 +
  246 +/*-----------------------------------------------------------------------------
  247 +
  248 +FUNCTION: WriterComplete
  249 +
  250 +PURPOSE: Handle an transfer completion
  251 +
  252 +HISTORY: Date: Author: Comment:
  253 + 1/26/96 AllenD Wrote it
  254 +
  255 +-----------------------------------------------------------------------------*/
  256 +void WriterComplete()
  257 +{
  258 + if (!SetEvent(ghTransferCompleteEvent))
  259 + ErrorReporter("SetEvent (transfer complete event)");
  260 +
  261 + return;
  262 +}
  263 +
  264 +/*-----------------------------------------------------------------------------
  265 +
  266 +FUNCTION: WriterAbort
  267 +
  268 +PURPOSE: Handle an transfer abort. Delete all writer packets.
  269 + Data packets get deleted with the entire data heap in the transfer
  270 + thread.
  271 +
  272 +HISTORY: Date: Author: Comment:
  273 + 1/26/96 AllenD Wrote it
  274 +
  275 +-----------------------------------------------------------------------------*/
  276 +void WriterAbort(PWRITEREQUEST pAbortNode)
  277 +{
  278 + PWRITEREQUEST pCurrent;
  279 + PWRITEREQUEST pNextNode;
  280 + BOOL fRes = TRUE;
  281 + int i = 0;
  282 + char szMessage[30];
  283 +
  284 + EnterCriticalSection(&gcsWriterHeap);
  285 + // remove all nodes after me
  286 + pCurrent = pAbortNode->pNext;
  287 +
  288 + while (pCurrent != gpWriterTail) {
  289 + pNextNode = pCurrent->pNext;
  290 + fRes = HeapFree(ghWriterHeap, 0, pCurrent);
  291 + if (!fRes)
  292 + break;
  293 + i++;
  294 + pCurrent = pNextNode;
  295 + }
  296 +
  297 + pAbortNode->pNext = gpWriterTail;
  298 + gpWriterTail->pPrev = pAbortNode;
  299 + LeaveCriticalSection(&gcsWriterHeap);
  300 +
  301 + wsprintf(szMessage, "%d packets ignored.\n", i);
  302 + OutputDebugString(szMessage);
  303 +
  304 + if (!fRes)
  305 + ErrorReporter("HeapFree (Writer heap)");
  306 +
  307 + if (!SetEvent(ghTransferCompleteEvent))
  308 + ErrorReporter("SetEvent (transfer complete event)");
  309 +
  310 + return;
  311 +}
  312 +
  313 +
  314 +/*-----------------------------------------------------------------------------
  315 +
  316 +FUNCTION: WriterFile(PWRITEREQUEST)
  317 +
  318 +PURPOSE: Handles a file transfer request
  319 +
  320 +PARAMETERS:
  321 + pWrite - pointer to write request packet
  322 +
  323 +COMMENTS: WRITEREQUEST packet contains the following:
  324 + lpBuf : Address of data buffer
  325 + dwSize : size of data buffer
  326 + hWndProgress: hwnd of progress indicator
  327 + hHeap : handle to heap which contains the data buffer
  328 +
  329 +HISTORY: Date: Author: Comment:
  330 + 10/27/95 AllenD Wrote it
  331 +
  332 +-----------------------------------------------------------------------------*/
  333 +void WriterFile(PWRITEREQUEST pWrite)
  334 +{
  335 + WriterGeneric(pWrite->lpBuf, pWrite->dwSize);
  336 +
  337 + //
  338 + // update progress indicator (even if aborting)
  339 + //
  340 + if (!PostMessage(pWrite->hWndProgress, PBM_STEPIT, 0, 0))
  341 + ErrorReporter("PostMessage (file transfer status)");
  342 +
  343 + return;
  344 +}
  345 +
  346 +/*-----------------------------------------------------------------------------
  347 +
  348 +FUNCTION: WriterBlock(PWRITEREQUEST)
  349 +
  350 +PURPOSE: Sends a block of characters
  351 +
  352 +PARAMETERS:
  353 + pWrite - pointer to write request packet
  354 +
  355 +COMMENTS: WRITEREQUEST packet contains the following:
  356 + lpBuf : Address of data buffer
  357 + dwSize : size of data buffer
  358 +
  359 +HISTORY: Date: Author: Comment:
  360 + 1/29/96 AllenD Wrote it
  361 +
  362 +-----------------------------------------------------------------------------*/
  363 +void WriterBlock(PWRITEREQUEST pWrite)
  364 +{
  365 +
  366 + WriterGeneric(pWrite->lpBuf, pWrite->dwSize);
  367 + return;
  368 +}
  369 +
  370 +/*-----------------------------------------------------------------------------
  371 +
  372 +FUNCTION: WriterFileStart(DWORD)
  373 +
  374 +PURPOSE: Initializes a file transfer (send)
  375 +
  376 +PARAMETER:
  377 + dwFileSize - not used
  378 +
  379 +COMMENTS: Provided to do any special initializations for transfer
  380 +
  381 +HISTORY: Date: Author: Comment:
  382 + 10/27/95 AllenD Wrote it
  383 + 11/20/95 AllenD Took out all test code
  384 +
  385 +-----------------------------------------------------------------------------*/
  386 +void WriterFileStart(DWORD dwFileSize)
  387 +{
  388 + return;
  389 +}
  390 +
  391 +/*-----------------------------------------------------------------------------
  392 +
  393 +FUNCTION: WriterChar(PWRITEREQUEST)
  394 +
  395 +PURPOSE: Handles sending characters
  396 +
  397 +PARAMETER:
  398 + pWrite - pointer to write request packet
  399 +
  400 +COMMENTS: WRITEREQUEST packet contains the following:
  401 + ch : character to send
  402 +
  403 +HISTORY: Date: Author: Comment:
  404 + 10/27/95 AllenD Wrote it
  405 +
  406 +-----------------------------------------------------------------------------*/
  407 +void WriterChar(PWRITEREQUEST pWrite)
  408 +{
  409 + WriterGeneric(&(pWrite->ch), 1);
  410 + return;
  411 +}
  412 +
  413 +/*-----------------------------------------------------------------------------
  414 +
  415 +FUNCTION: WriterGeneric(char *, DWORD)
  416 +
  417 +PURPOSE: Handles sending all types of data
  418 +
  419 +PARAMETER:
  420 + lpBuf - pointer to data buffer
  421 + dwToWrite - size of buffer
  422 +
  423 +HISTORY: Date: Author: Comment:
  424 + 10/27/95 AllenD Wrote it
  425 +
  426 +-----------------------------------------------------------------------------*/
  427 +void WriterGeneric(char * lpBuf, DWORD dwToWrite)
  428 +{
  429 + OVERLAPPED osWrite = {0};
  430 + HANDLE hArray[2];
  431 + DWORD dwWritten;
  432 + DWORD dwRes;
  433 +
  434 + //
  435 + // If no writing is allowed, then just return
  436 + //
  437 + if (NOWRITING(TTYInfo))
  438 + return ;
  439 +
  440 + //
  441 + // create this writes overlapped structure hEvent
  442 + //
  443 + osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
  444 + if (osWrite.hEvent == NULL)
  445 + ErrorInComm("CreateEvent (overlapped write hEvent)");
  446 +
  447 + hArray[0] = osWrite.hEvent;
  448 + hArray[1] = ghThreadExitEvent;
  449 +
  450 + //
  451 + // issue write
  452 + //
  453 + if (!WriteFile(COMDEV(TTYInfo), lpBuf, dwToWrite, &dwWritten, &osWrite)) {
  454 + if (GetLastError() == ERROR_IO_PENDING) {
  455 + //
  456 + // write is delayed
  457 + //
  458 + dwRes = WaitForMultipleObjects(2, hArray, FALSE, INFINITE);
  459 + switch(dwRes)
  460 + {
  461 + //
  462 + // write event set
  463 + //
  464 + case WAIT_OBJECT_0:
  465 + SetLastError(ERROR_SUCCESS);
  466 + if (!GetOverlappedResult(COMDEV(TTYInfo), &osWrite, &dwWritten, FALSE)) {
  467 + if (GetLastError() == ERROR_OPERATION_ABORTED)
  468 + UpdateStatus("Write aborted\r\n");
  469 + else
  470 + ErrorInComm("GetOverlappedResult(in Writer)");
  471 + }
  472 +
  473 + if (dwWritten != dwToWrite) {
  474 + if ((GetLastError() == ERROR_SUCCESS) && SHOWTIMEOUTS(TTYInfo))
  475 + UpdateStatus("Write timed out. (overlapped)\r\n");
  476 + else
  477 + ErrorReporter("Error writing data to port (overlapped)");
  478 + }
  479 + break;
  480 +
  481 + //
  482 + // thread exit event set
  483 + //
  484 + case WAIT_OBJECT_0 + 1:
  485 + break;
  486 +
  487 + //
  488 + // wait timed out
  489 + //
  490 + case WAIT_TIMEOUT:
  491 + UpdateStatus("Wait Timeout in WriterGeneric.\r\n");
  492 + break;
  493 +
  494 + case WAIT_FAILED:
  495 + default: ErrorInComm("WaitForMultipleObjects (WriterGeneric)");
  496 + break;
  497 + }
  498 + }
  499 + else
  500 + //
  501 + // writefile failed, but it isn't delayed
  502 + //
  503 + ErrorInComm("WriteFile (in Writer)");
  504 + }
  505 + else {
  506 + //
  507 + // writefile returned immediately
  508 + //
  509 + if (dwWritten != dwToWrite)
  510 + UpdateStatus("Write timed out. (immediate)\r\n");
  511 + }
  512 +
  513 + CloseHandle(osWrite.hEvent);
  514 +
  515 + return;
  516 +}
  517 +
  518 +/*-----------------------------------------------------------------------------
  519 +
  520 +FUNCTION: WriterAddNewNode(DWORD, DWORD, char, char *, HANDLE, HWND)
  521 +
  522 +PURPOSE: Adds a new write request packet
  523 +
  524 +PARAMETERS:
  525 + dwRequestType - write request packet request type
  526 + dwSize - size of write request
  527 + ch - character to write
  528 + lpBuf - address of buffer to write
  529 + hHeap - heap handle of data buffer
  530 + hProgress - hwnd of transfer progress bar
  531 +
  532 +RETURN:
  533 + TRUE if node is added to linked list
  534 + FALSE if node can't be allocated.
  535 +
  536 +COMMENTS: Allocates a new packet and fills it based on the
  537 + parameters passed in.
  538 +
  539 +HISTORY: Date: Author: Comment:
  540 + 10/27/95 AllenD Wrote it
  541 +
  542 +-----------------------------------------------------------------------------*/
  543 +BOOL WriterAddNewNode( DWORD dwRequestType,
  544 + DWORD dwSize,
  545 + char ch,
  546 + char * lpBuf,
  547 + HANDLE hHeap,
  548 + HWND hProgress)
  549 +{
  550 + PWRITEREQUEST pWrite;
  551 +
  552 + //
  553 + // allocate new packet
  554 + //
  555 + pWrite = HeapAlloc(ghWriterHeap, 0, sizeof(WRITEREQUEST));
  556 + if (pWrite == NULL) {
  557 + ErrorReporter("HeapAlloc (writer packet)");
  558 + return FALSE;
  559 + }
  560 +
  561 + //
  562 + // assign packet info
  563 + //
  564 + pWrite->dwWriteType = dwRequestType;
  565 + pWrite->dwSize = dwSize;
  566 + pWrite->ch = ch;
  567 + pWrite->lpBuf = lpBuf;
  568 + pWrite->hHeap = hHeap;
  569 + pWrite->hWndProgress = hProgress;
  570 +
  571 + AddToLinkedList(pWrite);
  572 +
  573 + return TRUE;
  574 +}
  575 +
  576 +/*-----------------------------------------------------------------------------
  577 +
  578 +FUNCTION: WriterAddNewNodeTimeout(DWORD, DWORD, char, char *,
  579 + HANDLE, HWND, DWORD)
  580 +
  581 +PURPOSE: Adds a new write request packet, timesout if can't allocate packet.
  582 +
  583 +PARAMETERS:
  584 + dwRequestType - write request packet request type
  585 + dwSize - size of write request
  586 + ch - character to write
  587 + lpBuf - address of buffer to write
  588 + hHeap - heap handle of data buffer
  589 + hProgress - hwnd of transfer progress bar
  590 + dwTimeout - timeout value for waiting
  591 +
  592 +RETURN:
  593 + TRUE if node is added to linked list
  594 + FALSE if node can't be allocated.
  595 +
  596 +COMMENTS: Allocates a new packet and fills it based on the
  597 + parameters passed in. If the first attemp to allocate packet
  598 + fails, then the function sleeps and tries again when it resumes.
  599 +
  600 +HISTORY: Date: Author: Comment:
  601 + 10/27/95 AllenD Wrote it
  602 +
  603 +-----------------------------------------------------------------------------*/
  604 +BOOL WriterAddNewNodeTimeout( DWORD dwRequestType,
  605 + DWORD dwSize,
  606 + char ch,
  607 + char * lpBuf,
  608 + HANDLE hHeap,
  609 + HWND hProgress,
  610 + DWORD dwTimeout )
  611 +{
  612 + PWRITEREQUEST pWrite;
  613 +
  614 + //
  615 + // attempt first allocation
  616 + //
  617 + pWrite = HeapAlloc(ghWriterHeap, 0, sizeof(WRITEREQUEST));
  618 + if (pWrite == NULL) {
  619 + Sleep(dwTimeout);
  620 + //
  621 + // attempt second allocation
  622 + //
  623 + pWrite = HeapAlloc(ghWriterHeap, 0, sizeof(WRITEREQUEST));
  624 + if (pWrite == NULL) {
  625 + ErrorReporter("HeapAlloc (writer packet)");
  626 + return FALSE;
  627 + }
  628 + }
  629 +
  630 + //
  631 + // assign packet info
  632 + //
  633 + pWrite->dwWriteType = dwRequestType;
  634 + pWrite->dwSize = dwSize;
  635 + pWrite->ch = ch;
  636 + pWrite->lpBuf = lpBuf;
  637 + pWrite->hHeap = hHeap;
  638 + pWrite->hWndProgress = hProgress;
  639 +
  640 + AddToLinkedList(pWrite);
  641 +
  642 + return TRUE;
  643 +}
  644 +
  645 +/*-----------------------------------------------------------------------------
  646 +
  647 +FUNCTION: WriterAddFirstNodeTimeout(DWORD, DWORD, char, char *,
  648 + HANDLE, HWND, DWORD)
  649 +
  650 +PURPOSE: Adds a new write request packet and places it at the front of the
  651 + list, timesout if can't allocate packet.
  652 +
  653 +PARAMETERS:
  654 + dwRequestType - write request packet request type
  655 + dwSize - size of write request
  656 + ch - character to write
  657 + lpBuf - address of buffer to write
  658 + hHeap - heap handle of data buffer
  659 + hProgress - hwnd of transfer progress bar
  660 + dwTimeout - timeout value for waiting
  661 +
  662 +RETURN:
  663 + TRUE if node is added to linked list
  664 + FALSE if node can't be allocated.
  665 +
  666 +COMMENTS: This function differs from WriterAddNewNodeTimeout only in that
  667 + it places the node at the front of the list.
  668 +
  669 +HISTORY: Date: Author: Comment:
  670 + 1/26/96 AllenD Wrote it
  671 +
  672 +-----------------------------------------------------------------------------*/
  673 +BOOL WriterAddFirstNodeTimeout( DWORD dwRequestType,
  674 + DWORD dwSize,
  675 + char ch,
  676 + char * lpBuf,
  677 + HANDLE hHeap,
  678 + HWND hProgress,
  679 + DWORD dwTimeout )
  680 +{
  681 + PWRITEREQUEST pWrite;
  682 +
  683 + //
  684 + // attempt first allocation
  685 + //
  686 + pWrite = HeapAlloc(ghWriterHeap, 0, sizeof(WRITEREQUEST));
  687 + if (pWrite == NULL) {
  688 + Sleep(dwTimeout);
  689 + //
  690 + // attempt second allocation
  691 + //
  692 + pWrite = HeapAlloc(ghWriterHeap, 0, sizeof(WRITEREQUEST));
  693 + if (pWrite == NULL) {
  694 + ErrorReporter("HeapAlloc (writer packet)");
  695 + return FALSE;
  696 + }
  697 + }
  698 +
  699 + //
  700 + // assign packet info
  701 + //
  702 + pWrite->dwWriteType = dwRequestType;
  703 + pWrite->dwSize = dwSize;
  704 + pWrite->ch = ch;
  705 + pWrite->lpBuf = lpBuf;
  706 + pWrite->hHeap = hHeap;
  707 + pWrite->hWndProgress = hProgress;
  708 +
  709 + AddToFrontOfLinkedList(pWrite);
  710 +
  711 + return TRUE;
  712 +}
  713 +
  714 +/*-----------------------------------------------------------------------------
  715 +
  716 +FUNCTION: WriterAddExistingNode
  717 +
  718 +PURPOSE: Adds a write request packet
  719 +
  720 +PARAMETERS:
  721 + dwRequestType - write request packet request type
  722 + dwSize - size of write request
  723 + ch - character to write
  724 + lpBuf - address of buffer to write
  725 + hHeap - heap handle of data buffer
  726 + hProgress - hwnd of transfer progress bar
  727 +
  728 +RETURN: always TRUE
  729 +
  730 +COMMENTS: Similar to WriterAddNewNode, except that the
  731 + memory has already been allocated.
  732 +
  733 +HISTORY: Date: Author: Comment:
  734 + 10/27/95 AllenD Wrote it
  735 +
  736 +-----------------------------------------------------------------------------*/
  737 +BOOL WriterAddExistingNode( PWRITEREQUEST pNode,
  738 + DWORD dwRequestType,
  739 + DWORD dwSize,
  740 + char ch,
  741 + char * lpBuf,
  742 + HANDLE hHeap,
  743 + HWND hProgress)
  744 +{
  745 + //
  746 + // assign packet info
  747 + //
  748 + pNode->dwWriteType = dwRequestType;
  749 + pNode->dwSize = dwSize;
  750 + pNode->ch = ch;
  751 + pNode->lpBuf = lpBuf;
  752 + pNode->hHeap = hHeap;
  753 + pNode->hWndProgress = hProgress;
  754 +
  755 + AddToLinkedList(pNode);
  756 +
  757 + return TRUE;
  758 +}
  759 +
  760 +/*-----------------------------------------------------------------------------
  761 +
  762 +FUNCTION: AddToLinkedList(PWRITEREQUEST)
  763 +
  764 +PURPOSE: Adds a node to the write request linked list
  765 +
  766 +PARAMETERS:
  767 + pNode - pointer to write request packet to add to linked list
  768 +
  769 +HISTORY: Date: Author: Comment:
  770 + 10/27/95 AllenD Wrote it
  771 +
  772 +-----------------------------------------------------------------------------*/
  773 +void AddToLinkedList(PWRITEREQUEST pNode)
  774 +{
  775 + PWRITEREQUEST pOldLast;
  776 + //
  777 + // add node to linked list
  778 + //
  779 + EnterCriticalSection(&gcsWriterHeap);
  780 +
  781 + pOldLast = gpWriterTail->pPrev;
  782 +
  783 + pNode->pNext = gpWriterTail;
  784 + pNode->pPrev = pOldLast;
  785 +
  786 + pOldLast->pNext = pNode;
  787 + gpWriterTail->pPrev = pNode;
  788 +
  789 + LeaveCriticalSection(&gcsWriterHeap);
  790 +
  791 + //
  792 + // notify writer thread that a node has been added
  793 + //
  794 + if (!SetEvent(ghWriterEvent))
  795 + ErrorReporter("SetEvent( writer packet )");
  796 +
  797 + return;
  798 +}
  799 +
  800 +/*-----------------------------------------------------------------------------
  801 +
  802 +FUNCTION: AddToFrontOfLinkedList(PWRITEREQUEST)
  803 +
  804 +PURPOSE: Adds a node to the front of the write request linked list
  805 +
  806 +PARAMETERS:
  807 + pNode - pointer to write request packet to add to linked list
  808 +
  809 +HISTORY: Date: Author: Comment:
  810 + 1/26/96 AllenD Wrote it
  811 +
  812 +-----------------------------------------------------------------------------*/
  813 +void AddToFrontOfLinkedList(PWRITEREQUEST pNode)
  814 +{
  815 + PWRITEREQUEST pNextNode;
  816 + //
  817 + // add node to linked list
  818 + //
  819 + EnterCriticalSection(&gcsWriterHeap);
  820 +
  821 + pNextNode = gpWriterHead->pNext;
  822 +
  823 + pNextNode->pPrev = pNode;
  824 + gpWriterHead->pNext = pNode;
  825 +
  826 + pNode->pNext = pNextNode;
  827 + pNode->pPrev = gpWriterHead;
  828 +
  829 + LeaveCriticalSection(&gcsWriterHeap);
  830 +
  831 + //
  832 + // notify writer thread that a node has been added
  833 + //
  834 + if (!SetEvent(ghWriterEvent))
  835 + ErrorReporter("SetEvent( writer packet )");
  836 +
  837 + return;
  838 +}
  839 +
  840 +/*-----------------------------------------------------------------------------
  841 +
  842 +FUNCTION: RemoveFromLinkedList(PWRITEREQUEST)
  843 +
  844 +PURPOSE: Deallocates the head node and makes the passed in node
  845 + the new head node.
  846 + Sets the head node point to node just after the passed in node.
  847 + Returns the node pointed to by the head node.
  848 +
  849 +PARAMETERS:
  850 + pNode - pointer to node to make the new head
  851 +
  852 +RETURN:
  853 + Pointer to next node. This will be NULL if there are no
  854 + more nodes in the list.
  855 +
  856 +HISTORY: Date: Author: Comment:
  857 + 10/27/95 AllenD Wrote it
  858 +
  859 +-----------------------------------------------------------------------------*/
  860 +PWRITEREQUEST RemoveFromLinkedList(PWRITEREQUEST pNode)
  861 +{
  862 + PWRITEREQUEST pNextNode;
  863 + PWRITEREQUEST pPrevNode;
  864 + BOOL bRes;
  865 +
  866 + EnterCriticalSection(&gcsWriterHeap);
  867 +
  868 + pNextNode = pNode->pNext;
  869 + pPrevNode = pNode->pPrev;
  870 +
  871 + bRes = HeapFree(ghWriterHeap, 0, pNode);
  872 +
  873 + pPrevNode->pNext = pNextNode;
  874 + pNextNode->pPrev = pPrevNode;
  875 +
  876 + LeaveCriticalSection(&gcsWriterHeap);
  877 +
  878 + if (!bRes)
  879 + ErrorReporter("HeapFree(write request)");
  880 +
  881 + return pNextNode; // return the freed node's pNext (maybe the tail)
  882 +}
  883 +
... ...
1   -// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
2   -
3   -// NOTE: Do not modify the contents of this file. If this class is regenerated by
4   -// Microsoft Visual C++, your modifications will be overwritten.
5   -
6   -
7   -#include "stdafx.h"
8   -#include "mscomm.h"
9   -
10   -/////////////////////////////////////////////////////////////////////////////
11   -// CMSComm
12   -
13   -IMPLEMENT_DYNCREATE(CMSComm, CWnd)
14   -
15   -/////////////////////////////////////////////////////////////////////////////
16   -// CMSComm properties
17   -
18   -/////////////////////////////////////////////////////////////////////////////
19   -// CMSComm operations
20   -
21   -void CMSComm::SetCDHolding(BOOL bNewValue)
22   -{
23   - static BYTE parms[] =
24   - VTS_BOOL;
25   - InvokeHelper(0x1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
26   - bNewValue);
27   -}
28   -
29   -BOOL CMSComm::GetCDHolding()
30   -{
31   - BOOL result;
32   - InvokeHelper(0x1, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
33   - return result;
34   -}
35   -
36   -void CMSComm::SetCommID(long nNewValue)
37   -{
38   - static BYTE parms[] =
39   - VTS_I4;
40   - InvokeHelper(0x3, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
41   - nNewValue);
42   -}
43   -
44   -long CMSComm::GetCommID()
45   -{
46   - long result;
47   - InvokeHelper(0x3, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
48   - return result;
49   -}
50   -
51   -void CMSComm::SetCommPort(short nNewValue)
52   -{
53   - static BYTE parms[] =
54   - VTS_I2;
55   - InvokeHelper(0x4, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
56   - nNewValue);
57   -}
58   -
59   -short CMSComm::GetCommPort()
60   -{
61   - short result;
62   - InvokeHelper(0x4, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
63   - return result;
64   -}
65   -
66   -void CMSComm::SetCTSHolding(BOOL bNewValue)
67   -{
68   - static BYTE parms[] =
69   - VTS_BOOL;
70   - InvokeHelper(0x5, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
71   - bNewValue);
72   -}
73   -
74   -BOOL CMSComm::GetCTSHolding()
75   -{
76   - BOOL result;
77   - InvokeHelper(0x5, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
78   - return result;
79   -}
80   -
81   -void CMSComm::SetDSRHolding(BOOL bNewValue)
82   -{
83   - static BYTE parms[] =
84   - VTS_BOOL;
85   - InvokeHelper(0x7, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
86   - bNewValue);
87   -}
88   -
89   -BOOL CMSComm::GetDSRHolding()
90   -{
91   - BOOL result;
92   - InvokeHelper(0x7, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
93   - return result;
94   -}
95   -
96   -void CMSComm::SetDTREnable(BOOL bNewValue)
97   -{
98   - static BYTE parms[] =
99   - VTS_BOOL;
100   - InvokeHelper(0x9, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
101   - bNewValue);
102   -}
103   -
104   -BOOL CMSComm::GetDTREnable()
105   -{
106   - BOOL result;
107   - InvokeHelper(0x9, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
108   - return result;
109   -}
110   -
111   -void CMSComm::SetHandshaking(long nNewValue)
112   -{
113   - static BYTE parms[] =
114   - VTS_I4;
115   - InvokeHelper(0xa, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
116   - nNewValue);
117   -}
118   -
119   -long CMSComm::GetHandshaking()
120   -{
121   - long result;
122   - InvokeHelper(0xa, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
123   - return result;
124   -}
125   -
126   -void CMSComm::SetInBufferSize(short nNewValue)
127   -{
128   - static BYTE parms[] =
129   - VTS_I2;
130   - InvokeHelper(0xb, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
131   - nNewValue);
132   -}
133   -
134   -short CMSComm::GetInBufferSize()
135   -{
136   - short result;
137   - InvokeHelper(0xb, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
138   - return result;
139   -}
140   -
141   -void CMSComm::SetInBufferCount(short nNewValue)
142   -{
143   - static BYTE parms[] =
144   - VTS_I2;
145   - InvokeHelper(0xc, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
146   - nNewValue);
147   -}
148   -
149   -short CMSComm::GetInBufferCount()
150   -{
151   - short result;
152   - InvokeHelper(0xc, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
153   - return result;
154   -}
155   -
156   -void CMSComm::SetBreak(BOOL bNewValue)
157   -{
158   - static BYTE parms[] =
159   - VTS_BOOL;
160   - InvokeHelper(0xd, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
161   - bNewValue);
162   -}
163   -
164   -BOOL CMSComm::GetBreak()
165   -{
166   - BOOL result;
167   - InvokeHelper(0xd, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
168   - return result;
169   -}
170   -
171   -void CMSComm::SetInputLen(short nNewValue)
172   -{
173   - static BYTE parms[] =
174   - VTS_I2;
175   - InvokeHelper(0xe, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
176   - nNewValue);
177   -}
178   -
179   -short CMSComm::GetInputLen()
180   -{
181   - short result;
182   - InvokeHelper(0xe, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
183   - return result;
184   -}
185   -
186   -void CMSComm::SetNullDiscard(BOOL bNewValue)
187   -{
188   - static BYTE parms[] =
189   - VTS_BOOL;
190   - InvokeHelper(0x10, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
191   - bNewValue);
192   -}
193   -
194   -BOOL CMSComm::GetNullDiscard()
195   -{
196   - BOOL result;
197   - InvokeHelper(0x10, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
198   - return result;
199   -}
200   -
201   -void CMSComm::SetOutBufferSize(short nNewValue)
202   -{
203   - static BYTE parms[] =
204   - VTS_I2;
205   - InvokeHelper(0x11, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
206   - nNewValue);
207   -}
208   -
209   -short CMSComm::GetOutBufferSize()
210   -{
211   - short result;
212   - InvokeHelper(0x11, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
213   - return result;
214   -}
215   -
216   -void CMSComm::SetOutBufferCount(short nNewValue)
217   -{
218   - static BYTE parms[] =
219   - VTS_I2;
220   - InvokeHelper(0x12, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
221   - nNewValue);
222   -}
223   -
224   -short CMSComm::GetOutBufferCount()
225   -{
226   - short result;
227   - InvokeHelper(0x12, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
228   - return result;
229   -}
230   -
231   -void CMSComm::SetParityReplace(LPCTSTR lpszNewValue)
232   -{
233   - static BYTE parms[] =
234   - VTS_BSTR;
235   - InvokeHelper(0x13, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
236   - lpszNewValue);
237   -}
238   -
239   -CString CMSComm::GetParityReplace()
240   -{
241   - CString result;
242   - InvokeHelper(0x13, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
243   - return result;
244   -}
245   -
246   -void CMSComm::SetPortOpen(BOOL bNewValue)
247   -{
248   - static BYTE parms[] =
249   - VTS_BOOL;
250   - InvokeHelper(0x14, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
251   - bNewValue);
252   -}
253   -
254   -BOOL CMSComm::GetPortOpen()
255   -{
256   - BOOL result;
257   - InvokeHelper(0x14, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
258   - return result;
259   -}
260   -
261   -void CMSComm::SetRThreshold(short nNewValue)
262   -{
263   - static BYTE parms[] =
264   - VTS_I2;
265   - InvokeHelper(0x15, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
266   - nNewValue);
267   -}
268   -
269   -short CMSComm::GetRThreshold()
270   -{
271   - short result;
272   - InvokeHelper(0x15, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
273   - return result;
274   -}
275   -
276   -void CMSComm::SetRTSEnable(BOOL bNewValue)
277   -{
278   - static BYTE parms[] =
279   - VTS_BOOL;
280   - InvokeHelper(0x16, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
281   - bNewValue);
282   -}
283   -
284   -BOOL CMSComm::GetRTSEnable()
285   -{
286   - BOOL result;
287   - InvokeHelper(0x16, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
288   - return result;
289   -}
290   -
291   -void CMSComm::SetSettings(LPCTSTR lpszNewValue)
292   -{
293   - static BYTE parms[] =
294   - VTS_BSTR;
295   - InvokeHelper(0x17, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
296   - lpszNewValue);
297   -}
298   -
299   -CString CMSComm::GetSettings()
300   -{
301   - CString result;
302   - InvokeHelper(0x17, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
303   - return result;
304   -}
305   -
306   -void CMSComm::SetSThreshold(short nNewValue)
307   -{
308   - static BYTE parms[] =
309   - VTS_I2;
310   - InvokeHelper(0x18, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
311   - nNewValue);
312   -}
313   -
314   -short CMSComm::GetSThreshold()
315   -{
316   - short result;
317   - InvokeHelper(0x18, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
318   - return result;
319   -}
320   -
321   -void CMSComm::SetOutput(const VARIANT& newValue)
322   -{
323   - static BYTE parms[] =
324   - VTS_VARIANT;
325   - InvokeHelper(0x19, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
326   - &newValue);
327   -}
328   -
329   -VARIANT CMSComm::GetOutput()
330   -{
331   - VARIANT result;
332   - InvokeHelper(0x19, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL);
333   - return result;
334   -}
335   -
336   -void CMSComm::SetInput(const VARIANT& newValue)
337   -{
338   - static BYTE parms[] =
339   - VTS_VARIANT;
340   - InvokeHelper(0x1a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
341   - &newValue);
342   -}
343   -
344   -VARIANT CMSComm::GetInput()
345   -{
346   - VARIANT result;
347   - InvokeHelper(0x1a, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL);
348   - return result;
349   -}
350   -
351   -void CMSComm::SetCommEvent(short nNewValue)
352   -{
353   - static BYTE parms[] =
354   - VTS_I2;
355   - InvokeHelper(0x1b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
356   - nNewValue);
357   -}
358   -
359   -short CMSComm::GetCommEvent()
360   -{
361   - short result;
362   - InvokeHelper(0x1b, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
363   - return result;
364   -}
365   -
366   -void CMSComm::SetEOFEnable(BOOL bNewValue)
367   -{
368   - static BYTE parms[] =
369   - VTS_BOOL;
370   - InvokeHelper(0x1c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
371   - bNewValue);
372   -}
373   -
374   -BOOL CMSComm::GetEOFEnable()
375   -{
376   - BOOL result;
377   - InvokeHelper(0x1c, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
378   - return result;
379   -}
380   -
381   -void CMSComm::SetInputMode(long nNewValue)
382   -{
383   - static BYTE parms[] =
384   - VTS_I4;
385   - InvokeHelper(0x1d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
386   - nNewValue);
387   -}
388   -
389   -long CMSComm::GetInputMode()
390   -{
391   - long result;
392   - InvokeHelper(0x1d, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
393   - return result;
394   -}
1   -#if !defined(AFX_MSCOMM_H__F0224F69_7A8C_4F5C_8A33_D81C42B66156__INCLUDED_)
2   -#define AFX_MSCOMM_H__F0224F69_7A8C_4F5C_8A33_D81C42B66156__INCLUDED_
3   -
4   -#if _MSC_VER > 1000
5   -#pragma once
6   -#endif // _MSC_VER > 1000
7   -// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
8   -
9   -// NOTE: Do not modify the contents of this file. If this class is regenerated by
10   -// Microsoft Visual C++, your modifications will be overwritten.
11   -
12   -/////////////////////////////////////////////////////////////////////////////
13   -// CMSComm wrapper class
14   -
15   -class CMSComm : public CWnd
16   -{
17   -protected:
18   - DECLARE_DYNCREATE(CMSComm)
19   -public:
20   - CLSID const& GetClsid()
21   - {
22   - static CLSID const clsid
23   - = { 0x648a5600, 0x2c6e, 0x101b, { 0x82, 0xb6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x14 } };
24   - return clsid;
25   - }
26   - virtual BOOL Create(LPCTSTR lpszClassName,
27   - LPCTSTR lpszWindowName, DWORD dwStyle,
28   - const RECT& rect,
29   - CWnd* pParentWnd, UINT nID,
30   - CCreateContext* pContext = NULL)
31   - { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); }
32   -
33   - BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle,
34   - const RECT& rect, CWnd* pParentWnd, UINT nID,
35   - CFile* pPersist = NULL, BOOL bStorage = FALSE,
36   - BSTR bstrLicKey = NULL)
37   - { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
38   - pPersist, bStorage, bstrLicKey); }
39   -
40   -// Attributes
41   -public:
42   -
43   -// Operations
44   -public:
45   - void SetCDHolding(BOOL bNewValue);
46   - BOOL GetCDHolding();
47   - void SetCommID(long nNewValue);
48   - long GetCommID();
49   - void SetCommPort(short nNewValue);
50   - short GetCommPort();
51   - void SetCTSHolding(BOOL bNewValue);
52   - BOOL GetCTSHolding();
53   - void SetDSRHolding(BOOL bNewValue);
54   - BOOL GetDSRHolding();
55   - void SetDTREnable(BOOL bNewValue);
56   - BOOL GetDTREnable();
57   - void SetHandshaking(long nNewValue);
58   - long GetHandshaking();
59   - void SetInBufferSize(short nNewValue);
60   - short GetInBufferSize();
61   - void SetInBufferCount(short nNewValue);
62   - short GetInBufferCount();
63   - void SetBreak(BOOL bNewValue);
64   - BOOL GetBreak();
65   - void SetInputLen(short nNewValue);
66   - short GetInputLen();
67   - void SetNullDiscard(BOOL bNewValue);
68   - BOOL GetNullDiscard();
69   - void SetOutBufferSize(short nNewValue);
70   - short GetOutBufferSize();
71   - void SetOutBufferCount(short nNewValue);
72   - short GetOutBufferCount();
73   - void SetParityReplace(LPCTSTR lpszNewValue);
74   - CString GetParityReplace();
75   - void SetPortOpen(BOOL bNewValue);
76   - BOOL GetPortOpen();
77   - void SetRThreshold(short nNewValue);
78   - short GetRThreshold();
79   - void SetRTSEnable(BOOL bNewValue);
80   - BOOL GetRTSEnable();
81   - void SetSettings(LPCTSTR lpszNewValue);
82   - CString GetSettings();
83   - void SetSThreshold(short nNewValue);
84   - short GetSThreshold();
85   - void SetOutput(const VARIANT& newValue);
86   - VARIANT GetOutput();
87   - void SetInput(const VARIANT& newValue);
88   - VARIANT GetInput();
89   - void SetCommEvent(short nNewValue);
90   - short GetCommEvent();
91   - void SetEOFEnable(BOOL bNewValue);
92   - BOOL GetEOFEnable();
93   - void SetInputMode(long nNewValue);
94   - long GetInputMode();
95   -};
96   -
97   -//{{AFX_INSERT_LOCATION}}
98   -// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
99   -
100   -#endif // !defined(AFX_MSCOMM_H__F0224F69_7A8C_4F5C_8A33_D81C42B66156__INCLUDED_)
No preview for this file type
1   -//
2   -// BLUEFLASHTOOL.RC2 - resources Microsoft Visual C++ does not edit directly
3   -//
4   -
5   -#ifdef APSTUDIO_INVOKED
6   - #error this file is not editable by Microsoft Visual C++
7   -#endif //APSTUDIO_INVOKED
8   -
9   -
10   -/////////////////////////////////////////////////////////////////////////////
11   -// Add manually edited resources here...
12   -
13   -/////////////////////////////////////////////////////////////////////////////
1 1 //{{NO_DEPENDENCIES}}
2   -// Microsoft Developer Studio generated include file.
3   -// Used by BlueFlashTool.rc
  2 +// Microsoft Visual C++ 生成的包含文件。
  3 +// 供 MTTTY.RC 使用
4 4 //
5   -#define IDD_BLUEFLASHTOOL_DIALOG 102
6   -#define IDR_MAINFRAME 128
7   -#define IDD_SYSTEM_CONFIG 131
8   -#define IDC_STATIC_GROUP01 1000
9   -#define IDC_CHECK_EAR01 1001
10   -#define IDC_CHECK_USB01 1002
11   -#define IDC_PROGRESS_EAR01 1003
12   -#define IDC_PROGRESS_USB01 1004
13   -#define IDC_BUTTON_START_EAR01 1005
14   -#define IDC_BUTTON_START_USB01 1006
15   -#define IDC_STATIC_GROUP2 1007
16   -#define IDC_CHECK_EAR2 1008
17   -#define IDC_CHECK_USB2 1009
18   -#define IDC_PROGRESS_EAR2 1010
19   -#define IDC_PROGRESS_USB2 1011
20   -#define IDC_BUTTON_START_EAR2 1012
21   -#define IDC_BUTTON_START_USB2 1013
22   -#define IDC_STATIC_GROUP3 1014
23   -#define IDC_CHECK_EAR3 1015
24   -#define IDC_CHECK_USB3 1016
25   -#define IDC_PROGRESS_EAR3 1017
26   -#define IDC_PROGRESS_USB3 1018
27   -#define IDC_BUTTON_START_EAR3 1019
28   -#define IDC_BUTTON_START_USB3 1020
29   -#define IDC_STATIC_GROUP4 1021
30   -#define IDC_CHECK_EAR4 1022
31   -#define IDC_CHECK_USB4 1023
32   -#define IDC_PROGRESS_EAR4 1024
33   -#define IDC_PROGRESS_USB4 1025
34   -#define IDC_BUTTON_START_EAR4 1026
35   -#define IDC_BUTTON_START_USB4 1027
36   -#define IDC_STATIC_GROUP5 1028
37   -#define IDC_CHECK_EAR5 1029
38   -#define IDC_CHECK_USB5 1030
39   -#define IDC_PROGRESS_EAR5 1031
40   -#define IDC_PROGRESS_USB5 1032
41   -#define IDC_BUTTON_START_EAR5 1033
42   -#define IDC_BUTTON_START_USB5 1034
43   -#define IDC_STATIC_GROUP6 1035
44   -#define IDC_CHECK_EAR6 1036
45   -#define IDC_CHECK_USB6 1037
46   -#define IDC_PROGRESS_EAR6 1038
47   -#define IDC_PROGRESS_USB6 1039
48   -#define IDC_BUTTON_START_EAR6 1040
49   -#define IDC_BUTTON_START_USB6 1041
50   -#define IDC_STATIC_GROUP7 1042
51   -#define IDC_CHECK_EAR7 1043
52   -#define IDC_CHECK_USB7 1044
53   -#define IDC_PROGRESS_EAR7 1045
54   -#define IDC_PROGRESS_USB7 1046
55   -#define IDC_BUTTON_START_EAR7 1047
56   -#define IDC_BUTTON_START_USB7 1048
57   -#define IDC_STATIC_GROUP8 1049
58   -#define IDC_CHECK_EAR8 1050
59   -#define IDC_CHECK_USB8 1051
60   -#define IDC_PROGRESS_EAR8 1052
61   -#define IDC_PROGRESS_USB8 1053
62   -#define IDC_BUTTON_START_EAR8 1054
63   -#define IDC_BUTTON_START_USB8 1055
64   -#define IDC_STATIC_GROUP9 1056
65   -#define IDC_CHECK_EAR9 1057
66   -#define IDC_CHECK_USB9 1058
67   -#define IDC_PROGRESS_EAR9 1059
68   -#define IDC_PROGRESS_USB9 1060
69   -#define IDC_BUTTON_START_EAR9 1061
70   -#define IDC_BUTTON_START_USB9 1062
71   -#define IDC_STATIC_GROUP10 1063
72   -#define IDC_CHECK_EAR10 1064
73   -#define IDC_CHECK_USB10 1065
74   -#define IDC_PROGRESS_EAR10 1066
75   -#define IDC_PROGRESS_USB10 1067
76   -#define IDC_BUTTON_START_EAR10 1068
77   -#define IDC_BUTTON_START_USB10 1069
78   -#define IDC_START_ALL 1070
79   -#define IDC_STOP_ALL 1071
80   -#define IDC_BUTTON_SETTING 1072
81   -#define IDC_MSCOMM0 1074
82   -#define IDC_MSCOMM1 1075
83   -#define IDC_MSCOMM2 1076
84   -#define IDC_MSCOMM3 1077
85   -#define IDC_MSCOMM4 1078
86   -#define IDC_MSCOMM5 1079
87   -#define IDC_MSCOMM6 1080
88   -#define IDC_MSCOMM7 1081
89   -#define IDC_MSCOMM8 1082
90   -#define IDC_MSCOMM9 1083
91   -#define IDC_MSCOMM10 1084
92   -#define IDC_MSCOMM11 1085
93   -#define IDC_MSCOMM12 1086
94   -#define IDC_MSCOMM13 1087
95   -#define IDC_MSCOMM14 1088
96   -#define IDC_MSCOMM15 1089
97   -#define IDC_MSCOMM16 1090
98   -#define IDC_MSCOMM17 1091
99   -#define IDC_MSCOMM18 1092
100   -#define IDC_MSCOMM19 1093
101   -#define IDC_MSCOMM20 1094
  5 +#define IDR_MTTTYMENU 101
  6 +#define IDR_MTTTYACCELERATOR 102
  7 +#define IDI_APPICON 103
  8 +#define IDD_TOOLBARSETTINGS 103
  9 +#define ID_TTYWINDOW 103
  10 +#define IDD_ABOUT 104
  11 +#define IDD_STATUSDIALOG 105
  12 +#define IDD_COMMEVENTSDLG 107
  13 +#define IDD_FLOWCONTROLDLG 108
  14 +#define IDI_APPICON2 109
  15 +#define IDI_APPICON3 110
  16 +#define IDD_TIMEOUTSDLG 110
  17 +#define IDI_APPICON4 111
  18 +#define IDD_GETADWORD 111
  19 +#define IDI_TITLE 102
  20 +#define IDC_PORTCOMBO 1000
  21 +#define IDC_BAUDCOMBO 1001
  22 +#define IDC_PARITYCOMBO 1002
  23 +#define IDC_DATABITSCOMBO 1003
  24 +#define IDC_STOPBITSCOMBO 1004
  25 +#define IDC_STATCTS 1004
  26 +#define IDC_STATDSR 1005
  27 +#define IDC_STATRING 1006
  28 +#define IDC_STATRLSD 1007
  29 +#define IDC_LOCALECHOCHK 1008
  30 +#define IDC_DISPLAYERRORSCHK 1009
  31 +#define IDC_FONTBTN 1010
  32 +#define IDC_ABORTBTN 1011
  33 +#define IDC_SENDBTN 1012
  34 +#define IDC_TRANSFERPROGRESS 1013
  35 +#define IDC_MODEMSTATUSGRP 1018
  36 +#define IDC_COMMEVENTSBTN 1019
  37 +#define IDC_EVBREAKBTN 1020
  38 +#define IDC_EVCTSBTN 1021
  39 +#define IDC_EVDSRBTN 1022
  40 +#define IDC_EVERRBTN 1023
  41 +#define IDC_EVRINGBTN 1024
  42 +#define IDC_EVRLSDBTN 1025
  43 +#define IDC_EVRXCHARBTN 1026
  44 +#define IDC_EVRXFLAGBTN 1027
  45 +#define IDC_EVTXEMPTYBTN 1028
  46 +#define IDC_FLAGEDIT 1029
  47 +#define IDC_DEFAULTSBTN 1030
  48 +#define IDC_LFBTN 1032
  49 +#define IDC_AUTOWRAPCHK 1033
  50 +#define IDC_STATUSEDIT 1034
  51 +#define IDC_FLAGCHAR 1036
  52 +#define IDC_FLOWCONTROLBTN 1039
  53 +#define IDC_CTSOUTCHK 1040
  54 +#define IDC_DSROUTCHK 1041
  55 +#define IDC_DTRCONTROLCOMBO 1043
  56 +#define IDC_DSRINCHK 1044
  57 +#define IDC_XONXOFFOUTCHK 1045
  58 +#define IDC_XONXOFFINCHK 1046
  59 +#define IDC_XONLIMITEDIT 1047
  60 +#define IDC_XOFFLIMITEDIT 1048
  61 +#define IDC_XONCHAREDIT 1049
  62 +#define IDC_XOFFCHAREDIT 1050
  63 +#define IDC_RTSCONTROLCOMBO 1051
  64 +#define IDC_RTSCTSBTN 1052
  65 +#define IDC_XOFFXONBTN 1053
  66 +#define IDC_XONCHARDISP 1054
  67 +#define IDC_XOFFCHARDISP 1055
  68 +#define IDC_PICTURE 1056
  69 +#define IDC_DTRDSRBTN 1056
  70 +#define IDC_TIMEOUTSBTN 1057
  71 +#define IDC_READINTERVALEDIT 1058
  72 +#define IDC_READMULTIPLIEREDIT 1059
  73 +#define IDC_READCONSTANTEDIT 1060
  74 +#define IDC_WRITEMULTIPLIEREDIT 1061
  75 +#define IDC_WRITECONSTANTEDIT 1062
  76 +#define IDC_NONEBTN 1064
  77 +#define IDC_OSVERSIONINFO 1065
  78 +#define IDC_TXAFTERXOFFSENTCHK 1066
  79 +#define IDC_CTSHOLDCHK 1067
  80 +#define IDC_DSRHOLDCHK 1068
  81 +#define IDC_RLSDHOLDCHK 1069
  82 +#define IDC_XOFFHOLDCHK 1070
  83 +#define IDC_XOFFSENTCHK 1071
  84 +#define IDC_EOFSENTCHK 1072
  85 +#define IDC_TXIMCHK 1073
  86 +#define IDC_TXCHAREDIT 1074
  87 +#define IDC_RXCHAREDIT 1075
  88 +#define IDC_NOREADINGCHK 1076
  89 +#define IDC_NOWRITINGCHK 1077
  90 +#define IDC_NOSTATUSCHK 1078
  91 +#define IDC_NOEVENTSCHK 1079
  92 +#define IDC_DWORDSTATIC 1081
  93 +#define IDC_DWORDEDIT 1082
  94 +#define IDC_DISPLAYTIMEOUTS 1083
  95 +#define ID_FILE_EXIT 40001
  96 +#define ID_HELP_ABOUTMTTTY 40002
  97 +#define ID_FILE_CONNECT 40004
  98 +#define ID_FILE_DISCONNECT 40005
  99 +#define ID_TTY_CLEAR 40008
  100 +#define ID_TRANSFER_SENDFILETEXT 40010
  101 +#define ID_TRANSFER_RECEIVEFILETEXT 40011
  102 +#define ID_TRANSFER_SENDREPEATEDLY 40012
  103 +#define ID_TRANSFER_ABORTSENDING 40016
  104 +#define ID_TRANSFER_ABORTREPEATEDSENDING 40018
  105 +#define IDC_STATIC 65535
102 106
103 107 // Next default values for new objects
104 108 //
105 109 #ifdef APSTUDIO_INVOKED
106 110 #ifndef APSTUDIO_READONLY_SYMBOLS
107   -#define _APS_NEXT_RESOURCE_VALUE 132
108   -#define _APS_NEXT_COMMAND_VALUE 32771
109   -#define _APS_NEXT_CONTROL_VALUE 1075
110   -#define _APS_NEXT_SYMED_VALUE 101
  111 +#define _APS_NEXT_RESOURCE_VALUE 115
  112 +#define _APS_NEXT_COMMAND_VALUE 40021
  113 +#define _APS_NEXT_CONTROL_VALUE 1085
  114 +#define _APS_NEXT_SYMED_VALUE 104
111 115 #endif
112 116 #endif
... ...
Please register or login to post a comment