summaryrefslogtreecommitdiffabout
path: root/T42View.cpp
Unidiff
Diffstat (limited to 'T42View.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--T42View.cpp703
1 files changed, 703 insertions, 0 deletions
diff --git a/T42View.cpp b/T42View.cpp
new file mode 100644
index 0000000..8ccad1c
--- a/dev/null
+++ b/T42View.cpp
@@ -0,0 +1,703 @@
1// T42View.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "T42.h"
6#include "T42View.h"
7
8#include "T42Frame.h"
9
10#ifdef _DEBUG
11#define new DEBUG_NEW
12#undef THIS_FILE
13static char THIS_FILE[] = __FILE__;
14#endif
15
16/////////////////////////////////////////////////////////////////////////////
17// T42View
18
19IMPLEMENT_DYNCREATE(T42View, CFormView)
20
21T42View::T42View()
22 : CFormView(T42View::IDD)
23{
24 //{{AFX_DATA_INIT(T42View)
25 //}}AFX_DATA_INIT
26 m_localCtl.m_pView = m_remoteCtl.m_pView = this;
27 m_pFrame = NULL;
28 m_localSize = 50;
29 m_remoteSize = 50;
30 m_gapSize = 5;
31 m_Ort = ortHorizontal;
32 m_bShown = FALSE;
33 m_bTracking = FALSE;
34 m_hHorzCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZENS);
35 m_hVertCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE);
36 m_bEnabled = FALSE;
37}
38
39T42View::~T42View()
40{
41}
42
43void T42View::DoDataExchange(CDataExchange* pDX)
44{
45 CFormView::DoDataExchange(pDX);
46 //{{AFX_DATA_MAP(T42View)
47 DDX_Control(pDX, IDC_SPLIT, m_splitCtl);
48 //}}AFX_DATA_MAP
49}
50
51
52BEGIN_MESSAGE_MAP(T42View, CFormView)
53 //{{AFX_MSG_MAP(T42View)
54 ON_WM_SIZE()
55 ON_MESSAGE(WM_SPLITTERBDOWN, OnSplitterBDown)
56 ON_WM_MOUSEMOVE()
57 ON_WM_LBUTTONUP()
58 ON_WM_SETCURSOR()
59 ON_COMMAND(ID_WINDOW_SPLITEQUALLY, OnWindowSplitequally)
60 ON_UPDATE_COMMAND_UI(ID_WINDOW_HORIZONTALSPLIT, OnUpdateWindowHorizontalsplit)
61 ON_UPDATE_COMMAND_UI(ID_WINDOW_VERTICALSPLIT, OnUpdateWindowVerticalsplit)
62 ON_COMMAND(ID_WINDOW_HORIZONTALSPLIT, OnWindowHorizontalsplit)
63 ON_COMMAND(ID_WINDOW_VERTICALSPLIT, OnWindowVerticalsplit)
64 ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
65 ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
66 ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste)
67 ON_WM_CANCELMODE()
68 ON_UPDATE_COMMAND_UI(ID_TEA_SAVE, OnUpdateTeaSave)
69 ON_COMMAND(ID_TEA_SAVE, OnTeaSave)
70 //}}AFX_MSG_MAP
71END_MESSAGE_MAP()
72
73/////////////////////////////////////////////////////////////////////////////
74// T42View diagnostics
75
76#ifdef _DEBUG
77void T42View::AssertValid() const
78{
79 CFormView::AssertValid();
80}
81
82void T42View::Dump(CDumpContext& dc) const
83{
84 CFormView::Dump(dc);
85}
86#endif //_DEBUG
87
88/////////////////////////////////////////////////////////////////////////////
89// T42View message handlers
90/////////////////////////////////////////////////////////////////////////////
91// CSplitBar
92
93CSplitBar::CSplitBar()
94{
95}
96
97CSplitBar::~CSplitBar()
98{
99}
100
101
102BEGIN_MESSAGE_MAP(CSplitBar, CStatic)
103 //{{AFX_MSG_MAP(CSplitBar)
104 ON_WM_LBUTTONDOWN()
105 ON_WM_PAINT()
106 //}}AFX_MSG_MAP
107END_MESSAGE_MAP()
108
109/////////////////////////////////////////////////////////////////////////////
110// CSplitBar message handlers
111
112void CSplitBar::OnLButtonDown(UINT nFlags, CPoint point)
113{
114 GetParent()->PostMessage(WM_SPLITTERBDOWN);
115}
116
117void CSplitBar::OnPaint()
118{
119CPaintDC dc(this); // device context for painting
120CRect rc;
121 GetWindowRect(rc);
122 ScreenToClient(rc);
123 dc.DrawEdge(rc,EDGE_RAISED,(m_Ort==T42View::ortVertical)?BF_LEFT|BF_RIGHT:BF_TOP|BF_BOTTOM);
124}
125
126void T42View::OnInitialUpdate()
127{
128 CFormView::OnInitialUpdate();
129 m_pFrame = (T42Frame*)GetParent();
130 ASSERT_KINDOF(T42Frame,m_pFrame);
131 SetScaleToFitSize(CSize(10,10));
132
133 m_localCtl.Create(WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|ES_LEFT|ES_MULTILINE|ES_WANTRETURN|WS_VSCROLL,
134 CRect(0,0,0,0), this, 0);
135 m_remoteCtl.Create(WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|ES_LEFT|ES_MULTILINE|ES_WANTRETURN|WS_VSCROLL,
136 CRect(0,0,0,0), this, 0);
137 m_localCtl.SetFocus();
138 m_localCtl.m_pInTEC = &m_pFrame->m_localEC;
139 m_localCtl.m_pOuTEC = &m_pFrame->m_remoteEC;
140 m_remoteCtl.m_pInTEC = &m_pFrame->m_remoteEC;
141 m_remoteCtl.m_pOuTEC = &m_pFrame->m_localEC;
142
143
144 LoadLayout();
145
146 RecalcLayout();
147 m_bShown=TRUE;
148}
149
150void T42View::RecalcLayout()
151{
152UINT lrs = m_localSize+m_remoteSize;
153 m_splitCtl.m_Ort = m_Ort;
154CRect crc;
155 GetClientRect(crc);
156CRect rc;
157UINT ls = m_localSize, rs = m_remoteSize;
158 if(m_Ort==ortHorizontal){
159 UINT lr = crc.Height()-m_gapSize;
160 rc.top = rc.left = 0;
161 rc.right = crc.right;
162
163 ls = lr*m_localSize/lrs;
164 rc.bottom = ls;
165 m_localCtl.MoveWindow(rc);
166
167 rc.top=rc.bottom+1;
168 rc.bottom=rc.top+m_gapSize-1;
169 m_splitCtl.MoveWindow(rc);
170
171 rc.top=rc.bottom+1;
172 rc.bottom=crc.bottom;
173 rs = rc.Height();
174 m_remoteCtl.MoveWindow(rc);
175 }else if(m_Ort==ortVertical){
176 CRect crc;
177 GetClientRect(crc);
178 CRect rc;
179 UINT lr = crc.Width()-m_gapSize;
180 rc.top = rc.left = 0;
181 rc.bottom = crc.bottom;
182
183 ls = lr*m_localSize/lrs;
184 rc.right = ls;
185 m_localCtl.MoveWindow(rc);
186
187 rc.left=rc.right+1;
188 rc.right=rc.left+m_gapSize-1;
189 m_splitCtl.MoveWindow(rc);
190
191 rc.left=rc.right+1;
192 rc.right=crc.right;
193 rs = rc.Width();
194 m_remoteCtl.MoveWindow(rc);
195 }else
196 ASSERT(FALSE);
197 m_localSize = ls; m_remoteSize = rs;
198}
199
200void T42View::OnSize(UINT nType, int cx, int cy)
201{
202 CFormView::OnSize(nType, cx, cy);
203 if(m_bShown)
204 RecalcLayout();
205}
206
207LRESULT T42View::OnSplitterBDown(WPARAM,LPARAM)
208{
209 SetCapture();
210 m_bTracking = TRUE;
211CRect rc;
212 GetClientRect(rc);
213 if(m_Ort==ortHorizontal){
214 ASSERT(rc.Height()>25);
215 rc.top+=10;
216 rc.bottom-=10;
217 }else{
218 ASSERT(rc.Width()>25);
219 rc.left+=10;
220 rc.right-=10;
221 }
222 ClientToScreen(rc);
223 ClipCursor(&rc);
224 return 0;
225}
226
227void T42View::OnMouseMove(UINT nFlags, CPoint point)
228{
229 if(m_bTracking){
230 CRect rc;
231 GetClientRect(rc);
232 if(m_Ort==ortHorizontal){
233 m_localSize = point.y;
234 m_remoteSize = rc.bottom-point.y;
235 }else{
236 m_localSize = point.x;
237 m_remoteSize = rc.right-point.x;
238 }
239 RecalcLayout();
240 }
241
242 CFormView::OnMouseMove(nFlags, point);
243}
244
245void T42View::OnLButtonUp(UINT nFlags, CPoint point)
246{
247 if(m_bTracking){
248 ClipCursor(NULL);
249 m_bTracking=FALSE;
250 ReleaseCapture();
251 }
252 CFormView::OnLButtonUp(nFlags, point);
253}
254/////////////////////////////////////////////////////////////////////////////
255// CLocalCtl
256
257CLocalCtl::CLocalCtl()
258{
259CT42App* app = (CT42App*)AfxGetApp();
260 m_bgColor = app->m_crT42LocalBG;
261 memmove(&m_fmtUser,&app->m_fmtT42Local,sizeof(m_fmtUser));
262 memmove(&m_fmtSystem,&app->m_fmtT42System,sizeof(m_fmtSystem));
263}
264
265CLocalCtl::~CLocalCtl()
266{
267}
268
269
270BEGIN_MESSAGE_MAP(CLocalCtl, CRichTalkCtl)
271 //{{AFX_MSG_MAP(CLocalCtl)
272 ON_WM_CREATE()
273 ON_WM_CHAR()
274 ON_WM_KEYDOWN()
275 //}}AFX_MSG_MAP
276END_MESSAGE_MAP()
277
278/////////////////////////////////////////////////////////////////////////////
279// CLocalCtl message handlers
280/////////////////////////////////////////////////////////////////////////////
281// CRemoteCtl
282
283CRemoteCtl::CRemoteCtl()
284{
285CT42App* app = (CT42App*)AfxGetApp();
286 m_bgColor = app->m_crT42RemoteBG;
287 memmove(&m_fmtUser,&app->m_fmtT42Remote,sizeof(m_fmtUser));
288 memmove(&m_fmtSystem,&app->m_fmtT42System,sizeof(m_fmtSystem));
289}
290
291CRemoteCtl::~CRemoteCtl()
292{
293}
294
295
296BEGIN_MESSAGE_MAP(CRemoteCtl, CRichTalkCtl)
297 //{{AFX_MSG_MAP(CRemoteCtl)
298 ON_WM_CREATE()
299 ON_WM_CHAR()
300 ON_WM_KEYDOWN()
301 //}}AFX_MSG_MAP
302END_MESSAGE_MAP()
303
304/////////////////////////////////////////////////////////////////////////////
305// CRemoteCtl message handlers
306
307void CRichTalkCtl::Setup()
308{
309 ModifyStyle(0,WS_VSCROLL);
310 SetOptions(ECOOP_SET,ECO_AUTOWORDSELECTION|ECO_AUTOVSCROLL|ECO_READONLY|
311 ECO_WANTRETURN|ECO_SAVESEL|ECO_SELECTIONBAR|ECO_NOHIDESEL);
312 SetTargetDevice(NULL,0);
313 SetSel(0,-1);
314PARAFORMAT pf;
315 memset(&pf,0,sizeof(pf));
316 pf.cbSize = sizeof(pf);
317 pf.dwMask = PFM_OFFSET;
318 pf.dxOffset = 20;
319 SetParaFormat(pf);
320 SetDefaultCharFormat(m_fmtUser);
321 SetSelectionCharFormat(m_fmtUser);
322 SetSel(-1,-1);
323 SetColor();
324}
325
326int CRemoteCtl::OnCreate(LPCREATESTRUCT lpCreateStruct)
327{
328 if (CRichEditCtrl::OnCreate(lpCreateStruct) == -1)
329 return -1;
330 Setup();
331 return 0;
332}
333
334int CLocalCtl::OnCreate(LPCREATESTRUCT lpCreateStruct)
335{
336 if (CRichEditCtrl::OnCreate(lpCreateStruct) == -1)
337 return -1;
338 Setup();
339 return 0;
340}
341
342void CLocalCtl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
343{
344 if(!m_pView->m_bEnabled)
345 return;
346 if(!(nFlags&0x8000)){
347 ASSERT(m_pView && m_pView->m_pFrame);
348 if(nChar=='\r')
349 nChar='\n';
350 UINT c = nChar;
351 if(c=='\b')
352 c=m_pOuTEC->m_cErase;
353 m_pView->m_pFrame->PostMessage(WM_TALKCHAR,c);
354 PutCharacter(nChar);
355 }
356}
357
358void CRemoteCtl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
359{
360 if(!m_pView->m_bEnabled)
361 return;
362 if(!(nFlags&0x8000)){
363 ASSERT(m_pView && m_pView->m_pFrame);
364 if(nChar=='\r')
365 nChar='\n';
366 UINT c = nChar;
367 if(c=='\b')
368 c=m_pOuTEC->m_cErase;
369 m_pView->m_pFrame->PostMessage(WM_TALKCHAR,c);
370 m_pView->m_localCtl.SetFocus();
371 m_pView->m_localCtl.PutCharacter(nChar);
372 }
373}
374
375void CRichTalkCtl::PutString(LPCTSTR str)
376{
377CString s = str;
378CHAR span[] = { '\r','\n','\a','\b',m_pInTEC->m_cErase,0 };
379CString sss;
380 while(!s.IsEmpty()){
381 sss=s.SpanExcluding(span);
382 if(!sss.IsEmpty()){
383 BOOL bDo = !GetTextLength();
384 SetSel(-1,-1);
385 long ss,es;
386 if(bDo)
387 GetSel(ss,es);
388 ReplaceSel(sss);
389 if(bDo){
390 SetSel(ss,-1);
391 SetSelectionCharFormat(m_fmtUser);
392 SetSel(-1,-1);
393 }
394 s = s.Mid(sss.GetLength());
395 }
396 if(!s.IsEmpty()){
397 PutCharacter(s[0]);
398 s=s.Mid(1);
399 }
400 }
401 UnlockWindowUpdate();
402}
403
404void CRichTalkCtl::PutCharacter(CHAR c)
405{
406 if(c=='\r')
407 return;
408 if(c=='\a'){
409 CT42App* app = (CT42App*)AfxGetApp();
410 ASSERT(app);
411 app->StartSound(app->m_sndT42Bell);
412 return;
413 }else if(c=='\b' || c==m_pInTEC->m_cErase){
414 SetSel(-1,-1);
415 CHARRANGE cr;
416 GetSel(cr);
417 if(cr.cpMin>0){
418 cr.cpMin--;
419 SetSel(cr);
420 ReplaceSel("");
421 }else
422 MessageBeep(0xFFFFFFFF);
423 return;
424 }
425BOOL bDo = !GetTextLength();
426 SetSel(-1,-1);
427char tmp[2] = {c,0};
428long ss,es;
429 if(bDo)
430 GetSel(ss,es);
431 ReplaceSel(tmp);
432 if(bDo){
433 SetSel(ss,-1);
434 SetSelectionCharFormat(m_fmtUser);
435 SetSel(-1,-1);
436 }
437 UnlockWindowUpdate();
438}
439
440void CRichTalkCtl::SystemMessage(LPCTSTR str)
441{
442 SetSel(-1,-1);
443
444 if(
445 GetTextLength()
446 && LineLength()
447 )
448 ReplaceSel("\n");
449
450CString tmp = "[";
451 tmp+=str;
452 tmp+=']';
453long ss,es;
454 GetSel(ss,es);
455 ReplaceSel(tmp);
456 SetSel(ss,-1);
457 SetSelectionCharFormat(m_fmtSystem);
458 SetSel(-1,-1);
459 GetSel(ss,es);
460 ReplaceSel("\n");
461 SetSel(ss,-1);
462 SetSelectionCharFormat(m_fmtUser);
463 SetSel(-1,-1);
464 UnlockWindowUpdate();
465}
466
467BOOL T42View::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
468{
469BOOL rv = CFormView::OnSetCursor(pWnd, nHitTest, message);
470 if(rv)
471 return rv;
472 if(pWnd==&m_splitCtl){
473 if(m_Ort==ortVertical){
474 SetCursor(m_hVertCursor);
475 }else{
476 SetCursor(m_hHorzCursor);
477 }
478 return TRUE;
479 }
480 return FALSE;
481}
482
483void CLocalCtl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
484{
485 CRichTalkCtl::OnKeyDown(nChar, nRepCnt, nFlags);
486}
487
488void CRichTalkCtl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
489{
490 switch(nChar){
491 caseVK_INSERT:
492 caseVK_DELETE:
493 caseVK_BACK:
494 caseVK_ESCAPE:
495 return;
496 }
497 CRichEditCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
498}
499
500void CRemoteCtl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
501{
502 CRichTalkCtl::OnKeyDown(nChar, nRepCnt, nFlags);
503}
504
505void T42View::OnWindowSplitequally()
506{
507 m_localSize = m_remoteSize = 50;
508 RecalcLayout();
509}
510
511void T42View::OnUpdateWindowHorizontalsplit(CCmdUI* pCmdUI)
512{
513 pCmdUI->SetRadio(m_Ort==ortHorizontal);
514}
515
516void T42View::OnUpdateWindowVerticalsplit(CCmdUI* pCmdUI)
517{
518 pCmdUI->SetRadio(m_Ort==ortVertical);
519}
520
521void T42View::OnWindowHorizontalsplit()
522{
523 m_Ort = ortHorizontal;
524 RecalcLayout();
525}
526
527void T42View::OnWindowVerticalsplit()
528{
529 m_Ort = ortVertical;
530 RecalcLayout();
531}
532
533
534void T42View::SetEnable(BOOL bEnable)
535{
536 m_bEnabled = bEnable;
537 m_localCtl.SetColor();
538 m_remoteCtl.SetColor();
539}
540
541void CRichTalkCtl::SetColor()
542{
543 if(m_pView->m_bEnabled)
544 SetBackgroundColor(FALSE,m_bgColor);
545 else{
546 SetBackgroundColor(
547 FALSE,
548 RGB(
549 GetRValue(m_bgColor)/2,
550 GetGValue(m_bgColor)/2,
551 GetBValue(m_bgColor)/2
552 )
553 );
554 }
555}
556
557void T42View::OnEditCopy()
558{
559CWnd* pWnd = GetFocus();
560 if(pWnd==&m_localCtl)
561 m_localCtl.Copy();
562 else if(pWnd==&m_remoteCtl)
563 m_remoteCtl.Copy();
564 else
565 MessageBeep(MB_OK);
566}
567
568void T42View::OnEditPaste()
569{
570 ASSERT(m_pFrame);
571 if(!m_bEnabled)
572 return;
573 if(!IsClipboardFormatAvailable(CF_TEXT))
574 return;
575 if(!OpenClipboard())
576 return;
577HANDLE h = GetClipboardData(CF_TEXT);
578LPVOID gl = GlobalLock(h);
579 ASSERT(gl);
580 m_pFrame->SendMessage(WM_TALKCHAR,0,(LPARAM)gl);
581 m_localCtl.PutString((LPCTSTR)gl);
582 GlobalUnlock(h);
583 CloseClipboard();
584}
585
586void T42View::OnUpdateEditPaste(CCmdUI* pCmdUI)
587{
588 pCmdUI->Enable(m_bEnabled && IsClipboardFormatAvailable(CF_TEXT));
589}
590
591void T42View::SaveLayout()
592{
593CWinApp* app = AfxGetApp();
594 app->WriteProfileInt("T42View","LocalSize",m_localSize);
595 app->WriteProfileInt("T42View","RemoteSize",m_remoteSize);
596 app->WriteProfileInt("T42View","Orientation",m_Ort);
597}
598
599void T42View::OnCancelMode()
600{
601 CFormView::OnCancelMode();
602 if(m_bTracking){
603 ClipCursor(NULL);
604 m_bTracking=FALSE;
605 ReleaseCapture();
606 }
607}
608
609void T42View::LoadLayout()
610{
611CWinApp* app = AfxGetApp();
612 m_localSize = app->GetProfileInt("T42View","LocalSize",m_localSize);
613 m_remoteSize = app->GetProfileInt("T42View","RemoteSize",m_remoteSize);
614_orientation ortSave = m_Ort;
615 m_Ort = (_orientation)app->GetProfileInt("T42View","Orientation",m_Ort);
616 if(m_Ort!=ortHorizontal && m_Ort!=ortVertical)
617 m_Ort=ortSave;
618}
619
620void T42View::SystemMessage(LPCTSTR str)
621{
622CT42App* app = (CT42App*)AfxGetApp();
623 m_localCtl.SystemMessage(str);
624 m_remoteCtl.SystemMessage(str);
625}
626
627
628void T42View::OnUpdateTeaSave(CCmdUI* pCmdUI)
629{
630 pCmdUI->Enable(m_localCtl.GetTextLength() || m_remoteCtl.GetTextLength());
631}
632
633void T42View::OnTeaSave()
634{
635CString dfn;
636 dfn.Format(IDS_FILENAME_T42,m_pFrame->m_LocalUser,m_pFrame->m_Target);
637CString filter;
638 VERIFY(filter.LoadString(IDS_FILTER_RTF));
639CFileDialog fd(FALSE,".rtf",dfn,
640 OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_EXPLORER|
641 OFN_LONGNAMES|OFN_NOREADONLYRETURN|OFN_PATHMUSTEXIST,
642 filter,this
643 );
644 if(fd.DoModal()==IDOK){
645 try{
646 CStdioFile f(fd.GetPathName(),
647 CFile::modeCreate|CFile::modeWrite|CFile::shareDenyWrite|
648 CFile::typeText);
649 CString rtf;
650 rtf.Format(IDS_RTF_HEAD,m_pFrame->m_LocalUser,m_pFrame->m_Target);
651 f.WriteString(rtf);
652 CMemFile mf(2048);
653 EDITSTREAM es;
654 memset(&es,0,sizeof(es));
655 es.dwCookie = (DWORD)&mf;
656 es.pfnCallback = ESINProc;
657 m_localCtl.StreamOut(SF_RTF,es);
658 UINT tmp=0;
659 mf.Write(&tmp,1);
660 LONG bytes = mf.GetLength();
661 LPBYTE pd = mf.Detach();
662 LPTSTR str;
663 while(str = strstr((LPCTSTR)pd,"\\rtf1"))memmove(str,&str[5],strlen(str)-4);
664 while(str = strstr((LPCTSTR)pd,"\\pard"))memmove(str,&str[5],strlen(str)-4);
665 f.Write(pd,strlen((LPCTSTR)pd));
666 rtf.LoadString(IDS_RTF_DELIMITER);
667 f.WriteString(rtf);
668 mf.Attach(pd,bytes,2048);
669 memset(&es,0,sizeof(es));
670 es.dwCookie = (DWORD)&mf;
671 es.pfnCallback = ESINProc;
672 m_remoteCtl.StreamOut(SF_RTF,es);
673 mf.Write(&tmp,1);
674 bytes = mf.GetLength();
675 pd = mf.Detach();
676 while(str = strstr((LPCTSTR)pd,"\\rtf1"))memmove(str,&str[5],strlen(str)-4);
677 while(str = strstr((LPCTSTR)pd,"\\pard"))memmove(str,&str[5],strlen(str)-4);
678 f.Write(pd,strlen((LPCTSTR)pd));
679 rtf.LoadString(IDS_RTF_TAIL);
680 f.WriteString(rtf);
681 delete pd;
682 f.Close();
683 }catch(CException* e){
684 TRACE0("Write exception\n");
685 e->Delete();
686 }
687 }
688}
689
690DWORD CALLBACK T42View::ESINProc(DWORD dwCookie,LPBYTE pbBuff,LONG cb,LONG FAR *pcb)
691{
692CFile* f = (CFile*)dwCookie;
693 try{
694 f->Write(pbBuff,cb);
695 (*pcb)=cb;
696 }catch(CException* e){
697 e->Delete();
698 TRACE0("Save Exception\n");
699 (*pcb)=0;
700 return 1;
701 }
702 return 0;
703}