📄 finddlg.cpp
字号:
// FindDlg.cpp : implementation file
//
/*
* This sample application and corresponding sample code is provided
* for example purposes only. It has not undergone rigorous testing
* and as such should not be shipped as part of a final application
* without extensive testing on the part of the organization releasing
* the end-user product.
*/
#include "stdafx.h"
#include "mapxsamp.h"
#include "FindDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFindDlg dialog
CFindDlg::CFindDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFindDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFindDlg)
m_chkUseRefineInfo = FALSE;
m_editZoom = 25;
m_editRefineItem = _T("");
m_editFindItem = _T("");
//}}AFX_DATA_INIT
}
void CFindDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFindDlg)
DDX_Control(pDX, IDC_REFINELAYERCOMBO, m_cbRefineLayer);
DDX_Control(pDX, IDC_FINDLAYERCOMBO, m_cbFindLayer);
DDX_Check(pDX, IDC_USEREFINELAYERCHECK, m_chkUseRefineInfo);
DDX_Text(pDX, IDC_ZOOMLEVELEDIT, m_editZoom);
DDX_Text(pDX, IDC_REFINEITEMEDIT, m_editRefineItem);
DDX_Text(pDX, IDC_FINDITEMEDIT, m_editFindItem);
//}}AFX_DATA_MAP
DDX_Control(pDX, IDC_MAP1, m_ctrlMapX);
}
BEGIN_MESSAGE_MAP(CFindDlg, CDialog)
//{{AFX_MSG_MAP(CFindDlg)
ON_BN_CLICKED(IDC_FINDBUTTON, OnFindbutton)
ON_BN_CLICKED(IDC_USEREFINELAYERCHECK, OnUserefinelayercheck)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFindDlg message handlers
BOOL CFindDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// add layer names to the combo box
try {
CMapXLayers lyrs = m_ctrlMapX.GetLayers();
for (long i=1; i<=lyrs.GetCount(); i++) {
m_cbFindLayer.AddString(lyrs.Item(i).GetName());
m_cbRefineLayer.AddString(lyrs.Item(i).GetName());
}
m_cbFindLayer.SetCurSel(0);
m_cbRefineLayer.SetCurSel(0);
}
catch (COleDispatchException *e) {
e->ReportError();
e->Delete();
}
catch (COleException *e) {
e->ReportError();
e->Delete();
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CFindDlg::OnFindbutton()
{
int iItem = m_cbFindLayer.GetCurSel();
CString sLyr;
m_cbFindLayer.GetLBText(iItem, sLyr);
try {
CMapXLayer lyr = m_ctrlMapX.GetLayers().Item(sLyr);
CMapXLayerFind findLyr = lyr.GetFind();
UpdateData(TRUE);
CMapXFindFeature foundObj;
if (m_chkUseRefineInfo) {
iItem = m_cbRefineLayer.GetCurSel();
m_cbRefineLayer.GetLBText(iItem, sLyr);
findLyr.SetRefineLayer(m_ctrlMapX.GetLayers().Item(sLyr));
foundObj = findLyr.Search(m_editFindItem, m_editRefineItem);
}
else
foundObj = findLyr.Search(m_editFindItem, "");
if ((foundObj.GetFindRC()%10) == 1) {
double dZoom = (double)m_editZoom;
double dCenterX = foundObj.GetCenterX();
double dCenterY = foundObj.GetCenterY();
m_ctrlMapX.ZoomTo(dZoom, dCenterX, dCenterY);
}
else
AfxMessageBox("Exact Match Not Found.");
}
catch (COleDispatchException *e) {
e->ReportError();
e->Delete();
}
catch (COleException *e) {
e->ReportError();
e->Delete();
}
}
void CFindDlg::OnUserefinelayercheck()
{
UpdateData(TRUE);
if (m_chkUseRefineInfo)
GetDlgItem(IDC_REFINELAYERCOMBO)->EnableWindow(TRUE);
else
GetDlgItem(IDC_REFINELAYERCOMBO)->EnableWindow(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -