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

📄 showleft.cpp

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

#include "stdafx.h"
#include "SuperViseSystem.h"
#include "ShowLeft.h"

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

/////////////////////////////////////////////////////////////////////////////
// CShowLeft

CShowLeft::CShowLeft()
{	
//-------------	
	rect_0.left = 0;
	rect_0.top = 0;
	rect_0.right = 38;
	rect_0.bottom = 108;
	m_Picture1[0].rect = rect_0;	
//---------------		
    rect_1.left = 0;
	rect_1.top = 110;
	rect_1.right = 38;
	rect_1.bottom = 205;
	m_Picture1[1].rect = rect_1;
//---------------		
    rect_2.left = 0;
	rect_2.top = 211;
	rect_2.right = 38;
	rect_2.bottom = 302;
	m_Picture1[2].rect = rect_2;
//---------------		
    rect_3.left = 0;
	rect_3.top = 308;
	rect_3.right = 38;
	rect_3.bottom = 400;
	m_Picture1[3].rect = rect_3;
//---------------		
    rect_4.left = 0;
	rect_4.top = 404;
	rect_4.right = 38;
	rect_4.bottom = 498;
	m_Picture1[4].rect = rect_4;
	

}

CShowLeft::~CShowLeft()
{

}


BEGIN_MESSAGE_MAP(CShowLeft, CWnd)
	//{{AFX_MSG_MAP(CCreateMap)
	ON_WM_PAINT()
	ON_WM_MOUSEMOVE()
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CCreateMap message handlers
//不仅在此创建窗口而且还要让子类进行调用。
int CShowLeft::CreateWnd(DWORD dwStyle, CRect &rect, CWnd *pParent, UINT id)
{
	int result;	

 	result = CWnd::CreateEx(NULL,//WS_EX_WINDOWEDGE , 
		NULL, NULL, dwStyle, 
		rect.left, rect.top, rect.Width(), rect.Height(),
		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 CShowLeft::SetImage(HBITMAP *hbp)
{
	m_bpImageWnd.Attach(hbp);
	m_bIsSetImage = true;
	this->Invalidate();
}

///////////////////////////////////////////////////////////////////////////////
//不仅要接受,而且还要绘图,所有要OnPaint()
void CShowLeft::OnPaint() 
{
	CPaintDC dc(this); // device context for painting	
	// TODO: Add your message handler code here
	if(m_bIsSetImage)
	{
		m_MemDC.SelectObject(m_bpImageWnd);
		dc.BitBlt(0,0,m_rcImgWnd.Width(),m_rcImgWnd.Height(),&m_MemDC,0,0,SRCCOPY);
	}
	// Do not call CWnd::OnPaint() for painting messages
}
///////////////////////////////////////////////////////////////////////////////
//要计算鼠标的移动时的坐标点,要有鼠标移动的消息函数!
void CShowLeft::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);
}

void CShowLeft::OnLButtonDown(UINT nFlags, CPoint point) 
{
	//切换窗口
	for(int i=0;i<5;i++)
	{
		rect_all = m_Picture1[i].rect;
		
		if (((rect_all.left < point.x) && (point.x< rect_all.right))
			&& (rect_all.top < point.y) && (point.y < rect_all.bottom))
		{   
			m_Picture1[i].bIsIn = true;
			this->GetParent()->PostMessage(WM_CHANGE_RHT_PANEL,i);
		//	this->Invalidate(false);	
		}
		
	}
}

⌨️ 快捷键说明

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