NewEdit.cpp
资源名称:CAD2006.rar [点击查看]
上传用户:ckg1000
上传日期:2013-01-26
资源大小:630k
文件大小:3k
源码类别:
CAD
开发平台:
Visual C++
- // NewEdit.cpp : implementation file
- //
- #include "stdafx.h"
- #include "CAD2006.h"
- #include "NewEdit.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // NewEdit
- NewEdit::NewEdit()
- {
- m_text = NULL;
- m_rect = NULL;
- }
- NewEdit::~NewEdit()
- {
- for( int i = 0; i < m_ptarray.GetSize(); i++ )
- {
- delete m_ptarray.operator [](i);
- }
- }
- BEGIN_MESSAGE_MAP(NewEdit, CEdit)
- //{{AFX_MSG_MAP(NewEdit)
- ON_WM_KILLFOCUS()
- ON_WM_CHAR()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // NewEdit message handlers
- void NewEdit::draw(CRect rect)
- {
- m_text = new CEdit;
- m_text->Create(WS_CHILD | WS_VISIBLE|ES_AUTOHSCROLL|ES_LEFT,rect,
- ::AfxGetApp()->m_pMainWnd,2000);
- m_text->SetLimitText(10);
- m_text->SetFocus();
- SaveText(m_text);
- }
- void NewEdit::SaveText(CEdit *m_text)
- {
- m_ptarray.Add(m_text);
- }
- void NewEdit::DeleteText(CDC * pDC, int index, CRect rect )
- {
- delete (CEdit *)m_ptarray[index];
- m_ptarray.RemoveAt(index);
- LostTextFouce(pDC,rect);
- }
- void NewEdit::SetTextFouce(CDC *pDC,CRect rect )
- {
- HBRUSH hbrush = (HBRUSH)::GetStockObject(NULL_BRUSH);
- CBrush *hbru = NULL;
- hbru = hbru->FromHandle(hbrush);
- CBrush* hbrutemp = pDC->SelectObject(hbru);
- pDC->Rectangle(&rect);
- pDC->SelectObject(hbrutemp);
- }
- void NewEdit::LostTextFouce(CDC *pDC, CRect rect)
- {
- HBRUSH hbrush = (HBRUSH)::GetStockObject(NULL_BRUSH);
- CBrush *hbru = NULL;
- hbru = hbru->FromHandle(hbrush);
- CBrush* hbrutemp = pDC->SelectObject(hbru);
- CPen hpen;
- hpen.CreatePen(PS_SOLID,1,RGB(255,255,255));
- CPen* pentemp = pDC->SelectObject(&hpen);
- //int temp = pDC->SetROP2(R2_XORPEN);
- pDC->Rectangle(&rect);
- pDC->SelectObject(hbrutemp);
- pDC->SelectObject(pentemp);
- //pDC->SetROP2(temp);
- }
- void NewEdit::SetFouceRect(CRect rect)
- {
- m_rect = rect;
- }
- CRect NewEdit::GetFouceText()
- {
- return m_rect;
- }
- void NewEdit::TextMove(CDC *pDC,CPoint pt,int index,CRect rectrect)
- {
- /* m_rect.left += pt.x - m_rect.CenterPoint().x;
- m_rect.top += pt.y - m_rect.CenterPoint().y;
- m_rect.right += pt.x - m_rect.CenterPoint().x;
- m_rect.bottom += pt.y - m_rect.CenterPoint().y;
- m_textrect.left += pt.x - m_rect.CenterPoint().x;
- m_textrect.top += pt.y - m_rect.CenterPoint().y;
- m_textrect.right += pt.x - m_rect.CenterPoint().x;
- m_textrect.bottom += pt.y - m_rect.CenterPoint().y;
- DeleteText(pDC,index,rectrect);
- pDC->TextOut(m_textrect.left,m_textrect.top,"DSFDS");
- SetTextFouce(pDC,m_rect);
- //m_text->ReplaceSel("sdfdsfds");*/
- }
- void NewEdit::SetFouceTextRect(CRect rect)
- {
- m_textrect = rect;
- }
- CRect NewEdit::GetFouceTextRect()
- {
- return m_textrect;
- }