// CSearchView drawing
void CSearchView::OnDraw(CDC* pDC)
{
CSearchDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CSearchView diagnostics
#ifdef _DEBUG
void CSearchView::AssertValid() const
{
CView::AssertValid();
}
void CSearchView::Dump(CDumpContext&; dc) const
{
CView::Dump(dc);
}
CSearchDoc* CSearchView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSearchDoc)));
return (CSearchDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSearchView message handlers
int CSearchView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
m_ctrlMapX.Create(NULL,WS_VISIBLE,CRect(0,0,400,400),this,IDC_MAP);
m_ctrlMapX.SetGeoSet("./maps/node.gst");
m_ctrlMapX.CreateCustomTool(MYTOOL_DISTANCE,miToolTypePoly,miCrossCursor);
m_ctrlMapX.CreateCustomTool(INFO_TOOL, miToolTypePoint, miCrossCursor);
m_ctrlMapX.CreateCustomTool(INFO_POWER, miToolTypePoint, miCrossCursor);
return 0;
}
void CSearchView::OnSetFocus(CWnd* pOldWnd)
{
CView::OnSetFocus(pOldWnd);
m_ctrlMapX.SetFocus();
// TODO: Add your message handler code here
}
void CSearchView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
m_ctrlMapX.MoveWindow(0,0,cx,cy,TRUE);
// TODO: Add your message handler code here
}
BOOL CSearchView::OnMouseUpInMap(short Button, short Shift, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y)
{
if (Button == 2) {
CMenu menu; // top-level menu
CMenu *pMenu=NULL; // pop-up menu
// Load the menu resource.
menu.LoadMenu(IDR_SEARCHTYPE);
// TrackPopupMenu cannot display the top-level menu, so get
// the handle of the first pop-up menu.
pMenu = menu.GetSubMenu(1);
if (!pMenu)
return TRUE;
SetMenuDefaultItem(pMenu->m_hMenu, ID_VIEW_PROPERTIES, FALSE);
POINT pt;
GetCursorPos(&;pt);
pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, this, NULL);
// Destroy the menu.
menu.DestroyMenu();
}
return TRUE;
}
BOOL CSearchView::OnMouseMoveInMap(short Button, short Shift, OLE_XPOS_PIXELS x,
OLE_YPOS_PIXELS y)
{
POINT pt;
float map_x;
float map_y;
double latitude;
double longitude;
GetCursorPos(&;pt);
map_x=(float)pt.x;
map_y=(float)pt.y;
m_ctrlMapX.ConvertCoord(&;map_x,&;map_y,&;longitude,&;latitude,miScreenToMap);
CString str1;
CString str2;
str1.Format("经度: %f", longitude);
str2.Format("纬度: %f", latitude);
((CMai