📄 infodlg.cpp
字号:
// InfoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CampusGis.h"
#include "InfoDlg.h"
#include "sofieldinfo.h"
#include "sofieldinfos.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInfoDlg dialog
CInfoDlg::CInfoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CInfoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CInfoDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CInfoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInfoDlg)
DDX_Control(pDX, IDC_LISTINFO, m_ListInfo);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInfoDlg, CDialog)
//{{AFX_MSG_MAP(CInfoDlg)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInfoDlg message handlers
BOOL CInfoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//初始化ListView
CRect rcClient;
GetClientRect(rcClient);//获得客户区的大小
m_ListInfo.InsertColumn(0,"字段",LVCFMT_LEFT,rcClient.Width()/2,-1);
m_ListInfo.InsertColumn(1,"属性值",LVCFMT_LEFT,rcClient.Width()/2,-1);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CInfoDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect rc;
GetClientRect(rc);
if(::IsWindow(m_ListInfo.m_hWnd))
{
m_ListInfo.MoveWindow(rc);
}
}
BOOL CInfoDlg::InsertRecordset(CsoRecordset* pRecordset)
{
//if recordset is null , exit
if(!pRecordset)
return FALSE;
if(pRecordset->GetRecordCount()==-1)
return FALSE;
// count recordset's record number
long lRecordCount=pRecordset->GetRecordCount();
//count recordset's field number
long lFieldCount=pRecordset->GetFieldCount();
//field information
CsoFieldInfo FieldInfo;
//ListItem index
int nItemIndex;
COleVariant variant;
//显示的文本
CString strValue;
m_ListInfo.DeleteAllItems();
for(long i=1;i<=lFieldCount;i++)
{
FieldInfo=pRecordset->GetFieldInfo(COleVariant(i,VT_I4 ));
nItemIndex=m_ListInfo.InsertItem(i-1,FieldInfo.GetName());
variant=pRecordset->GetFieldValue(COleVariant(i,VT_I4 ));
//使用ColeVariant 类实现数据类型转换
//转换后才能显示在列表控件中
variant.ChangeType(VT_BSTR);
strValue=variant.bstrVal;
m_ListInfo.SetItemText(nItemIndex,1,strValue);
}
m_ListInfo.UpdateWindow();
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -