-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathSTATUS.C
710 lines (547 loc) · 21.8 KB
/
STATUS.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
/*-----------------------------------------------------------------------------
This is a part of the Microsoft Source Code Samples.
Copyright (C) 1995 Microsoft Corporation.
All rights reserved.
This source code is only intended as a supplement to
Microsoft Development Tools and/or WinHelp documentation.
See these sources for detailed information regarding the
Microsoft samples programs.
MODULE: Status.c
PURPOSE: Controls the status dialog at bottom of screen
Functions:
OpenStatusToolBar - Creates the status dialog
CreateStatusEditFont - Creates the status edit control font
StatusDlgProc - Status dialog procedure
InitStatusMessage - Initializes the status message mechanism
StatusMessage - Updates status edit control
UpdateStatus - Creates a status message node (entry point
for other threads
ReportModemStatus - Updates modem status controls
CheckModemStatus - Calls GetCommModemStatus and ReportModemStatus
ReportComStat - Updates comm status controls based on
COMSTAT structure (from ClearCommError)
ReportCommError - Reports comm errors when they occur
ReportStatusEvent - Reports comm events when they occur
-----------------------------------------------------------------------------*/
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include "MTTTY.h"
#define MAX_STATUS_LENGTH 100
//
// Prototypes for functions called only within this file
//
void ReportStatusEvent( DWORD );
void ReportCommError( void );
void ReportModemStatus( DWORD );
BOOL CALLBACK StatusDlgProc( HWND, UINT, WPARAM, LPARAM );
void InitStatusMessage( void );
/*-----------------------------------------------------------------------------
FUNCTION: OpenStatusToolbar(HWND)
PURPOSE: Opens the modeless status dialog
PARAMETERS:
hWnd - Handle of window which owns the dialog
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
/*-----------------------------------------------------------------------------*/
void OpenStatusToolbar(HWND hWnd)
{
ghWndStatusDlg = CreateDialog(ghInst, MAKEINTRESOURCE(IDD_STATUSDIALOG), hWnd, StatusDlgProc);
if (ghWndStatusDlg == NULL)
ErrorReporter(_T("CreateDialog (Status Dialog)"));
return;
}
/*-----------------------------------------------------------------------------
FUNCTION: CreateStatusEditFont
PURPOSE: Creates the font for the status edit control
RETURN: HFONT of new font created
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
HFONT CreateStatusEditFont()
{
LOGFONT lf = {0};
HFONT hFont;
lf.lfHeight = 14 ;
lf.lfCharSet = ANSI_CHARSET ;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS ;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS ;
lf.lfQuality = DEFAULT_QUALITY ;
lf.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS ;
hFont = CreateFontIndirect(&lf);
return hFont;
}
/*-----------------------------------------------------------------------------
FUNCTION: StatusDlgProc(HWND, UINT, WPARAM, LPARAM)
PURPOSE: Provides the dialog procedure for the status dialog
PARAMETERS:
hWndDlg - Dialog window handle
uMsg - Window message
wParam - message parameter (depends on message)
lParam - message parameter (depends on message)
RETURN:
TRUE if message is handled
FALSE if message is not handled
Exception is WM_INITDIALOG: returns FALSE since focus is not set
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
BOOL CALLBACK StatusDlgProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
BOOL fRet = FALSE;
switch(uMsg)
{
case WM_INITDIALOG: // setup dialog with defaults
SendMessage(GetDlgItem(hWndDlg, IDC_STATUSEDIT), WM_SETFONT, (WPARAM)ghFontStatus, 0);
InitStatusMessage();
break;
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDC_ABORTBTN:
SendMessage(ghwndMain, WM_COMMAND, ID_TRANSFER_ABORTSENDING, MAKELPARAM(IDC_ABORTBTN,0) );
fRet = TRUE;
break;
case IDC_STATCTS:
case IDC_STATDSR:
case IDC_STATRING:
case IDC_STATRLSD:
CheckModemStatus(TRUE);
fRet = TRUE;
break;
case IDC_CTSHOLDCHK:
case IDC_DSRHOLDCHK:
case IDC_RLSDHOLDCHK:
case IDC_XOFFHOLDCHK:
case IDC_XOFFSENTCHK:
case IDC_EOFSENTCHK:
case IDC_TXIMCHK:
CheckComStat(TRUE);
fRet = TRUE;
break;
default:
break;
}
}
break;
default:
break;
}
return fRet;
}
/*-----------------------------------------------------------------------------
FUNCTION: InitStatusMessage
PURPOSE: Initializes status message heap and linked list
HISTORY: Date: Author: Comment:
11/21/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
void InitStatusMessage()
{
SYSTEM_INFO SysInfo;
GetSystemInfo(&SysInfo);
ghStatusMessageHeap = HeapCreate(0, SysInfo.dwPageSize, 0);
if (ghStatusMessageHeap == NULL)
ErrorReporter(_T("HeapCreate (Status message)"));
glpStatusMessageHead = HeapAlloc(ghStatusMessageHeap, HEAP_ZERO_MEMORY, sizeof(STATUS_MESSAGE));
glpStatusMessageTail = glpStatusMessageHead;
gnStatusIndex = 0;
/*
Queue the initial status message.
This won't show up until the ReaderAndStatusProc function
is called when the threads are created after the port is connected.
*/
UpdateStatus(_T("Status message go here:\r\n"));
return;
}
/*-----------------------------------------------------------------------------
FUNCTION: StatusMessage
PURPOSE: Retrieves status message from status message linked list
and updates status edit control.
COMMENTS: Called from ReaderAndStatusProc when the status event
has been set. Clears edit control when number of characters
exceeds MAX_STATUS_BUFFER.
HISTORY: Date: Author: Comment:
11/21/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
void StatusMessage()
{
STATUS_MESSAGE * lpStatusMessage;
DWORD dwRes;
HWND hEdit;
BOOL bRes;
hEdit = GetDlgItem (ghWndStatusDlg, IDC_STATUSEDIT);
/*
If status control has a lot of characters in it,
then wipe them out and start over
*/
if (gnStatusIndex > MAX_STATUS_BUFFER) {
SendMessageTimeout( hEdit, EM_SETSEL,
(WPARAM) (INT) 0, (LPARAM) (INT) -1,
SMTO_NORMAL | SMTO_ABORTIFHUNG,
500, &dwRes);
SendMessageTimeout( hEdit, EM_REPLACESEL,
0, (LPARAM) "",
SMTO_NORMAL | SMTO_ABORTIFHUNG,
500, &dwRes);
gnStatusIndex = 0;
}
//
// Loop through each node in the status message linked list.
//
for ( lpStatusMessage = glpStatusMessageHead->lpNext ; lpStatusMessage ; )
{
//
// if global quit event is set, then just exit this loop
//
if (WaitForSingleObject(ghThreadExitEvent, 0) == WAIT_OBJECT_0)
break;
//
// Place each status message into the status control.
//
SendMessageTimeout( hEdit, EM_SETSEL,
gnStatusIndex, gnStatusIndex,
SMTO_NORMAL | SMTO_ABORTIFHUNG,
500, &dwRes);
SendMessageTimeout( hEdit, EM_REPLACESEL,
0, (LPARAM) ((LPSTR) &(lpStatusMessage->chMessageStart)),
SMTO_NORMAL | SMTO_ABORTIFHUNG,
500, &dwRes);
gnStatusIndex += _tcslen(&(lpStatusMessage->chMessageStart));
//
// Update status message linked list
//
EnterCriticalSection(&gStatusCritical);
bRes = HeapFree(ghStatusMessageHeap, 0, glpStatusMessageHead);
glpStatusMessageHead = lpStatusMessage;
lpStatusMessage = lpStatusMessage->lpNext;
LeaveCriticalSection(&gStatusCritical);
if (!bRes)
ErrorReporter(_T("HeapFree (status message)"));
}
return;
}
/*-----------------------------------------------------------------------------
FUNCTION: UpdateStatus(char *)
PURPOSE: Places the passed in string into the status message linked
list and sets the event to make the message display.
PARAMETERS:
szText - message to be placed in the status control
COMMENTS: Synchronization needed in order to ensure that only
one thread at a time places a string in the list
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
11/21/95 AllenD Modified to use a status message heap
-----------------------------------------------------------------------------*/
void UpdateStatus(TCHAR * szText)
{
TCHAR * szNewMsg;
DWORD dwSize;
STATUS_MESSAGE * lpStatusMessage;
static dwMessageCounter = 0;
dwMessageCounter++;
dwSize = _tcslen(szText) + 30; // include NULL terminator and space for counter
EnterCriticalSection(&gStatusCritical);
szNewMsg = HeapAlloc(ghStatusMessageHeap, 0, dwSize+30);
if (szNewMsg == NULL) {
LeaveCriticalSection(&gStatusCritical);
ErrorReporter(_T("HeapAlloc (status message)"));
return;
}
else {
wsprintf(szNewMsg, _T("%d:%s"), dwMessageCounter, szText);
if (_tcslen(szNewMsg) > dwSize) {
LeaveCriticalSection(&gStatusCritical);
ErrorInComm(_T("Heap Corruption in UpdateStatus\n"));
}
}
lpStatusMessage = HeapAlloc(ghStatusMessageHeap, 0, sizeof(LPSTR) + dwSize );
if (lpStatusMessage == NULL) {
LeaveCriticalSection(&gStatusCritical);
ErrorReporter(_T("HeapAlloc (status message)"));
return ;
}
lpStatusMessage->lpNext = NULL;
glpStatusMessageTail->lpNext = lpStatusMessage;
glpStatusMessageTail = lpStatusMessage;
CopyMemory(&(lpStatusMessage->chMessageStart), szNewMsg, dwSize);
LeaveCriticalSection(&gStatusCritical);
SetEvent(ghStatusMessageEvent);
return ;
}
/*-----------------------------------------------------------------------------
FUNCTION: ReportModemStatus(DWORD)
PURPOSE: Reports modem status line states
PARAMETERS:
dwModemStatus - current modem status flag
COMMENTS: Checks each button according to the state
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
void ReportModemStatus(DWORD dwModemStatus)
{
BOOL fCTS, fDSR, fRING, fRLSD;
BOOL fStat[4];
int i;
fCTS = fStat[0] = MS_CTS_ON & dwModemStatus;
fDSR = fStat[1] = MS_DSR_ON & dwModemStatus;
fRING = fStat[2] = MS_RING_ON & dwModemStatus;
fRLSD = fStat[3] = MS_RLSD_ON & dwModemStatus;
for (i = IDC_STATCTS; i <= IDC_STATRLSD; i++)
CheckDlgButton(ghWndStatusDlg, i, fStat[i-IDC_STATCTS] ? 1 : 0);
return;
}
/*-----------------------------------------------------------------------------
FUNCTION: CheckModemStatus(BOOL)
PURPOSE: Check new status and possibly report it
PARAMETERS:
bUpdateNow - if TRUE, update should be done
if FALSE, update is done only if status is different
COMMENTS: Reports status if bUpdateNow is true or
new status is different from old status
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
void CheckModemStatus( BOOL bUpdateNow )
{
//
// dwOldStatus needs to be static so that it is maintained
// between function calls by the same thread.
// It also needs to be __declspec(thread) so that it is
// initialized when a new thread is created.
//
__declspec(thread) static DWORD dwOldStatus = 0;
DWORD dwNewModemStatus;
if (!GetCommModemStatus(COMDEV(TTYInfo), &dwNewModemStatus))
ErrorReporter(_T("GetCommModemStatus"));
//
// Report status if bUpdateNow is true or status has changed
//
if (bUpdateNow || (dwNewModemStatus != dwOldStatus)) {
ReportModemStatus(dwNewModemStatus);
dwOldStatus = dwNewModemStatus;
}
return;
}
/*-----------------------------------------------------------------------------
FUNCTION: ReportComStat( COMSTAT )
PURPOSE: Update status dialog controls based on the COMSTAT structure
PARAMETERS:
ComStat - comstat structure used to update comm stat controls.
HISTORY: Date: Author: Comment:
12/01/95 AllenD Wrote it
12/18/95 AllenD Modified it
-----------------------------------------------------------------------------*/
void ReportComStat(COMSTAT ComStat)
{
CheckDlgButton(ghWndStatusDlg, IDC_CTSHOLDCHK, ComStat.fCtsHold);
CheckDlgButton(ghWndStatusDlg, IDC_DSRHOLDCHK, ComStat.fDsrHold);
CheckDlgButton(ghWndStatusDlg, IDC_RLSDHOLDCHK, ComStat.fRlsdHold);
CheckDlgButton(ghWndStatusDlg, IDC_XOFFHOLDCHK, ComStat.fXoffHold);
CheckDlgButton(ghWndStatusDlg, IDC_XOFFSENTCHK, ComStat.fXoffSent);
CheckDlgButton(ghWndStatusDlg, IDC_EOFSENTCHK, ComStat.fEof);
CheckDlgButton(ghWndStatusDlg, IDC_TXIMCHK, ComStat.fTxim);
SetDlgItemInt(ghWndStatusDlg, IDC_TXCHAREDIT, ComStat.cbOutQue, FALSE);
SetDlgItemInt(ghWndStatusDlg, IDC_RXCHAREDIT, ComStat.cbInQue, FALSE);
return;
}
/*-----------------------------------------------------------------------------
FUNCTION: CheckComStat(BOOL)
PURPOSE: Calls ClearCommError and reports the results.
PARAMETERS:
bUpdateNow - If TRUE, then ReportComStat is called with new results.
if FALSE, then ReportComStat is called only if
new results differ from old.
COMMENTS: Called when the ReaderAndStatusProc times out after waiting on
its event handles. Also called from ReportStatusEvent.
HISTORY: Date: Author: Comment:
12/18/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
void CheckComStat(BOOL bUpdateNow)
{
COMSTAT ComStatNew;
DWORD dwErrors;
__declspec(thread) static COMSTAT ComStatOld = {0};
__declspec(thread) static DWORD dwErrorsOld = 0;
BOOL bReport = bUpdateNow;
if (!ClearCommError(COMDEV(TTYInfo), &dwErrors, &ComStatNew))
ErrorReporter(_T("ClearCommError"));
if (dwErrors != dwErrorsOld) {
bReport = TRUE;
dwErrorsOld = dwErrors;
}
if (memcmp(&ComStatOld, &ComStatNew, sizeof(COMSTAT))) {
bReport = TRUE;
ComStatOld = ComStatNew;
}
if (bReport)
ReportComStat(ComStatNew);
ComStatOld = ComStatNew;
return;
}
/*-----------------------------------------------------------------------------
FUNCTION: ReportCommError
PURPOSE: Calls ClearCommError and reports the results
COMMENTS: This function is called if EV_ERR occurs and is called
when the ReaderAndStatusProc times out after waiting on
its event handles.
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
void ReportCommError()
{
COMSTAT comStat;
DWORD dwErrors;
BOOL fOOP, fOVERRUN, fPTO, fRXOVER, fRXPARITY, fTXFULL;
BOOL fBREAK, fDNS, fFRAME, fIOE, fMODE;
TCHAR szMessage[100];
//
// Get and clear current errors on the port
//
if (!ClearCommError(COMDEV(TTYInfo), &dwErrors, &comStat))
ErrorReporter(_T("ClearCommError"));
//
// get error flags
//
fDNS = dwErrors & CE_DNS;
fIOE = dwErrors & CE_IOE;
fOOP = dwErrors & CE_OOP;
fPTO = dwErrors & CE_PTO;
fMODE = dwErrors & CE_MODE;
fBREAK = dwErrors & CE_BREAK;
fFRAME = dwErrors & CE_FRAME;
fRXOVER = dwErrors & CE_RXOVER;
fTXFULL = dwErrors & CE_TXFULL;
fOVERRUN = dwErrors & CE_OVERRUN;
fRXPARITY = dwErrors & CE_RXPARITY;
//
// create error string
//
_tcscpy_s(szMessage, 100, _T("ERROR: "));
_tcscat_s(szMessage, 100, fDNS ? _T("DNS ") : _T(""));
_tcscat_s(szMessage, 100, fIOE ? _T("IOE ") : _T(""));
_tcscat_s(szMessage, 100, fOOP ? _T("OOP ") : _T(""));
_tcscat_s(szMessage, 100, fPTO ? _T("PTO ") : _T(""));
_tcscat_s(szMessage, 100, fMODE ? _T("MODE ") : _T(""));
_tcscat_s(szMessage, 100, fBREAK ? _T("BREAK ") : _T(""));
_tcscat_s(szMessage, 100, fFRAME ? _T("FRAME ") : _T(""));
_tcscat_s(szMessage, 100, fRXOVER ? _T("RXOVER ") : _T(""));
_tcscat_s(szMessage, 100, fTXFULL ? _T("TXFULL ") : _T(""));
_tcscat_s(szMessage, 100, fOVERRUN ? _T("OVERRUN ") : _T(""));
_tcscat_s(szMessage, 100, fRXPARITY ? _T("RXPARITY ") : _T(""));
_tcscat_s(szMessage, 100, _T("\r\n"));
//
// if there really were errors, then report them
//
if (dwErrors)
UpdateStatus(szMessage);
//
// Report info from the COMSTAT structure
//
ReportComStat(comStat);
//
// Show COMSTAT structure with the error indicator
//
if (comStat.fCtsHold)
UpdateStatus(_T("Tx waiting for CTS signal.\r\n"));
if (comStat.fDsrHold)
UpdateStatus(_T("Tx waiting for DSR signal.\r\n"));
if (comStat.fRlsdHold)
UpdateStatus(_T("Tx waiting for RLSD signal.\r\n"));
if (comStat.fXoffHold)
UpdateStatus(_T("Tx waiting, XOFF char rec'd.\r\n"));
if (comStat.fXoffSent)
UpdateStatus(_T("Tx waiting, XOFF char sent.\r\n"));
if (comStat.fEof)
UpdateStatus(_T("EOF character received.\r\n"));
if (comStat.fTxim)
UpdateStatus(_T("Character waiting for Tx.\r\n"));
if (comStat.cbInQue) {
wsprintf(szMessage, _T("%d bytes in input buffer.\r\n"), comStat.cbInQue);
UpdateStatus(szMessage);
}
if (comStat.cbOutQue) {
wsprintf(szMessage, _T("%d bytes in output buffer.\r\n"), comStat.cbOutQue);
UpdateStatus(szMessage);
}
return;
}
/*-----------------------------------------------------------------------------
FUNCTION: ReportStatusEvent(DWORD)
PURPOSE: Report a comm status event
PARAMETERS:
dwStatus - status event flag from WaitCommEvent
COMMENTS: This is different than line status (aka Modem Status).
NOTE: EV_RING isn't detected on Windows 95. This is a known problem.
A workaround to the problem is to rely on GetCommModemStatus, or
set the modem to send a "RING" and have the app detect it.
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
/*-----------------------------------------------------------------------------*/
void ReportStatusEvent(DWORD dwStatus)
{
BOOL fRING, fRLSD, fRXCHAR, fRXFLAG, fTXEMPTY;
BOOL fBREAK, fCTS, fDSR, fERR;
TCHAR szMessage[70];
//
// Get status event flags.
//
fCTS = EV_CTS & dwStatus;
fDSR = EV_DSR & dwStatus;
fERR = EV_ERR & dwStatus;
fRING = EV_RING & dwStatus;
fRLSD = EV_RLSD & dwStatus;
fBREAK = EV_BREAK & dwStatus;
fRXCHAR = EV_RXCHAR & dwStatus;
fRXFLAG = EV_RXFLAG & dwStatus;
fTXEMPTY = EV_TXEMPTY & dwStatus;
/*
Construct status message indicating the
status event flags that are set.
*/
_tcscpy_s(szMessage, 70, _T("EVENT: "));
_tcscat_s(szMessage, 70, fCTS ? _T("CTS ") : _T(""));
_tcscat_s(szMessage, 70, fDSR ? _T("DSR ") : _T(""));
_tcscat_s(szMessage, 70, fERR ? _T("ERR ") : _T(""));
_tcscat_s(szMessage, 70, fRING ? _T("RING ") : _T(""));
_tcscat_s(szMessage, 70, fRLSD ? _T("RLSD ") : _T(""));
_tcscat_s(szMessage, 70, fBREAK ? _T("BREAK ") : _T(""));
_tcscat_s(szMessage, 70, fRXFLAG ? _T("RXFLAG ") : _T(""));
_tcscat_s(szMessage, 70, fRXCHAR ? _T("RXCHAR ") : _T(""));
_tcscat_s(szMessage, 70, fTXEMPTY ? _T("TXEMPTY ") : _T(""));
/*
If dwStatus == NULL, then no status event flags are set.
This happens when the event flag is changed with SetCommMask.
*/
if (dwStatus == 0x0000)
_tcscat_s(szMessage, 70, _T("NULL"));
_tcscat_s(szMessage, 70, _T("\r\n"));
//
// Queue the status message for the status control
//
UpdateStatus(szMessage);
/*
If an error flag is set in the event flag, then
report the error with the status message
If not, then just report the comm status.
*/
if (fERR)
ReportCommError();
/*
Might as well check the modem status and comm status now since
the event may have been caused by a change in line status.
Line status is indicated by the CheckModemStatus function.
*/
CheckModemStatus( FALSE );
/*
Since line status can affect sending/receiving when
hardware flow-control is used, ReportComStat should
be called to show comm status. This is called only if no error
was reported in the event flag. If an error was reported, then
ReportCommError was called above and CheckComStat was already called
in that function.
*/
if (!fERR)
CheckComStat( FALSE );
return;
}