disdialog.cpp
资源名称:display.rar [点击查看]
上传用户:qie0807
上传日期:2014-09-18
资源大小:413k
文件大小:5k
源码类别:
CAD
开发平台:
Visual C++
- // disdialog.cpp : implementation file
- //
- #include "StdAfx.h"
- #include "resource.h"
- #include "disdialog.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // disdialog dialog
- disdialog::disdialog(CWnd* pParent /*=NULL*/)
- : CDialog(disdialog::IDD, pParent)
- {
- //{{AFX_DATA_INIT(disdialog)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void disdialog::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(disdialog)
- DDX_Control(pDX, IDC_EDIT3, m_face_size);
- DDX_Control(pDX, IDC_EDIT2, m_face_class);
- DDX_Control(pDX, IDC_EDIT1, m_tun_name);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(disdialog, CDialog)
- //{{AFX_MSG_MAP(disdialog)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // disdialog message handlers
- char ch1[50];
- char ch2[50];
- char ch3[50];
- struct mytag //建立巷道属性表结构
- {
- double nameind; //索引号
- char name[50]; //巷道名称
- float enddist;
- float endhigh;
- float twidth;
- float bwidth;
- float wallhigh;
- int tunneltype;//巷道类型
- }temtag; //temtag结构存放巷道属性值
- void diswindow()
- {
- //TODO:Implement the command.
- struct resbuf *rbEnt;
- struct resbuf *rbTrav;
- ads_name ent;
- ads_point pt;
- char mktext[50];
- // char cmpmktext[50];
- int cmp1=0;
- int cmp2=0;
- acedEntSel(NULL,ent,pt);//选择文本实体
- rbEnt=acdbEntGet(ent);//获得文本实体
- if(!rbEnt)
- {
- acutPrintf("nFailed to get entities result buffer linked list.");
- return;
- }
- rbTrav=rbEnt;
- while(rbTrav)
- {
- switch(rbTrav->restype)
- {
- case 1:
- sprintf(mktext,"%s",rbTrav->resval.rstring);//给变量赋值
- acutPrintf("nThe entity text is <Entity name:%s>",mktext);
- break;
- default:
- break;
- }
- rbTrav=rbTrav->rbnext;
- }
- if (rbEnt)
- {
- acutRelRb(rbEnt);
- }
- //文件路径字符串赋值给FILENAME变量
- CString FILENAME= "D:/wzy/Db3";
- char attQuery[256];
- sprintf(attQuery,"SELECT * FROM 巷道属性表");//设置SQL查寻语句
- CDaoDatabase db; //声明一个数据库对象
- //按指定路径打开数据库
- db.Open(FILENAME,FALSE,FALSE,_T(""));
- CDaoRecordset att_rs(&db);//记录集与数据库连接
- if (att_rs.IsOpen()) att_rs.Close();
- att_rs.Open(dbOpenDynaset,attQuery,0);//动态打开记录集
- //读取属性表数据
- int iRecords =att_rs.GetRecordCount();//统计记录个数
- if (!att_rs.IsBOF()) att_rs.MoveFirst();//把指针移到开始处
- while (!att_rs.IsEOF())
- {
- COleVariant vNameInd =att_rs.GetFieldValue("NameIndex");
- COleVariant vTunName =att_rs.GetFieldValue("Name");
- COleVariant vEndDist = att_rs.GetFieldValue("EndDist");
- COleVariant vEndHigh = att_rs.GetFieldValue("EndHigh");
- COleVariant vTopWidth = att_rs.GetFieldValue("TopWith");
- COleVariant vButWidth = att_rs.GetFieldValue("ButtomWith");
- COleVariant vWallHigh = att_rs.GetFieldValue("WallHigh");
- COleVariant vTunType = att_rs.GetFieldValue("Tunneltype");
- //程序结构变量提取属性数据库字段值
- sprintf(temtag.name,"%s",vTunName.bstrVal);
- cmp2=strcmp(mktext,temtag.name);
- if(cmp2==0)
- {
- temtag.nameind=vNameInd.lVal; //巷道名称索引号
- sprintf(temtag.name,"%s",vTunName.bstrVal);//巷道名称字符串
- temtag.enddist=vEndDist.fltVal; //点至掌头的距离
- temtag.endhigh=vEndHigh.fltVal; //掌头底板高程或煤仓底部高程
- temtag.twidth=vTopWidth.fltVal; //巷道断面上宽或煤仓半径
- temtag.bwidth=vButWidth.fltVal; //巷道断面下宽
- temtag.wallhigh=vWallHigh.fltVal; //拱形指墙高,非拱形指净高
- temtag.tunneltype=vTunType.intVal;//巷道断面类型:701-拱形;703-圆形;702-其它
- break;
- }
- else
- att_rs.MoveNext();//指到下一条属性记录
- }//循环结束(while)
- switch(temtag.tunneltype)
- {
- case 701:
- sprintf(ch1,"%s",temtag.name);
- sprintf(ch2,"拱 形");
- sprintf(ch3,"下宽:%1.1fm 墙高: %1.1fm",temtag.bwidth,temtag.wallhigh);
- break;
- case 702:
- sprintf(ch1,"%s",temtag.name);
- sprintf(ch2,"梯 形");
- sprintf(ch3,"上宽:%1.1fm 下宽:%1.1fm 高:%1.1fm",temtag.twidth,temtag.bwidth,temtag.wallhigh);
- break;
- case 703:
- sprintf(ch1,"%s",temtag.name);
- sprintf(ch2,"圆 形");
- sprintf(ch3,"半径: %1.1fm",temtag.twidth);
- break;
- }
- att_rs.Close();//关闭巷道属性记录集
- CAcModuleResourceOverride resOverride;
- disdialog dlg(CWnd::FromHandle(adsw_acadMainWnd()));
- if(dlg.DoModal()==IDOK)
- {
- acutPrintf("naccessful");
- }//if
- return;
- }
- BOOL disdialog::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- m_tun_name.SetWindowText(ch1);
- m_face_class.SetWindowText(ch2);
- m_face_size.SetWindowText(ch3);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }