www.pudn.com > CreateCEdit.rar > CreateCEditView.cpp
// CreateCEditView.cpp : implementation of the CCreateCEditView class
//
#include "stdafx.h"
#include "CreateCEdit.h"
#include "CreateCEditDoc.h"
#include "CreateCEditView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCreateCEditView
IMPLEMENT_DYNCREATE(CCreateCEditView, CFormView)
BEGIN_MESSAGE_MAP(CCreateCEditView, CFormView)
//{{AFX_MSG_MAP(CCreateCEditView)
ON_BN_CLICKED(IDC_BTN_OK, OnBtnOk)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCreateCEditView construction/destruction
CCreateCEditView::CCreateCEditView()
: CFormView(CCreateCEditView::IDD)
{
//{{AFX_DATA_INIT(CCreateCEditView)
m_edit_id = 101;
m_edit_left = 50;
m_edit_right = 150;
m_edit_top = 200;
m_edit_bottom = 220;
m_edit_maxlen = 10;
pEdt = NULL;
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CCreateCEditView::~CCreateCEditView()
{
}
void CCreateCEditView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCreateCEditView)
DDX_Text(pDX, IDC_EDIT_ID, m_edit_id);
DDX_Text(pDX, IDC_EDIT_LEFT, m_edit_left);
DDX_Text(pDX, IDC_EDIT_RIGHT, m_edit_right);
DDX_Text(pDX, IDC_EDIT_TOP, m_edit_top);
DDX_Text(pDX, IDC_EDIT_BOTTOM, m_edit_bottom);
DDX_Text(pDX, IDC_EDIT_MAXLEN, m_edit_maxlen);
//}}AFX_DATA_MAP
}
BOOL CCreateCEditView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CCreateCEditView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
/////////////////////////////////////////////////////////////////////////////
// CCreateCEditView printing
BOOL CCreateCEditView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCreateCEditView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCreateCEditView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CCreateCEditView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CCreateCEditView diagnostics
#ifdef _DEBUG
void CCreateCEditView::AssertValid() const
{
CFormView::AssertValid();
}
void CCreateCEditView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CCreateCEditDoc* CCreateCEditView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCreateCEditDoc)));
return (CCreateCEditDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCreateCEditView message handlers
void CCreateCEditView::OnBtnOk()
{
// TODO: Add your control notification handler code here
UpdateData(true);
if(m_edit_bottom <= m_edit_top)
{
AfxMessageBox("'BOTTOM'<='TOP'");
return;
}
if(m_edit_right <= m_edit_left)
{
AfxMessageBox("'RIGHT'<='LEFT'");
return;
}
if(pEdt != NULL) delete pEdt;
pEdt = new CEdit;
pEdt->Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP,CRect(m_edit_left,m_edit_top,m_edit_right,m_edit_bottom), this, m_edit_id);
pEdt->ModifyStyleEx(0,WS_EX_CLIENTEDGE,SWP_DRAWFRAME);
pEdt->SetLimitText(m_edit_maxlen);
}