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

📄 showsecondright.cpp

📁 此代码使用bmp图作为主要界面
💻 CPP
字号:
// ShowSecondRight.cpp : implementation file
//

#include "stdafx.h"
#include "SuperViseSystem.h"
#include "ShowSecondRight.h"

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

/////////////////////////////////////////////////////////////////////////////
// CShowSecondRight

CShowSecondRight::CShowSecondRight()
{
	m_bIsSetImage = true;
//------------------------
	rect_0.left = 120;
	rect_0.top = 441;
	rect_0.right = 140;
	rect_0.bottom = 460;

	m_MainPicture[0].rect = rect_0;
//------------------------
	rect_1.left = 172;
	rect_1.top = 441;
	rect_1.right = 195;
	rect_1.bottom = 460;

	m_MainPicture[1].rect = rect_1;
//------------------------
	rect_2.left = 120;
	rect_2.top = 466;
	rect_2.right = 140;
	rect_2.bottom = 485;

	m_MainPicture[2].rect = rect_2;
//------------------------
	rect_3.left = 172;
	rect_3.top = 466;
	rect_3.right = 195;
	rect_3.bottom = 485;

	m_MainPicture[3].rect = rect_3;
//------------------------
	rect_4.left = 120;
	rect_4.top = 491;
	rect_4.right = 140;
	rect_4.bottom = 510;

	m_MainPicture[4].rect = rect_4;
//------------------------
	rect_5.left = 172;
	rect_5.top = 491;
	rect_5.right = 195;
	rect_5.bottom = 510;

	m_MainPicture[5].rect = rect_5;
}

CShowSecondRight::~CShowSecondRight()
{
}


BEGIN_MESSAGE_MAP(CShowSecondRight, CWnd)
	//{{AFX_MSG_MAP(CShowSecondRight)
	ON_WM_LBUTTONDOWN()
	ON_WM_PAINT()
	ON_MESSAGE(WM_MYMESSAGE,OnMyMessage)
	ON_WM_MOUSEMOVE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CShowSecondRight message handlers

BOOL CShowSecondRight::Create(DWORD dwStyle, CRect& rect, CWnd* pParent, UINT id) 
{		BOOL result ;
	result = CWnd::CreateEx(NULL , 
		NULL, NULL, dwStyle, 
		rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
		pParent->GetSafeHwnd(), (HMENU)id) ;
	
    if( !result )
	AfxMessageBox("Error creating window");

	m_rcImgWnd.top = m_rcImgWnd.left  = 0;
	m_rcImgWnd.bottom = m_rcImgWnd.top + rect.Height();
	m_rcImgWnd.right = m_rcImgWnd.left + rect.Width();

	//m_MemDC为CDC类的一个对象.
	m_MemDC.CreateCompatibleDC(GetDC());// 创建什么东西?

	return result;
}

void CShowSecondRight::OnLButtonDown(UINT nFlags, CPoint point) 
{
	for(int i=0;i<6;i++)
	{
		rect_all = m_MainPicture[i].rect;
		
		if (((rect_all.left < point.x) && (point.x< rect_all.right))
			&& (rect_all.top < point.y) && (point.y < rect_all.bottom))
		{   
			m_MainPicture[i].bIsIn = true;
			this->GetParent()->PostMessage(WM_SECOND_RHT,i);
		//	this->Invalidate(false);	
		}
		
	}
	CWnd::OnLButtonDown(nFlags, point);
}

void CShowSecondRight::OnPaint() 
{
	CPaintDC dc(this);	
	if(m_bIsSetImage)
	{
		m_MemDC.SelectObject(m_bpImageWnd);
		dc.BitBlt(0,0,m_rcImgWnd.Width(),m_rcImgWnd.Height(),&m_MemDC,0,0,SRCCOPY);
	}
}

void CShowSecondRight::SetImage(HBITMAP *hbp)
{
	m_bpImageWnd.Attach(hbp);
	m_bIsSetImage = true;
	this->Invalidate();
}

void CShowSecondRight::OnMyMessage(int BT_IDC)
{
	GetParent()->PostMessage(WM_MYMESSAGE,BT_IDC);
}


void CShowSecondRight::OnMouseMove(UINT nFlags, CPoint point) 
{
	//////////////////////////////////////////////////////
	//计算鼠标当前的坐标点;
	
	///////////////////////////////////////////////////////
	CDC *pDC = GetDC();
	CString strFormat;
	CString  str;
	CPoint pt = point;
	strFormat.Format("x %d, y %d",pt.x,pt.y);
	str.Format("                                   ");
	pDC->TextOut(50,50,str);
	pDC->TextOut(50,50,strFormat);
	CWnd::OnMouseMove(nFlags, point);
}

⌨️ 快捷键说明

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