📄 downview.cpp
字号:
// DownView.cpp : 实现文件
//
#include "stdafx.h"
#include "MapEditor.h"
#include "DownView.h"
MESH1 m_mesh[50][50];
extern POINT bp;
extern CString m_Pathname;
extern CString m_name;
bool flag = false;
int x,y;
extern int l;
extern int num[50][4];
// CDownView
IMPLEMENT_DYNCREATE(CDownView, CView)
CDownView::CDownView()
{
}
CDownView::~CDownView()
{
}
BEGIN_MESSAGE_MAP(CDownView, CView)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
// CDownView 绘图
void CDownView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: 在此添加绘制代码
int i;
int j,m,n;
int k = 0;
CBrush m_brush;
CPen m_pen;
CRect m_rect;
HBITMAP m_hbmp;
HDC hdc;
hdc = CreateCompatibleDC(pDC->m_hDC);
m_brush.CreateSolidBrush(RGB(0,0,0));
m_pen.CreatePen(PS_SOLID,1,RGB(0,0,255));
this->GetClientRect(&m_rect);
pDC->FillRect(&CRect(0,0,m_rect.right,m_rect.bottom),&m_brush);m = 0;
m = 0;
for(i = 0; i < m_rect.bottom ; i = i + 32)
{
n = 0;
for(j = 0; j < m_rect.right; j = j + 32)
{
m_mesh[m][n].i = 0;
m_mesh[m][n].rect = CRect(j,i, j+32,i+32);
//k = k + 1;
n = n + 1;
}
m = m + 1;
}
x = m - 1;
y = n - 1;
pDC->SelectObject(&m_pen);
m_hbmp =( HBITMAP)LoadImage(::AfxGetInstanceHandle(),//
"1.bmp",//文件名
IMAGE_BITMAP, //位图方式
0,//图形宽
0,//图形高
LR_LOADFROMFILE|LR_CREATEDIBSECTION//方式
);
SelectObject(hdc,m_hbmp);
//BitBlt(pDC->m_hDC,0,0,32,32, hdc,0,0,SRCCOPY);
for(i=0;i<l;i++)
BitBlt(pDC->m_hDC,num[i][1]*32,num[i][0]*32,32,32, hdc,num[i][2],num[i][3],SRCCOPY);
pDC->SelectObject(&m_pen);
for(i = 0; i < m_rect.bottom; i = i + 32)
{
pDC->MoveTo(0, i);
pDC->LineTo((int)m_rect.right,i);
}
for(j = 0; j < (int)m_rect.right; j = j + 32)
{
pDC->MoveTo(j, 0);
pDC->LineTo(j,(int)m_rect.bottom);
}
}
// CDownView 诊断
#ifdef _DEBUG
void CDownView::AssertValid() const
{
CView::AssertValid();
}
#ifndef _WIN32_WCE
void CDownView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif
#endif //_DEBUG
// CDownView 消息处理程序
void CDownView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CClientDC dc(this);
HDC hdc;
HBITMAP m_hbmp;
int i, j;
bool flag = false;
hdc = CreateCompatibleDC(dc.m_hDC);
m_hbmp =( HBITMAP)LoadImage(::AfxGetInstanceHandle(),//
m_Pathname,//文件名
IMAGE_BITMAP, //位图方式
0,//图形宽
0,//图形高
LR_LOADFROMFILE|LR_CREATEDIBSECTION//方式
);
SelectObject(hdc,m_hbmp);
for(i = 0; i < x; i++ )
{
for(j = 0; j < y ; j++)
{
if(PtInRect(&m_mesh[i][j].rect,point))
{
BitBlt(dc.m_hDC,m_mesh[i][j].rect.left,m_mesh[i][j].rect.top,32,32, hdc,bp.x,bp.y,SRCCOPY);
m_mesh[i][j].i=1;
m_mesh[i][j].point.x=bp.x;
m_mesh[i][j].point.y=bp.y;
num[l][0]=i;
num[l][1]=j;
num[l][2]=bp.x;
num[l][3]=bp.y;
l++;
flag = true;
break;
}
}
if(flag)
{
break;
}
}
CView::OnLButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -