Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[dad864]: TextView.cpp Maximize Restore History

Download this file

TextView.cpp    82 lines (67 with data), 1.8 kB

 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
// TextView.cpp : implementation file
//
#include "stdafx.h"
#include "chitem.h"
#include "TextView.h"
#include <fcntl.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTextView dialog
CTextView::CTextView(CWnd* pParent /*=NULL*/)
: CDialog(CTextView::IDD, pParent)
{
//{{AFX_DATA_INIT(CTextView)
//}}AFX_DATA_INIT
}
void CTextView::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTextView)
DDX_Control(pDX, IDC_TEXT, m_text_control);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTextView, CDialog)
//{{AFX_MSG_MAP(CTextView)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTextView message handlers
BOOL CTextView::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowText("View text ("+m_file+")");
if(m_text.IsEmpty())
{
int fhandle;
int len;
char *poi;
fhandle=open(m_file,O_RDONLY|O_BINARY);
m_file.Empty();
if(fhandle>0)
{
len=filelength(fhandle);
poi=m_text.GetBufferSetLength(len);
read(fhandle, poi, len);
close(fhandle);
m_text.ReleaseBuffer(-1);
m_text.Replace("\r\n","\n");
}
else
{
OnCancel();
return FALSE;
}
}
m_text_control.SetOptions(ECOOP_OR, ECO_SAVESEL); //prevent auto highlight crap
m_text_control.SetWindowText(m_text);
return TRUE;
}
BOOL CTextView::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::PreTranslateMessage(pMsg);
}