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

📄 finddlg.cpp

📁 mapx嵌入式插件
💻 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 "MapXMobileViewer.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

	m_pReferenceMapX=NULL;
	m_nLayerIndex=1;
}


void CFindDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFindDlg)
	DDX_Text(pDX, IDC_FINDITEMEDIT, m_editFindItem);
	DDX_Text(pDX, IDC_FINDZOOM, m_editZoom);
	//}}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)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFindDlg message handlers

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

	SHINITDLGINFO	shidi;
	memset(&shidi, 0, sizeof(SHINITDLGINFO));
	shidi.dwMask = SHIDIM_FLAGS;
	shidi.dwFlags = SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
	shidi.hDlg = m_hWnd;

	if (!SHInitDialog(&shidi))
	{
		DWORD dwError = GetLastError();
		TRACE(_T("Warning: Making Fullscreen dialog failed during dialog init, error %d.\n"), dwError);
	}
	
	// add layer names to the combo box
	TRY {
		// first add layers from the main mapx (mini clone map)
		CMapXLayers lyrs = m_ctrlMapX.GetLayers();
		if (m_pReferenceMapX) {
			m_ctrlMapX.SetNumericCoordSys(m_pReferenceMapX->GetNumericCoordSys());
			CMapXLayers lyrsRef = m_pReferenceMapX->GetLayers();
			for (long i=1; i<=lyrsRef.GetCount(); i++) { 
				CMapXLayer l = lyrsRef.Item(i);
				CMapXLayer lAdd = lyrs.Add(l.GetFilespec(), i);
				lAdd.SetAutoLabel(l.GetAutoLabel());
				lAdd.SetOverrideStyle(l.GetOverrideStyle());
				lAdd.SetStyle(l.GetStyle());
				lAdd.SetZoomLayer(l.GetZoomLayer());
				lAdd.SetZoomMax(l.GetZoomMax());
				lAdd.SetZoomMin(l.GetZoomMin());
			}
			m_ctrlMapX.ZoomTo(m_pReferenceMapX->GetZoom(), m_pReferenceMapX->GetCenterX(), m_pReferenceMapX->GetCenterY());
		}
		CMapXLayer lyr = m_ctrlMapX.GetLayers().Item(m_nLayerIndex);
		CString strName;
		strName.Format(IDS_FINDINLAYER, lyr.GetName());
		SetWindowText(strName);
		m_ctrlMapX.SetCurrentTool(miZoomInTool);

	}
	CATCH (COleDispatchException, e) {
		e->ReportError();
		e->Delete();
	}
	AND_CATCH (COleException, e) {
		e->ReportError();
		e->Delete();
	} 
	END_CATCH
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void CFindDlg::OnFindbutton() 
{
	TRY {
		CMapXLayer lyr = m_ctrlMapX.GetLayers().Item(m_nLayerIndex);
		CMapXLayerFind findLyr = lyr.GetFind();

		UpdateData(TRUE);

		CMapXFindFeature foundObj;

		if (m_chkUseRefineInfo) {
			// uncomment if you want to add refining search capability
			//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, _T(""));	

		if ((foundObj.GetFindRC()%10) == 1) {
			// found something, zoom to it
			double dZoom = (double)m_editZoom; 
			double dCenterX = foundObj.GetCenterX();
			double dCenterY = foundObj.GetCenterY();
			m_ctrlMapX.ZoomTo(dZoom, dCenterX, dCenterY);
		}
		else
			AfxMessageBox(IDS_FINDNOMATCH);
	}
	CATCH (COleDispatchException, e) {
		e->ReportError();
		e->Delete();
	}
	AND_CATCH(COleException, e) {
		e->ReportError();
		e->Delete();
	}
	END_CATCH
}

BEGIN_EVENTSINK_MAP(CFindDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CFindDlg)
	ON_EVENT(CFindDlg, IDC_MAP1, 3 /* ToolUsed */, OnToolUsedMap1, VTS_I2 VTS_R8 VTS_R8 VTS_R8 VTS_R8 VTS_R8 VTS_BOOL VTS_BOOL VTS_PBOOL)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CFindDlg::OnToolUsedMap1(short ToolNum, double X1, double Y1, double X2, double Y2, double Distance, BOOL Shift, BOOL Ctrl, BOOL FAR* EnableDefault) 
{
	*EnableDefault=TRUE;
	
}

void CFindDlg::OnCancel() 
{
	m_pReferenceMapX->ZoomTo(m_ctrlMapX.GetZoom(), m_ctrlMapX.GetCenterX(), m_ctrlMapX.GetCenterY());
	
	CDialog::OnCancel();
}

⌨️ 快捷键说明

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