[每日一码] 一些ARX源码完整工程(带注释)
// MyExam07Dlg.cpp : implementation file//
#include "stdafx.h"
#include "MyExam07Dlg.h"
#include "exam07.h"
#ifdef 采用DEBUG
#define new DEBUG采用NEW
#undef THIS采用FILE
static char THIS采用FILE[] = 采用采用FILE采用采用;
#endif
/////////////////////////////////////////////////////////////////////////////
// MyExam07Dlg dialog
MyExam07Dlg::MyExam07Dlg(CWnd* pParent /*=NULL*/)
: CAcUiDialog(MyExam07Dlg::IDD, pParent)
{
//{{AFX采用DATA采用INIT(MyExam07Dlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX采用DATA采用INIT
}
void MyExam07Dlg::DoDataExchange(CDataExchange* pDX)
{
CAcUiDialog::DoDataExchange(pDX);
//{{AFX采用DATA采用MAP(MyExam07Dlg)
DDX采用Control(pDX, IDC采用COMBO采用REGAPPS, m采用ctrlRegAppComboBox);
DDX采用Control(pDX, IDC采用LIST采用BLOCKS, m采用ctrlBlockListBox);
DDX采用Control(pDX, IDC采用EDIT采用ZPT, m采用ctrlZPtEdit);
DDX采用Control(pDX, IDC采用EDIT采用YPT, m采用ctrlYPtEdit);
DDX采用Control(pDX, IDC采用EDIT采用XPT, m采用ctrlXPtEdit);
DDX采用Control(pDX, IDC采用EDIT采用ANGLE, m采用ctrlAngleEdit);
DDX采用Control(pDX, IDC采用BUTTON采用POINT, m采用ctrlPickButton);
DDX采用Control(pDX, IDC采用BUTTON采用ANGLE, m采用ctrlAngleButton);
//}}AFX采用DATA采用MAP
}
BEGIN采用MESSAGE采用MAP(MyExam07Dlg, CAcUiDialog)
//{{AFX采用MSG采用MAP(MyExam07Dlg)
ON采用BN采用CLICKED(IDC采用BUTTON采用ANGLE, OnButtonAngle)
ON采用BN采用CLICKED(IDC采用BUTTON采用POINT, OnButtonPoint)
ON采用CBN采用KILLFOCUS(IDC采用COMBO采用REGAPPS, OnKillfocusComboRegapps)
ON采用EN采用KILLFOCUS(IDC采用EDIT采用ANGLE, OnKillfocusEditAngle)
ON采用EN采用KILLFOCUS(IDC采用EDIT采用XPT, OnKillfocusEditXpt)
ON采用EN采用KILLFOCUS(IDC采用EDIT采用YPT, OnKillfocusEditYpt)
ON采用EN采用KILLFOCUS(IDC采用EDIT采用ZPT, OnKillfocusEditZpt)
//}}AFX采用MSG采用MAP
END采用MESSAGE采用MAP()
/////////////////////////////////////////////////////////////////////////////
// MyExam07Dlg message handlers
BOOL MyExam07Dlg::OnInitDialog()
{
SetDialogName("exam07:MyExam07Dlg");
CAcUiDialog::OnInitDialog();
DLGCTLINFO dlgSizeInfo[]= {
{ IDC采用STATIC采用GROUP1, ELASTICX, 20 },
{ IDC采用STATIC采用GROUP1, ELASTICY, 100 },
{ IDC采用EDIT采用XPT,ELASTICX, 20 },
{ IDC采用EDIT采用YPT,ELASTICX, 20 },
{ IDC采用EDIT采用ZPT,ELASTICX, 20 },
{ IDC采用EDIT采用ANGLE, ELASTICX, 20 },
{ IDC采用STATIC采用GROUP2, MOVEX, 20 },
{ IDC采用STATIC采用GROUP2, ELASTICY, 100 },
{ IDC采用STATIC采用GROUP2, ELASTICX, 80 },
{ IDC采用LIST采用BLOCKS, MOVEX, 20 },
{ IDC采用LIST采用BLOCKS, ELASTICY, 100 },
{ IDC采用STATIC采用TEXT2,MOVEX, 20 },
{ IDC采用STATIC采用TEXT2,MOVEY, 100 },
{ IDC采用LIST采用BLOCKS, ELASTICX, 80 },
{ IDC采用STATIC采用TEXT2,ELASTICX, 80 },
{ IDC采用STATIC采用GROUP3, MOVEY, 100 },
{ IDC采用STATIC采用GROUP3, ELASTICX, 20 },
{ IDC采用COMBO采用REGAPPS, MOVEY, 100 },
{ IDC采用COMBO采用REGAPPS, ELASTICX, 20 },
{ IDC采用STATIC采用TEXT3,MOVEY, 100 },
{ IDC采用STATIC采用TEXT3,ELASTICX, 20 },
{ IDOK,MOVEX, 100 },
{ IDCANCEL, MOVEX, 100 },
};
const DWORD numberofentries =
sizeof dlgSizeInfo / sizeof DLGCTLINFO;
SetControlProperty(dlgSizeInfo, numberofentries);
m采用ctrlXPtEdit.SetRange(-50.0, 50.0);
m采用ctrlYPtEdit.SetRange(-50.0, 50.0);
m采用ctrlZPtEdit.SetRange(-50.0, 50.0);
m采用ctrlAngleEdit.SetRange(0.0, 90.0 /*(PI/2.0)*/);
SetWindowText("AcUiDialog Sample");
m采用ctrlPickButton.AutoLoad();
m采用ctrlAngleButton.AutoLoad();
if (!GetDialogData("ANGLE", m采用strAngle))
m采用strAngle = "0.0";
if (!GetDialogData("POINTX", m采用strXPt))
m采用strXPt = "0.0";
if (!GetDialogData("POINTY", m采用strYPt))
m采用strYPt = "0.0";
if (!GetDialogData("POINTZ", m采用strZPt))
m采用strZPt = "0.0";
DisplayPoint();
DisplayAngle();
DisplayBlocks();
DisplayRegApps();
return TRUE;
}
void MyExam07Dlg::DisplayPoint()
{
m采用ctrlXPtEdit.SetWindowText(m采用strXPt);
m采用ctrlXPtEdit.Convert();
m采用ctrlYPtEdit.SetWindowText(m采用strYPt);
m采用ctrlYPtEdit.Convert();
m采用ctrlZPtEdit.SetWindowText(m采用strZPt);
m采用ctrlZPtEdit.Convert();
}
bool MyExam07Dlg::ValidatePoint()
{
if (!m采用ctrlXPtEdit.Validate())
return false;
if (!m采用ctrlYPtEdit.Validate())
return false;
if (!m采用ctrlZPtEdit.Validate())
return false;
return true;
}
void MyExam07Dlg::DisplayAngle()
{
m采用ctrlAngleEdit.SetWindowText(m采用strAngle);
m采用ctrlAngleEdit.Convert();
}
bool MyExam07Dlg::ValidateAngle()
{
if (!m采用ctrlAngleEdit.Validate())
return false;
return true;
}
void MyExam07Dlg::DisplayBlocks()
{
AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTable, AcDb::kForRead);
char *pName;
AcDbBlockTableIterator *pBTItr;
if (pBlockTable->newIterator(pBTItr) == Acad::eOk)
{
while (!pBTItr->done())
{
AcDbBlockTableRecord *pRecord;
if (pBTItr->getRecord(pRecord, AcDb::kForRead)
== Acad::eOk)
{
pRecord->getName(pName);
m采用ctrlBlockListBox.InsertString(-1, pName);
pRecord->close();
}
pBTItr->step();
}
}
pBlockTable->close();
}
void MyExam07Dlg::DisplayRegApps()
{
AcDbRegAppTable *pRegAppTable;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pRegAppTable, AcDb::kForRead);
char *pName;
AcDbRegAppTableIterator *pItr;
if (pRegAppTable->newIterator(pItr) == Acad::eOk)
{
while (!pItr->done())
{
AcDbRegAppTableRecord *pRecord;
if (pItr->getRecord(pRecord, AcDb::kForRead)
== Acad::eOk)
{
pRecord->getName(pName);
m采用ctrlRegAppComboBox.InsertString(-1, pName);
pRecord->close();
}
pItr->step();
}
}
pRegAppTable->close();
}
void MyExam07Dlg::OnButtonAngle()
{
BeginEditorCommand();
ads采用point pt;
acdbDisToF(m采用strXPt, -1, &pt);
acdbDisToF(m采用strYPt, -1, &pt);
acdbDisToF(m采用strZPt, -1, &pt);
double angle;
if (acedGetAngle(pt, "\nPick an angle: ", &angle) == RTNORM) {
CompleteEditorCommand();
m采用strAngle.Format("%g", angle*(180.0/PI));
DisplayAngle();
}
else
{
CancelEditorCommand();
}
}
void MyExam07Dlg::OnButtonPoint()
{
BeginEditorCommand();
ads采用point pt;
if (acedGetPoint(NULL, "\nPick a point: ", pt) == RTNORM) {
CompleteEditorCommand();
m采用strXPt.Format("%g", pt);
m采用strYPt.Format("%g", pt);
m采用strZPt.Format("%g", pt);
DisplayPoint();
}
else
{
CancelEditorCommand();
}
}
void MyExam07Dlg::OnKillfocusEditAngle()
{
m采用ctrlAngleEdit.Convert();
m采用ctrlAngleEdit.GetWindowText(m采用strAngle);
}
void MyExam07Dlg::OnKillfocusEditXpt()
{
m采用ctrlXPtEdit.Convert();
m采用ctrlXPtEdit.GetWindowText(m采用strXPt);
}
void MyExam07Dlg::OnKillfocusEditYpt()
{
m采用ctrlYPtEdit.Convert();
m采用ctrlYPtEdit.GetWindowText(m采用strYPt);
}
void MyExam07Dlg::OnKillfocusEditZpt()
{
m采用ctrlZPtEdit.Convert();
m采用ctrlZPtEdit.GetWindowText(m采用strZPt);
}
void MyExam07Dlg::OnKillfocusComboRegapps()
{
CString strFromEdit;
m采用ctrlRegAppComboBox.GetWindowText(strFromEdit);
if (m采用ctrlRegAppComboBox.FindString(-1, strFromEdit) == CB采用ERR)
if (acdbRegApp(strFromEdit) == RTNORM)
m采用ctrlRegAppComboBox.AddString(strFromEdit);
}
void MyExam07Dlg::OnOK()
{
if (!ValidatePoint())
{
AfxMessageBox("Sorry, Point out of desired range.");
m采用ctrlXPtEdit.SetFocus();
return;
}
if (!ValidateAngle())
{
AfxMessageBox("Sorry, Angle out of desired range.");
m采用ctrlAngleEdit.SetFocus();
return;
}
SetDialogData("ANGLE", m采用strAngle);
SetDialogData("POINTX", m采用strXPt);
SetDialogData("POINTY", m采用strYPt);
SetDialogData("POINTZ", m采用strZPt);
CAcUiDialog::OnOK();
}
页:
[1]