NewEditWrite.cpp
资源名称:CAD2006.rar [点击查看]
上传用户:ckg1000
上传日期:2013-01-26
资源大小:630k
文件大小:5k
源码类别:
CAD
开发平台:
Visual C++
- // NewEditWrite.cpp : implementation file
- //
- #include "stdafx.h"
- #include "CAD2006.h"
- #include "NewEditWrite.h"
- #include "CAD2006View.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- static int index = -1;
- static bool bln = false;
- /////////////////////////////////////////////////////////////////////////////
- // NewEditWrite
- NewEditWrite::NewEditWrite()
- {
- }
- NewEditWrite::~NewEditWrite()
- {
- }
- BEGIN_MESSAGE_MAP(NewEditWrite, CEdit)
- //{{AFX_MSG_MAP(NewEditWrite)
- ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
- ON_CONTROL_REFLECT(EN_SETFOCUS, OnSetfocus)
- ON_WM_KEYDOWN()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // NewEditWrite message handlers
- void NewEditWrite::OnChange()
- {
- // TODO: Add your control notification handler code here
- CString text;
- NewListBox * m_listbox = (NewListBox *)::AfxGetApp()->m_pMainWnd;
- this->GetWindowText(text);
- index = text.Find("::");
- if( bln )
- {
- // CMainFrame *m_frame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- // select = m_list->SelectString(-1,(LPCTSTR)text.operator [](index + 2));
- TCHAR a = text.operator [](index + 2);
- m_listbox->Find(&"121345");
- }
- if( index != -1 )
- {
- CPoint m_point;
- int i = text.Find("::");
- m_point = this->PosFromChar(i+1);
- ::AfxGetApp()->m_pMainWnd->ClientToScreen(&m_point);
- CRect rect;
- rect.left = m_point.x;
- rect.top = m_point.y-20;
- rect.right = m_point.x+250;
- rect.bottom = m_point.y+40;
- m_listbox->Draw(rect);
- bln = true;
- }
- }
- void NewEditWrite::OnSetfocus()
- {
- // TODO: Add your control notification handler code here
- bln= false;
- CPoint m_point = this->PosFromChar(' ');
- ::AfxGetApp()->m_pMainWnd->ClientToScreen(&m_point);
- }
- void NewEditWrite::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // TODO: Add your message handler code here and/or call default
- if( nChar == 13 )
- {
- NewListBox * m_listbox = (NewListBox *)::AfxGetApp()->m_pMainWnd;
- CString text;
- this->GetWindowText(text);
- text.MakeLower();
- int line = text.Find(&"line(");
- int rect = text.Find(&"rect(");
- int circle = text.Find(&"circle(");
- if( line != -1 )
- {
- CString temp1;
- CString temp4;
- CString x;
- CString y;
- CString x1;
- CString y1;
- CPoint pointbegin;
- CPoint pointend;
- ::AfxExtractSubString(temp1,text.operator LPCTSTR(),0,',');
- ::AfxExtractSubString(y,text.operator LPCTSTR(),1,',');
- ::AfxExtractSubString(x1,text.operator LPCTSTR(),2,',');
- ::AfxExtractSubString(temp4,text.operator LPCTSTR(),3,',');
- AfxExtractSubString(x,temp1.operator LPCTSTR(),1,'(');
- AfxExtractSubString(y1,temp4.operator LPCTSTR(),0,')');
- pointbegin.x = atoi(x.operator LPCTSTR());
- pointbegin.y = atoi(y.operator LPCTSTR());
- pointend.x = atoi(x1.operator LPCTSTR());
- pointend.y = atoi(y1.operator LPCTSTR());
- //::AfxGetApp()->GetMainWnd()->ScreenToClient(&pointbegin);
- //::AfxGetApp()->GetMainWnd()->ScreenToClient(&pointend);
- ::AfxGetApp()->m_pMainWnd->GetDC()->MoveTo(pointbegin);
- ::AfxGetApp()->m_pMainWnd->GetDC()->LineTo(pointend);
- SetWindowText("");
- this->SetFocus();
- }
- else if( rect != -1 )
- {
- CString temp1;
- CString temp4;
- CString x;
- CString y;
- CString x1;
- CString y1;
- CPoint pointbegin;
- CPoint pointend;
- ::AfxExtractSubString(temp1,text.operator LPCTSTR(),0,',');
- ::AfxExtractSubString(y,text.operator LPCTSTR(),1,',');
- ::AfxExtractSubString(x1,text.operator LPCTSTR(),2,',');
- ::AfxExtractSubString(temp4,text.operator LPCTSTR(),3,',');
- AfxExtractSubString(x,temp1.operator LPCTSTR(),1,'(');
- AfxExtractSubString(y1,temp4.operator LPCTSTR(),0,')');
- pointbegin.x = atoi(x.operator LPCTSTR());
- pointbegin.y = atoi(y.operator LPCTSTR());
- pointend.x = atoi(x1.operator LPCTSTR());
- pointend.y = atoi(y1.operator LPCTSTR());
- //::AfxGetApp()->GetMainWnd()->ScreenToClient(&pointbegin);
- //::AfxGetApp()->GetMainWnd()->ScreenToClient(&pointend);
- ::AfxGetApp()->m_pMainWnd->GetDC()->Rectangle(pointbegin.x,pointbegin.y,pointend.x,pointend.y);
- SetWindowText("");
- }
- else if( circle != -1 )
- {
- CString temp1;
- CString temp4;
- CString x;
- CString y;
- CString x1;
- CString y1;
- CPoint pointbegin;
- CPoint pointend;
- ::AfxExtractSubString(temp1,text.operator LPCTSTR(),0,',');
- ::AfxExtractSubString(y,text.operator LPCTSTR(),1,',');
- ::AfxExtractSubString(x1,text.operator LPCTSTR(),2,',');
- ::AfxExtractSubString(temp4,text.operator LPCTSTR(),3,',');
- AfxExtractSubString(x,temp1.operator LPCTSTR(),1,'(');
- AfxExtractSubString(y1,temp4.operator LPCTSTR(),0,')');
- pointbegin.x = atoi(x.operator LPCTSTR());
- pointbegin.y = atoi(y.operator LPCTSTR());
- pointend.x = atoi(x1.operator LPCTSTR());
- pointend.y = atoi(y1.operator LPCTSTR());
- //::AfxGetApp()->GetMainWnd()->ScreenToClient(&pointbegin);
- //::AfxGetApp()->GetMainWnd()->ScreenToClient(&pointend);
- ::AfxGetApp()->m_pMainWnd->GetDC()->Ellipse(pointbegin.x,pointbegin.y,pointend.x,pointend.y);
- SetWindowText("");
- }
- else if( !text.IsEmpty() )
- {
- ::AfxMessageBox("语法错误,请重新输入!");
- SetWindowText("");
- SetFocus();
- }
- }
- CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
- }