www.pudn.com > edpos.zip > EdPosView.cpp
// EdPosView.cpp : implementation of the CEdPosView class
//
#include "stdafx.h"
#include "EdPos.h"
#include "EdPosDoc.h"
#include "EdPosView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEdPosView
IMPLEMENT_DYNCREATE(CEdPosView, CEditView)
BEGIN_MESSAGE_MAP(CEdPosView, CEditView)
//{{AFX_MSG_MAP(CEdPosView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEdPosView construction/destruction
CEdPosView::CEdPosView()
{
// TODO: add construction code here
}
CEdPosView::~CEdPosView()
{
}
BOOL CEdPosView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
BOOL bPreCreated = CEditView::PreCreateWindow(cs);
cs.style &= ~(ES_AUTOHSCROLL|WS_HSCROLL); // Enable word-wrapping
return bPreCreated;
}
/////////////////////////////////////////////////////////////////////////////
// CEdPosView drawing
void CEdPosView::OnDraw(CDC* pDC)
{
CEdPosDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CEdPosView diagnostics
#ifdef _DEBUG
void CEdPosView::AssertValid() const
{
CEditView::AssertValid();
}
void CEdPosView::Dump(CDumpContext& dc) const
{
CEditView::Dump(dc);
}
CEdPosDoc* CEdPosView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEdPosDoc)));
return (CEdPosDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEdPosView message handlers
//SAMPLE: get the edit control and find the line and char offset.
void CEdPosView::ComputeRowCol(int& nLine, int& nChar) const
{
//SAMPLE: get the edit control in the view
CEdit& theControl = GetEditCtrl();
//SAMPLE: grab the selection
int nStart, nEnd;
theControl.GetSel(nStart, nEnd);
//SAMPLE: what line is the cursor on?
// what is the starting character position for that line?
int nControlLine = theControl.LineFromChar(nEnd);
int nLineIndex = theControl.LineIndex(nControlLine);
//SAMPLE: compute and return the line/col offsets
nLine = nControlLine + 1;
nChar = nStart - nLineIndex + 1;
}