?? arxdlg.cpp
字號:
//-----------------------------------------------------------------------------
//----- ArxDlg.cpp : implementation file
#include "StdAfx.h"
#include "resource.h"
#include "ArxDlg.h"
#include "math.h"
//-----------------------------------------------------------------------------
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC (CArxDlg, CAcUiDialog)
BEGIN_MESSAGE_MAP(CArxDlg, CAcUiDialog)
//{{AFX_MSG_MAP(CArxDlg)
ON_MESSAGE(WM_ACAD_KEEPFOCUS, OnAcadKeepFocus) // Needed for modeless dialog.
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_BTN_POINT, OnBtnPoint)
ON_BN_CLICKED(IDC_BTN_ANGLE, OnBtnAngle)
ON_EN_KILLFOCUS(IDC_EDT_XPT, OnKillfocusEdtXpt)
ON_EN_KILLFOCUS(IDC_EDT_YPT, OnKillfocusEdtYpt)
ON_EN_KILLFOCUS(IDC_EDT_ZPT, OnKillfocusEdtZpt)
ON_EN_KILLFOCUS(IDC_EDT_ANGLE, OnKillfocusEdtAngle)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//-----------------------------------------------------------------------------
CArxDlg::CArxDlg (CWnd* pParent /*=NULL*/, HINSTANCE hInstance /*=NULL*/) : CAcUiDialog (CArxDlg::IDD, pParent, hInstance) {
//{{AFX_DATA_INIT(CArxDlg)
//}}AFX_DATA_INIT
}
void CArxDlg::DoDataExchange (CDataExchange *pDX) {
CAcUiDialog::DoDataExchange (pDX) ;
//{{AFX_DATA_MAP(CArxDlg)
DDX_Control(pDX, IDC_BTN_ANGLE, m_btnAngle);
DDX_Control(pDX, IDC_BTN_POINT, m_btnPoint);
DDX_Control(pDX, IDC_EDT_ANGLE, m_edtAngle);
DDX_Control(pDX, IDC_EDT_XPT, m_edtXpt);
DDX_Control(pDX, IDC_EDT_YPT, m_edtYpt);
DDX_Control(pDX, IDC_EDT_ZPT, m_edtZpt);
//}}AFX_DATA_MAP
}
// Needed for modeless dialogs to keep focus.
// Return FALSE to not keep the focus, return TRUE to keep the focus
LONG CArxDlg::OnAcadKeepFocus(UINT, UINT)
{
return TRUE;
}
//-----------------------------------------------------------------------------
BOOL CArxDlg::OnInitDialog()
{
CAcUiDialog::OnInitDialog();
m_edtXpt.SetRange(-100.0,100.0);
m_edtYpt.SetRange(-100.0,100.0);
m_edtZpt.SetRange(-100.0,100.0);
m_edtAngle.SetRange(0.0,90.0);
m_btnPoint.AutoLoad();
m_btnAngle.AutoLoad();
// 設(shè)置文本框的默認值
m_strAngle = "0.0";
m_strXpt = "0.0";
m_strYpt = "0.0";
m_strZpt = "0.0";
// 顯示初始點的坐標和角度值
DisplayPoint();
DisplayAngle();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CArxDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
double x = atof(m_strXpt);
double y = atof(m_strYpt);
double z = atof(m_strZpt);
acutPrintf(_T("\n所選中的點為:(%.2f,%.2f,%.2f)\n"),x,y,z);
CAcUiDialog::OnClose();
}
void CArxDlg::OnBtnPoint()
{
// TODO: Add your control notification handler code here
BeginEditorCommand();
ads_point pt;
if (acedGetPoint(NULL,_T("\n選擇一點:\n"),pt) == RTNORM)
{
CompleteEditorCommand();
m_strXpt.Format(_T("%.2f"),pt[X]);
m_strYpt.Format(_T("%.2f"),pt[Y]);
m_strZpt.Format(_T("%.2f"),pt[Z]);
DisplayPoint();
}
else
{
CancelEditorCommand();
}
}
void CArxDlg::OnBtnAngle()
{
// TODO: Add your control notification handler code here
BeginEditorCommand();
ads_point pt;
acdbDisToF(m_strXpt, -1, &pt[X]);
acdbDisToF(m_strYpt, -1, &pt[Y]);
acdbDisToF(m_strZpt, -1, &pt[Z]);
double dAngle;
const double PI = 4 * atan(1);
if (acedGetAngle(pt,_T("\n請輸入角度:\n"),&dAngle) == RTNORM)
{
CompleteEditorCommand();
m_strAngle.Format("%.2f", dAngle * (180.0/PI));
DisplayAngle();
}
else
{
CancelEditorCommand();
}
}
void CArxDlg::OnKillfocusEdtXpt()
{
// TODO: Add your control notification handler code here
m_edtXpt.GetWindowText(m_strXpt);
m_edtXpt.Convert();
}
void CArxDlg::OnKillfocusEdtYpt()
{
// TODO: Add your control notification handler code here
m_edtYpt.Convert();
m_edtYpt.GetWindowText(m_strYpt);
}
void CArxDlg::OnKillfocusEdtZpt()
{
// TODO: Add your control notification handler code here
m_edtZpt.Convert();
m_edtZpt.GetWindowText(m_strZpt);
}
void CArxDlg::DisplayPoint()
{
m_edtXpt.SetWindowText(m_strXpt);
m_edtXpt.Convert();
m_edtYpt.SetWindowText(m_strYpt);
m_edtYpt.Convert();
m_edtZpt.SetWindowText(m_strZpt);
m_edtZpt.Convert();
}
void CArxDlg::DisplayAngle()
{
m_edtAngle.SetWindowText(m_strAngle);
m_edtAngle.Convert();
}
void CArxDlg::OnKillfocusEdtAngle()
{
// TODO: Add your control notification handler code here
m_edtAngle.Convert();
m_edtAngle.GetWindowText(m_strAngle);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -