www.pudn.com > mapx_test.rar > mapx_testView.cpp


// mapx_testView.cpp : implementation of the CMapx_testView class 
// 
 
#include "stdafx.h" 
#include "mapx_test.h" 
 
#include "mapx_testDoc.h" 
#include "mapx_testView.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CMapx_testView 
 
IMPLEMENT_DYNCREATE(CMapx_testView, CView) 
 
BEGIN_MESSAGE_MAP(CMapx_testView, CView) 
	//{{AFX_MSG_MAP(CMapx_testView) 
	ON_COMMAND(ID_FILE_START, OnFileStart) 
	ON_WM_CREATE() 
	ON_WM_SIZE() 
	ON_WM_SETFOCUS() 
	ON_COMMAND(ID_ZOOM_IN, OnZoomIn) 
	ON_COMMAND(ID_ZOOM_OUT, OnZoomOut) 
	ON_COMMAND(ID_ARROW_TOOL, OnArrowTool) 
	//}}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() 
 
///////////////////////////////////////////////////////////////////////////// 
// CMapx_testView construction/destruction 
 
CMapx_testView::CMapx_testView() 
{ 
	geoset_path="shenzhen_test.gst"; 
	 
	// TODO: add construction code here 
 
} 
 
CMapx_testView::~CMapx_testView() 
{ 
} 
 
BOOL CMapx_testView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CMapx_testView drawing 
 
void CMapx_testView::OnDraw(CDC* pDC) 
{ 
	CMapx_testDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	// TODO: add draw code for native data here 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CMapx_testView printing 
 
BOOL CMapx_testView::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
void CMapx_testView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add extra initialization before printing 
} 
 
void CMapx_testView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add cleanup after printing 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CMapx_testView diagnostics 
 
#ifdef _DEBUG 
void CMapx_testView::AssertValid() const 
{ 
	CView::AssertValid(); 
} 
 
void CMapx_testView::Dump(CDumpContext& dc) const 
{ 
	CView::Dump(dc); 
} 
 
CMapx_testDoc* CMapx_testView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMapx_testDoc))); 
	return (CMapx_testDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CMapx_testView message handlers 
 
int CMapx_testView::OnCreate(LPCREATESTRUCT lpCreateStruct)  
{ 
	if (CView::OnCreate(lpCreateStruct) == -1) 
		return -1; 
	RECT windRect; 
	//GetClientRect(&windRect); 
 
	if (!m_ctrlMapX.Create(NULL, WS_VISIBLE, windRect, this,IDC_MAP)) 
		return -1; 
	 
	return 0; 
} 
 
void CMapx_testView::OnSize(UINT nType, int cx, int cy)  
{ 
	CView::OnSize(nType, cx, cy); 
	 
if (m_ctrlMapX.m_hWnd != NULL) 
		m_ctrlMapX.MoveWindow(0,0,cx,cy,TRUE); 
			 
} 
 
void CMapx_testView::OnFileStart()  
{ 
	// TODO: Add your command handler code here 
	/* 
	CFileDialog dlgFile(TRUE, "*.gst", NULL, OFN_HIDEREADONLY , szTabFilter, this); 
	dlgFile.m_ofn.lpstrTitle = "Open MapInfo Map"; 
 
	if (dlgFile.DoModal() == IDCANCEL) 
		return; 
		*/ 
 
 
 
     
	m_ctrlMapX.SetGeoSet(geoset_path); 
   //m_ctrlMapX.SetSize(6000, 4500); 
	m_maptitle = m_ctrlMapX.GetTitle(); 
    //m_maptitle.SetBorder(FALSE); 
	m_maptitle.SetVisible(FALSE); 
	 
/* 
	try { 
			// Close the existing set of map layers and load the Canada map 
			TRACE0("Old Geoset: " + m_ctrlMapX.GetGeoSet()); 
			m_ctrlMapX.SetGeoSet(geoset_path); 
			//m_ctrlMapX.SetTitleText(""); 
			TRACE0("New Geoset: " + m_ctrlMapX.GetGeoSet()); 
		 
		}  
	catch (COleDispatchException *e) { 
		e->ReportError(); 
		e->Delete(); 
	}  
	catch (COleException *e) { 
		e->ReportError(); 
		e->Delete(); 
	} 
	*/ 
} 
 
void CMapx_testView::OnSetFocus(CWnd* pOldWnd)  
{ 
	CView::OnSetFocus(pOldWnd); 
	 
      m_ctrlMapX.SetFocus(); 
	 
} 
 
void CMapx_testView::OnZoomIn()  
{ 
   m_ctrlMapX.SetCurrentTool(miZoomInTool);	 
} 
 
void CMapx_testView::OnZoomOut()  
{ 
	// TODO: Add your command handler code here 
	m_ctrlMapX.SetCurrentTool(miZoomOutTool);	 
} 
 
void CMapx_testView::OnArrowTool()  
{ 
	// TODO: Add your command handler code here 
	m_ctrlMapX.SetCurrentTool(miArrowTool); 
}