?? myscrollview.cpp
字號:
// MyScrollView.cpp : implementation file
//
#include "stdafx.h"
#include "GpsNav.h"
#include "MyScrollView.h"
#include "GpsNavDoc.h"
void Marker(LONG x, LONG y, HDC hdc);
CPoint CoordTranstport(double x,double y);
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyScrollView
IMPLEMENT_DYNCREATE(CMyScrollView, CScrollView)
CMyScrollView::CMyScrollView()
{
}
CMyScrollView::~CMyScrollView()
{
}
BEGIN_MESSAGE_MAP(CMyScrollView, CScrollView)
//{{AFX_MSG_MAP(CMyScrollView)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONUP()
ON_WM_ERASEBKGND()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyScrollView drawing
void CMyScrollView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx=1000;
sizeTotal.cy =1200;
SetScrollSizes(MM_TEXT, sizeTotal);
SetScrollPos(SB_HORZ,0,TRUE);
SetScrollPos(SB_VERT,600,TRUE);
Invalidate(TRUE);
UpdateWindow();
}
void CMyScrollView::OnDraw(CDC* pDC)
{
CMyGpsNavDoc * pDoc =(CMyGpsNavDoc* ) GetDocument();
// TODO: add draw code here
CBitmap bmp;
bmp.LoadBitmap(img);
CClientDC pdc(this);
OnPrepareDC(&pdc);
CDC mDC;
mDC.CreateCompatibleDC(&pdc);
mDC.SelectObject(&bmp);
BITMAP bmpinfo;
//
bmp.GetBitmap(&bmpinfo);
CRect r(0,0,bmpinfo.bmWidth,bmpinfo.bmHeight);
pdc.DPtoLP(&r);
r.OffsetRect(100,50);
pdc.BitBlt(0,0,r.Size().cx,r.Size().cy,&mDC,0,0,SRCCOPY);
CPoint cp;
cp=pDoc->pt;
Marker(cp.x, cp.y,pDC->m_hDC);
//得到視圖的無效矩形
/*
CRect rectClip;
CRect rectStroke;
pDC->GetClipBox(&rectClip);
pDC->LPtoDP(&rectClip);
rectClip.InflateRect(1, 1);
*/
CTypedPtrList<CObList,CStroke*>& strokeList = pDoc->m_strokeList;
POSITION pos = strokeList.GetHeadPosition();
while (pos != NULL)
{
CStroke* pStroke = strokeList.GetNext(pos);
/*
rectStroke = pStroke->GetBoundingRect();
pDC->LPtoDP(&rectStroke);
rectStroke.InflateRect(1, 1);
if (!rectStroke.IntersectRect(&rectStroke, &rectClip))//判斷兩矩形的交際是否為空
continue;
*/
if(pStroke->m_pointArray.GetSize()>0)
{
pStroke->DrawStroke(pDC); //畫線
}
}
}
/////////////////////////////////////////////////////////////////////////////
// CMyScrollView diagnostics
#ifdef _DEBUG
void CMyScrollView::AssertValid() const
{
CScrollView::AssertValid();
}
void CMyScrollView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMyScrollView message handlers
//DEL BOOL CMyScrollView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
//DEL {
//DEL // TODO: Add your specialized code here and/or call the base class
//DEL
//DEL return CScrollView::OnScroll(nScrollCode, nPos, bDoScroll);
//DEL }
void CMyScrollView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
pDC->SetMapMode(MM_ANISOTROPIC);
CPoint cPorg(GetScrollPos(SB_HORZ),GetScrollPos(SB_VERT));
pDC->SetViewportOrg(-cPorg);
CScrollView::OnPrepareDC(pDC, pInfo);
}
void CMyScrollView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (GetCapture() != this)
{
return; //如果該視圖沒有俘獲鼠標,那么不在該區域繪制
}
HCURSOR hCursor;
hCursor = AfxGetApp()->LoadCursor(IDC_MYCURSOR);
SetCursor(hCursor);
m_ptPrev = point;
}
void CMyScrollView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (GetCapture() != this)
return; //
//m_ptPrev = point;
ReleaseCapture(); //
}
BOOL CMyScrollView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return TRUE;
//return CScrollView::OnEraseBkgnd(pDC);
}
void CMyScrollView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SetCapture();
m_ptPrev = point;
CScrollView::OnLButtonDown(nFlags, point);
}
BOOL CMyScrollView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
{
// TODO: Add your specialized code here and/or call the base class
Invalidate();
return CScrollView::OnScroll(nScrollCode, nPos, bDoScroll);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -