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

📄 zhongguoview.cpp

📁 基于VC,MAPX开发的gis小型系统
💻 CPP
字号:
// zhongguoView.cpp : implementation of the CZhongguoView class
//

#include "stdafx.h"
#include "zhongguo.h"

#include "zhongguoDoc.h"
#include "zhongguoView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CZhongguoView

IMPLEMENT_DYNCREATE(CZhongguoView, CView)

BEGIN_MESSAGE_MAP(CZhongguoView, CView)
	//{{AFX_MSG_MAP(CZhongguoView)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_SETFOCUS()
	ON_COMMAND(IDC_ZOOMIN, OnZoomin)
	ON_UPDATE_COMMAND_UI(IDC_ZOOMIN, OnUpdateZoomin)
	ON_COMMAND(IDC_ZOOMOUT, OnZoomout)
	ON_UPDATE_COMMAND_UI(IDC_ZOOMOUT, OnUpdateZoomout)
	ON_COMMAND(IDC_PANTOOL, OnPantool)
	ON_UPDATE_COMMAND_UI(IDC_PANTOOL, OnUpdatePantool)
	ON_COMMAND(IDC_CENTERTOOL, OnCentertool)
	ON_UPDATE_COMMAND_UI(IDC_CENTERTOOL, OnUpdateCentertool)
	ON_COMMAND(IDC_LAYER, OnLayer)
	ON_COMMAND(IDC_DATA,OnData)
	ON_COMMAND(IDC_TOOLSELECT, OnToolselect)
	ON_UPDATE_COMMAND_UI(IDC_TOOLSELECT, OnUpdateToolselect)
	ON_COMMAND(IDC_ARROWTOOL, OnArrowTool)
	ON_UPDATE_COMMAND_UI(IDC_ARROWTOOL, OnUpdateArrowTool)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CZhongguoView construction/destruction

CZhongguoView::CZhongguoView()
{
	// TODO: add construction code here
    m_iMouseStation = 0;
}

CZhongguoView::~CZhongguoView()
{
}

BOOL CZhongguoView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CZhongguoView drawing

void CZhongguoView::OnDraw(CDC* pDC)
{
	CZhongguoDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CZhongguoView printing

BOOL CZhongguoView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CZhongguoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CZhongguoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CZhongguoView diagnostics

#ifdef _DEBUG
void CZhongguoView::AssertValid() const
{
	CView::AssertValid();
}

void CZhongguoView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CZhongguoDoc* CZhongguoView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CZhongguoDoc)));
	return (CZhongguoDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CZhongguoView message handlers

int CZhongguoView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	SetCapture();
	BeginWaitCursor();

	char CurrentPath[80];
	GetCurrentDirectory(80,CurrentPath);
	char m_strPath[120];
	strcpy(m_strPath,CurrentPath);
	strcat(m_strPath,"\\china.gst");

	CRect viewrect;
	GetClientRect(viewrect);
	m_ctrlMapx.Create(NULL,WS_VISIBLE,viewrect,this,IDC_MAP);
	m_ctrlMapx.SetGeoSet(m_strPath);
	m_ctrlMapx.SetMousePointer(miHourglassCursor);
	m_ctrlMapx.SetRedrawInterval(150);

	CString str=m_ctrlMapx.GetTitleText();
	m_ctrlMapx.SetTitleText(str);
	m_ctrlMapx.SetMapUnit(1);
   
	ReleaseCapture();
	EndWaitCursor();
	m_ctrlMapx.SetMousePointer(0);
	return 0;
}

void CZhongguoView::OnSize(UINT nType, int cx, int cy) 
{
	CView::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	if(cx!=0 && cy!=0)
	{
		m_ctrlMapx.MoveWindow(0,0,cx,cy,TRUE);
	}
}

void CZhongguoView::OnSetFocus(CWnd* pOldWnd) 
{
	CView::OnSetFocus(pOldWnd);
	
	// TODO: Add your message handler code here
	m_ctrlMapx.SetFocus();
}

void CZhongguoView::OnZoomin() 
{
	// TODO: Add your command handler code here
	m_ctrlMapx.SetCurrentTool(miZoomInTool);
	m_iMouseStation = 11;
}

void CZhongguoView::OnUpdateZoomin(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if(m_iMouseStation==11)
	{
		pCmdUI->SetCheck(TRUE);
	}
	else
	{
		pCmdUI->SetCheck(FALSE);
	}
}

void CZhongguoView::OnZoomout() 
{
	// TODO: Add your command handler code here
	m_ctrlMapx.SetCurrentTool(miZoomOutTool);
    m_iMouseStation=13;
}

void CZhongguoView::OnUpdateZoomout(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if(m_iMouseStation==13)
	{
		pCmdUI->SetCheck(TRUE);
	}
	else
	{
		pCmdUI->SetCheck(FALSE);
	}
}

void CZhongguoView::OnPantool() 
{
	// TODO: Add your command handler code here
	m_ctrlMapx.SetCurrentTool(miPanTool);
	m_iMouseStation=14;
}

void CZhongguoView::OnUpdatePantool(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if(m_iMouseStation == 14)
	{
		pCmdUI->SetCheck(TRUE);
	}
	else
	{
		pCmdUI->SetCheck(FALSE);
	}
}

void CZhongguoView::OnCentertool() 
{
	// TODO: Add your command handler code here
	m_ctrlMapx.SetCurrentTool(miCenterTool);
	m_iMouseStation=15;
}

void CZhongguoView::OnUpdateCentertool(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if(m_iMouseStation==15)
	{
		pCmdUI->SetCheck(TRUE);
	}
	else
	{
		pCmdUI->SetCheck(FALSE);
	}
}

void CZhongguoView::OnLayer() 
{
	// TODO: Add your command handler code here
	CMapXLayers ls;
	ls=m_ctrlMapx.GetLayers();
	ls.LayersDlg();
}

void CZhongguoView::OnData() 
{
	 //TODO: Add your command handler code here
/*	COleVariant variant;
	CMapXLayers ls;
	CMapXDataset dt;
	ls=m_ctrlMapx.GetLayers();
	for(int i=0;i<ls.GetCount();i++)
	{
		variant=ls.Item(i+1);
		dt=m_ctrlMapx.GetDatasets().Add(miDataSetLayer,variant);
	}*/
}

void CZhongguoView::OnToolselect() 
{
	// TODO: Add your command handler code here
	m_ctrlMapx.SetCurrentTool(miSelectTool);
}

void CZhongguoView::OnUpdateToolselect(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(TRUE);
}

void CZhongguoView::OnArrowTool() 
{
	// TODO: Add your command handler code here
	m_ctrlMapx.SetCurrentTool(miArrowTool);
	m_iMouseStation=16;
}

void CZhongguoView::OnUpdateArrowTool(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if(m_iMouseStation==16)
	{
		pCmdUI->SetCheck(TRUE);
	}
	else 
	{
		pCmdUI->SetCheck(FALSE);
	}
}

⌨️ 快捷键说明

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