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

📄 layerrecorddlg.cpp

📁 vc 和mapobjects地理信息系统组件开发 很有启发意义和参考价值
💻 CPP
字号:
// LayerRecordDlg.cpp : implementation file
//

#include "stdafx.h"
#include "mapper.h"
#include "LayerRecordDlg.h"

#include "EngHtmlFile.h"
#include "logfile.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CLayerRecordDlg dialog


CLayerRecordDlg::CLayerRecordDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CLayerRecordDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLayerRecordDlg)
	m_sLayer = _T("");
	//}}AFX_DATA_INIT
}


void CLayerRecordDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLayerRecordDlg)
	DDX_Control(pDX, IDC_RECORDS, m_oRecords);
	DDX_Text(pDX, IDC_LAYER, m_sLayer);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLayerRecordDlg, CDialog)
	//{{AFX_MSG_MAP(CLayerRecordDlg)
	ON_BN_CLICKED(IDC_HTML, OnHtml)
	ON_BN_CLICKED(IDC_TEXT, OnText)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLayerRecordDlg message handlers

BOOL CLayerRecordDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	CMoTableDesc table=m_rs.GetTableDesc();
	short i,count=table.GetFieldCount();
	for(i=0;i<count;i++)
	{
		m_oRecords.InsertColumn(i,table.GetFieldName(i));
		m_oRecords.SetColumnWidth(i,50);
	}

	CString s;
	CMoFields fields(m_rs.GetFields());	

	long index;
	m_rs.MoveFirst();
	while(!m_rs.GetEof())
	{
		for(i=0;i<count;i++)
		{
			CMoField field(fields.Item(COleVariant(table.GetFieldName(i))));
			s=field.GetValueAsString();
			if(i==0)
			{
				index=m_oRecords.InsertItem(m_oRecords.GetItemCount(),s);
			}
			else
			{
				m_oRecords.SetItemText(index,i,s);
			}
		}
		m_rs.MoveNext();
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CLayerRecordDlg::OnHtml() 
{
	CFileDialog	fd(FALSE,"htm",NULL,OFN_EXPLORER|OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT,"HTML文件(*.htm)|*.htm||",this);

	if(fd.DoModal()!=IDOK) return;

	CEngHtmlFile ehf;
	ehf.Open(fd.GetPathName());
	ehf.FileTitle("shp记录");
	ehf.OutData2(m_sLayer+"记录",TRUE,TRUE,FALSE,TRUE,TRUE);

	ehf.TableBegin(TRUE);
	CStringArray saInfo;
	
	CMoTableDesc table=m_rs.GetTableDesc();
	short j;
	saInfo.RemoveAll();
	for(j=0;j<table.GetFieldCount();j++)
	{
		saInfo.Add(table.GetFieldName(j));
	}
	ehf.TableRow(saInfo);

	int i,count=m_oRecords.GetItemCount();
	char temp[256];
	for(i=0;i<count;i++)
	{
		saInfo.RemoveAll();
		for(j=0;j<table.GetFieldCount();j++)
		{
			m_oRecords.GetItemText(i,j,temp,256);
			saInfo.Add(temp);
		}
		ehf.TableRow(saInfo);
	}
	ehf.TableEnd();
	ehf.Close();
	AfxMessageBox("输出完毕!");	
}

void CLayerRecordDlg::OnText() 
{
	CFileDialog	fd(FALSE,"txt",NULL,OFN_EXPLORER|OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT,
		"文本TML文件(*.txt)|*.txt||",this);

	if(fd.DoModal()!=IDOK) 
		return;

	CLogFile f;
	f.SetPathFile(fd.GetPathName());

	CStringArray saInfo;
	CMoTableDesc table=m_rs.GetTableDesc();
	short j;
	saInfo.RemoveAll();
	for(j=0;j<table.GetFieldCount();j++)
	{
		saInfo.Add(table.GetFieldName(j));
	}
	
	int i,count=m_oRecords.GetItemCount();
	char temp[256];
	for(i=0;i<count;i++)
	{
		for(j=0;j<table.GetFieldCount();j++)
		{
			m_oRecords.GetItemText(i,j,temp,256);
			f.OutPut(saInfo[j]+": ");
			f.OutPutLine(temp);
		}
		f.OutPutLine("");
	}

	f.OutPutSplitLine('-',60);
	for(j=0;j<table.GetFieldCount();j++)
	{
		f.OutPut(saInfo[j]);
	}
	f.OutPutLine("");

	for(i=0;i<count;i++)
	{
		for(j=0;j<table.GetFieldCount();j++)
		{
			m_oRecords.GetItemText(i,j,temp,256);
			f.OutPut(temp);
		}
		f.OutPutLine("");
	}	

	AfxMessageBox("输出完毕!");		
}

⌨️ 快捷键说明

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