⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arxmodalessdlg.cpp

📁 c++结合objectarcx
💻 CPP
字号:
//-----------------------------------------------------------------------------
//----- ArxModalessDlg.cpp : implementation file
#include "StdAfx.h"
#include "resource.h"
#include "ArxModalessDlg.h"
#include "dbents.h"
extern CArxModalessDlg* pModalessDlg;
//-----------------------------------------------------------------------------
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC (CArxModalessDlg, CAcUiDialog)

BEGIN_MESSAGE_MAP(CArxModalessDlg, CAcUiDialog)
	//{{AFX_MSG_MAP(CArxModalessDlg)
	ON_MESSAGE(WM_ACAD_KEEPFOCUS, OnAcadKeepFocus)    // Needed for modeless dialog.
	ON_BN_CLICKED(IDC_BTN_CREATELINE, OnBtnCreateline)
	ON_BN_CLICKED(IDC_BTN_ENDPT, OnBtnEndpt)
	ON_BN_CLICKED(IDC_BTN_STARTPT, OnBtnStartpt)
	ON_BN_CLICKED(IDC_BTN_CLOSE, OnBtnClose)
	ON_WM_CLOSE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//-----------------------------------------------------------------------------
CArxModalessDlg::CArxModalessDlg (CWnd* pParent /*=NULL*/, HINSTANCE hInstance /*=NULL*/) : CAcUiDialog (CArxModalessDlg::IDD, pParent, hInstance) {
	//{{AFX_DATA_INIT(CArxModalessDlg)
	m_strEndXpt = _T("");
	m_strEndYpt = _T("");
	m_strEndZpt = _T("");
	m_strStartXpt = _T("");
	m_strStartYpt = _T("");
	m_strStartZpt = _T("");
	//}}AFX_DATA_INIT
}

void CArxModalessDlg::DoDataExchange (CDataExchange *pDX) {
	CAcUiDialog::DoDataExchange (pDX) ;
	//{{AFX_DATA_MAP(CArxModalessDlg)
	DDX_Text(pDX, IDC_EDT_END_XPT, m_strEndXpt);
	DDX_Text(pDX, IDC_EDT_END_YPT, m_strEndYpt);
	DDX_Text(pDX, IDC_EDT_END_ZPT, m_strEndZpt);
	DDX_Text(pDX, IDC_EDT_START_XPT, m_strStartXpt);
	DDX_Text(pDX, IDC_EDT_START_YPT, m_strStartYpt);
	DDX_Text(pDX, IDC_EDT_START_ZPT, m_strStartZpt);
	DDX_Control(pDX, IDC_BTN_STARTPT, m_btnStartPt);
	DDX_Control(pDX, IDC_BTN_ENDPT, m_btnEndPt);
	//}}AFX_DATA_MAP
}

// Needed for modeless dialogs to keep focus.
// Return FALSE to not keep the focus, return TRUE to keep the focus
LONG CArxModalessDlg::OnAcadKeepFocus(UINT, UINT)
{
  return TRUE;
}

//-----------------------------------------------------------------------------

void CArxModalessDlg::OnBtnCreateline() 
{
	// TODO: Add your control notification handler code here
	AcGePoint3d ptStart(atol(m_strStartXpt),atol(m_strStartYpt),atol(m_strStartZpt));
	AcGePoint3d ptEnd(atol(m_strEndXpt),atol(m_strEndYpt),atol(m_strEndZpt));
    
	acDocManager->lockDocument(curDoc());
	AcDbLine* pLine = new AcDbLine(ptStart,ptEnd);

	AcDbBlockTable* pBlkTbl;
	acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl,AcDb::kForRead);

	AcDbBlockTableRecord* pBlkTblRec;
	pBlkTbl->getAt(ACDB_MODEL_SPACE,pBlkTblRec,AcDb::kForWrite);

	AcDbObjectId LineID;
	pBlkTblRec->appendAcDbEntity(LineID,pLine);

	pBlkTbl->close();
	pBlkTblRec->close();
	pLine->close();

	acDocManager->unlockDocument(curDoc());
}

void CArxModalessDlg::OnBtnEndpt() 
{
	// TODO: Add your control notification handler code here
	BeginEditorCommand();
	ads_point pt;
	if (acedGetPoint(NULL,_T("\n请选择终点:\n"),pt) == RTNORM)
	{
		CompleteEditorCommand();
		m_strEndXpt.Format(_T("%.2f"),pt[X]);
		m_strEndYpt.Format(_T("%.2f"),pt[Y]);
		m_strEndZpt.Format(_T("%.2f"),pt[Z]);
	}
	else
	{
		CancelEditorCommand();
	}
	UpdateData(FALSE);	
}

void CArxModalessDlg::OnBtnStartpt() 
{
	// TODO: Add your control notification handler code here
	BeginEditorCommand();
	ads_point pt;
	if (acedGetPoint(NULL,_T("\n请选择起点:\n"),pt) == RTNORM)
	{
		CompleteEditorCommand();
		m_strStartXpt.Format(_T("%.2f"),pt[X]);
		m_strStartYpt.Format(_T("%.2f"),pt[Y]);
		m_strStartZpt.Format(_T("%.2f"),pt[Z]);
	}
	else
	{
		CancelEditorCommand();
	}
	UpdateData(FALSE);	
}

BOOL CArxModalessDlg::OnInitDialog() 
{
	CAcUiDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_btnStartPt.AutoLoad();
	m_btnEndPt.AutoLoad();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CArxModalessDlg::OnBtnClose() 
{
	// TODO: Add your control notification handler code here
	DestroyWindow();
}

void CArxModalessDlg::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	DestroyWindow();
	CAcUiDialog::OnClose();
}

void CArxModalessDlg::PostNcDestroy() 
{
	// TODO: Add your specialized code here and/or call the base class
	delete this;
	if (pModalessDlg!=NULL)
	{
		pModalessDlg = NULL;
	}
	CAcUiDialog::PostNcDestroy();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -